LCOV - code coverage report
Current view: top level - gcc/c - c-typeck.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.8 % 9214 8639
Test Date: 2026-06-13 15:38:22 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              : static bool top_array_vla_p (const_tree type);
     145              : 
     146              : 
     147              : /* Return true if EXP is a null pointer constant, false otherwise.  */
     148              : 
     149              : bool
     150    188705041 : null_pointer_constant_p (const_tree expr)
     151              : {
     152              :   /* This should really operate on c_expr structures, but they aren't
     153              :      yet available everywhere required.  */
     154    188705041 :   tree type = TREE_TYPE (expr);
     155              : 
     156              :   /* An integer constant expression with the value 0, such an expression
     157              :      cast to type void*, or the predefined constant nullptr, are a null
     158              :      pointer constant.  */
     159    188705041 :   if (expr == nullptr_node)
     160              :     return true;
     161              : 
     162    188704357 :   return (TREE_CODE (expr) == INTEGER_CST
     163     19115976 :           && !TREE_OVERFLOW (expr)
     164     19115879 :           && integer_zerop (expr)
     165    192642933 :           && (INTEGRAL_TYPE_P (type)
     166       336916 :               || (TREE_CODE (type) == POINTER_TYPE
     167       336914 :                   && VOID_TYPE_P (TREE_TYPE (type))
     168       261628 :                   && TYPE_QUALS (TREE_TYPE (type)) == TYPE_UNQUALIFIED)));
     169              : }
     170              : 
     171              : /* EXPR may appear in an unevaluated part of an integer constant
     172              :    expression, but not in an evaluated part.  Wrap it in a
     173              :    C_MAYBE_CONST_EXPR, or mark it with TREE_OVERFLOW if it is just an
     174              :    INTEGER_CST and we cannot create a C_MAYBE_CONST_EXPR.  */
     175              : 
     176              : static tree
     177        62368 : note_integer_operands (tree expr)
     178              : {
     179        62368 :   tree ret;
     180        62368 :   if (TREE_CODE (expr) == INTEGER_CST && in_late_binary_op)
     181              :     {
     182           22 :       ret = copy_node (expr);
     183           22 :       TREE_OVERFLOW (ret) = 1;
     184              :     }
     185              :   else
     186              :     {
     187        62346 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL_TREE, expr);
     188        62346 :       C_MAYBE_CONST_EXPR_INT_OPERANDS (ret) = 1;
     189              :     }
     190        62368 :   return ret;
     191              : }
     192              : 
     193              : /* Having checked whether EXPR may appear in an unevaluated part of an
     194              :    integer constant expression and found that it may, remove any
     195              :    C_MAYBE_CONST_EXPR noting this fact and return the resulting
     196              :    expression.  */
     197              : 
     198              : static inline tree
     199     33800457 : remove_c_maybe_const_expr (tree expr)
     200              : {
     201     33800457 :   if (TREE_CODE (expr) == C_MAYBE_CONST_EXPR)
     202        61517 :     return C_MAYBE_CONST_EXPR_EXPR (expr);
     203              :   else
     204              :     return expr;
     205              : }
     206              : 
     207              : /* This is a cache to hold if two types are seen.  */
     208              : 
     209              : struct tagged_tu_seen_cache {
     210              :   const struct tagged_tu_seen_cache * next;
     211              :   const_tree t1;
     212              :   const_tree t2;
     213              : };
     214              : 
     215              : /* Do `exp = require_complete_type (loc, exp);' to make sure exp
     216              :    does not have an incomplete type.  (That includes void types.)
     217              :    LOC is the location of the use.  */
     218              : 
     219              : tree
     220    774292184 : require_complete_type (location_t loc, tree value)
     221              : {
     222    774292184 :   tree type = TREE_TYPE (value);
     223              : 
     224    774292184 :   if (error_operand_p (value))
     225         9030 :     return error_mark_node;
     226              : 
     227              :   /* First, detect a valid value with a complete type.  */
     228    774283154 :   if (COMPLETE_TYPE_P (type))
     229              :     return value;
     230              : 
     231          164 :   c_incomplete_type_error (loc, value, type);
     232          164 :   return error_mark_node;
     233              : }
     234              : 
     235              : /* Print an error message for invalid use of an incomplete type.
     236              :    VALUE is the expression that was used (or 0 if that isn't known)
     237              :    and TYPE is the type that was invalid.  LOC is the location for
     238              :    the error.  */
     239              : 
     240              : void
     241          232 : c_incomplete_type_error (location_t loc, const_tree value, const_tree type)
     242              : {
     243              :   /* Avoid duplicate error message.  */
     244          232 :   if (TREE_CODE (type) == ERROR_MARK)
     245              :     return;
     246              : 
     247          232 :   if (value != NULL_TREE && (VAR_P (value) || TREE_CODE (value) == PARM_DECL))
     248           98 :     error_at (loc, "%qD has an incomplete type %qT", value, type);
     249              :   else
     250              :     {
     251          134 :     retry:
     252              :       /* We must print an error message.  Be clever about what it says.  */
     253              : 
     254          134 :       switch (TREE_CODE (type))
     255              :         {
     256           90 :         case RECORD_TYPE:
     257           90 :         case UNION_TYPE:
     258           90 :         case ENUMERAL_TYPE:
     259           90 :           break;
     260              : 
     261           38 :         case VOID_TYPE:
     262           38 :           error_at (loc, "invalid use of void expression");
     263           38 :           return;
     264              : 
     265            6 :         case ARRAY_TYPE:
     266            6 :           if (TYPE_DOMAIN (type))
     267              :             {
     268            3 :               if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL)
     269              :                 {
     270            3 :                   error_at (loc, "invalid use of flexible array member");
     271            3 :                   return;
     272              :                 }
     273            0 :               type = TREE_TYPE (type);
     274            0 :               goto retry;
     275              :             }
     276            3 :           error_at (loc, "invalid use of array with unspecified bounds");
     277            3 :           return;
     278              : 
     279            0 :         default:
     280            0 :           gcc_unreachable ();
     281              :         }
     282              : 
     283           90 :       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
     284           88 :         error_at (loc, "invalid use of undefined type %qT", type);
     285              :       else
     286              :         /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
     287            2 :         error_at (loc, "invalid use of incomplete typedef %qT", type);
     288              :     }
     289              : }
     290              : 
     291              : /* Given a type, apply default promotions wrt unnamed function
     292              :    arguments and return the new type.  */
     293              : 
     294              : tree
     295    125147652 : c_type_promotes_to (tree type)
     296              : {
     297    125147652 :   tree ret = NULL_TREE;
     298              : 
     299    125147652 :   if (TYPE_MAIN_VARIANT (type) == float_type_node)
     300      1617453 :     ret = double_type_node;
     301    123530199 :   else if (c_promoting_integer_type_p (type))
     302              :     {
     303              :       /* Preserve unsignedness if not really getting any wider.  */
     304     18664379 :       if (TYPE_UNSIGNED (type)
     305     18664379 :           && (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
     306            0 :         ret = unsigned_type_node;
     307              :       else
     308     18664379 :         ret = integer_type_node;
     309              :     }
     310              : 
     311     20281832 :   if (ret != NULL_TREE)
     312     20281832 :     return (TYPE_ATOMIC (type)
     313     20281832 :             ? c_build_qualified_type (ret, TYPE_QUAL_ATOMIC)
     314              :             : ret);
     315              : 
     316              :   return type;
     317              : }
     318              : 
     319              : /* Return true if between two named address spaces, whether there is a superset
     320              :    named address space that encompasses both address spaces.  If there is a
     321              :    superset, return which address space is the superset.  */
     322              : 
     323              : static bool
     324      7610760 : addr_space_superset (addr_space_t as1, addr_space_t as2, addr_space_t *common)
     325              : {
     326      7610760 :   if (as1 == as2)
     327              :     {
     328      7610760 :       *common = as1;
     329      7610760 :       return true;
     330              :     }
     331            0 :   else if (targetm.addr_space.subset_p (as1, as2))
     332              :     {
     333            0 :       *common = as2;
     334            0 :       return true;
     335              :     }
     336            0 :   else if (targetm.addr_space.subset_p (as2, as1))
     337              :     {
     338            0 :       *common = as1;
     339            0 :       return true;
     340              :     }
     341              :   else
     342              :     return false;
     343              : }
     344              : 
     345              : /* Return a variant of TYPE which has all the type qualifiers of LIKE
     346              :    as well as those of TYPE.  */
     347              : 
     348              : static tree
     349      2846041 : qualify_type (tree type, tree like)
     350              : {
     351      2846041 :   addr_space_t as_type = TYPE_ADDR_SPACE (type);
     352      2846041 :   addr_space_t as_like = TYPE_ADDR_SPACE (like);
     353      2846041 :   addr_space_t as_common;
     354              : 
     355              :   /* If the two named address spaces are different, determine the common
     356              :      superset address space.  If there isn't one, raise an error.  */
     357      2846041 :   if (!addr_space_superset (as_type, as_like, &as_common))
     358              :     {
     359            0 :       as_common = as_type;
     360            0 :       error ("%qT and %qT are in disjoint named address spaces",
     361              :              type, like);
     362              :     }
     363              : 
     364      5692082 :   return c_build_qualified_type (type,
     365      2846041 :                                  TYPE_QUALS_NO_ADDR_SPACE (type)
     366      2846041 :                                  | TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (like)
     367      2846041 :                                  | ENCODE_QUAL_ADDR_SPACE (as_common));
     368              : }
     369              : 
     370              : 
     371              : /* Check consistency of type TYPE.  For derived types, we test that
     372              :    C_TYPE_VARIABLE_SIZE and C_TYPE_VARIABLY_MODIFIED are consistent with
     373              :    the requirements of the base type.  We also check that arrays with a
     374              :    non-constant length are marked with C_TYPE_VARIABLE_SIZE. If any
     375              :    inconsistency is detected false is returned and true otherwise.  */
     376              : 
     377              : static bool
     378    141310696 : c_verify_type (tree type)
     379              : {
     380    141310696 :   switch (TREE_CODE (type))
     381              :     {
     382     67308468 :     case POINTER_TYPE:
     383     67308468 :     case FUNCTION_TYPE:
     384     67308468 :     case ARRAY_TYPE:
     385              :       /* Pointer, array, functions are variably modified if and only if the
     386              :          target, element, return type is variably modified.  */
     387     67308468 :       if (!TYPE_STRUCTURAL_EQUALITY_P (type)
     388     67308468 :           && (C_TYPE_VARIABLY_MODIFIED (type)
     389     66924167 :               != C_TYPE_VARIABLY_MODIFIED (TREE_TYPE (type))))
     390              :         return false;
     391              :       /* If the target type is structural equality, the type should also. */
     392     67308468 :       if (!TYPE_STRUCTURAL_EQUALITY_P (type)
     393     67308468 :           && TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (type)))
     394              :         return false;
     395              : 
     396    141310696 :      default:
     397    141310696 :        break;
     398              :     }
     399              : 
     400    141310696 :   switch (TREE_CODE (type))
     401              :     {
     402     66392003 :     case POINTER_TYPE:
     403     66392003 :     case FUNCTION_TYPE:
     404              :       /* Pointer and functions can not have variable size.  */
     405     66392003 :       if (C_TYPE_VARIABLE_SIZE (type))
     406            0 :         return false;
     407              :       break;
     408       916465 :     case ARRAY_TYPE:
     409              :       /* An array has variable size if and only if it has a non-constant
     410              :          dimensions or its element type has variable size.  */
     411       916465 :       if ((C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
     412       916465 :            || top_array_vla_p (type))
     413       916465 :           != 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       916465 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (type))
     418       916465 :           || C_TYPE_VARIABLE_SIZE (type))
     419              :         {
     420        27693 :           if (!C_TYPE_VARIABLE_SIZE (type))
     421              :             return false;
     422        27693 :           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    134286362 : c_set_type_bits (tree new_type, tree old_type)
     436              : {
     437    134286362 :   gcc_checking_assert (c_verify_type (old_type));
     438              : 
     439    134286362 :   if (c_type_variably_modified_p (old_type))
     440        28342 :     C_TYPE_VARIABLY_MODIFIED (new_type) = true;
     441              : 
     442    134286362 :   if (TREE_CODE (new_type) == ARRAY_TYPE && C_TYPE_VARIABLE_SIZE (old_type))
     443              :     {
     444        16808 :       C_TYPE_VARIABLY_MODIFIED (new_type) = true;
     445        16808 :       C_TYPE_VARIABLE_SIZE (new_type) = true;
     446              :     }
     447    134286362 :   return new_type;
     448              : }
     449              : 
     450              : /* Build a pointer type using the default pointer mode.  */
     451              : 
     452              : tree
     453     71669678 : c_build_pointer_type (tree to_type)
     454              : {
     455     71669678 :   addr_space_t as = to_type == error_mark_node ? ADDR_SPACE_GENERIC
     456     71669678 :                                                : TYPE_ADDR_SPACE (to_type);
     457     71669678 :   machine_mode pointer_mode;
     458              : 
     459     71669678 :   if (as != ADDR_SPACE_GENERIC || c_default_pointer_mode == VOIDmode)
     460     71669678 :     pointer_mode = targetm.addr_space.pointer_mode (as);
     461              :   else
     462              :     pointer_mode = c_default_pointer_mode;
     463              : 
     464     71669678 :   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     71917083 : c_build_pointer_type_for_mode (tree type, machine_mode mode, bool m)
     471              : {
     472     71917083 :   tree ret = build_pointer_type_for_mode (type, mode, m);
     473     71917083 :   return c_set_type_bits (ret, type);
     474              : }
     475              : 
     476              : /* Build a function type.  */
     477              : 
     478              : tree
     479     53787386 : c_build_function_type (tree type, tree args, bool no)
     480              : {
     481     53787386 :   tree ret = build_function_type (type, args, no);
     482     53787386 :   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      1158228 : c_build_array_type (tree type, tree domain)
     491              : {
     492      1158228 :   int type_quals = TYPE_QUALS (type);
     493              : 
     494              :   /* Identify typeless storage as introduced in C2Y
     495              :      and supported also in earlier language modes.  */
     496      1720756 :   bool typeless = (char_type_p (type) && !(type_quals & TYPE_QUAL_ATOMIC))
     497      1158228 :                   || (AGGREGATE_TYPE_P (type) && TYPE_TYPELESS_STORAGE (type));
     498              : 
     499      1158228 :   tree ret = build_array_type (type, domain, typeless);
     500              : 
     501      1158228 :   if (top_array_vla_p (ret))
     502              :     {
     503        24268 :       C_TYPE_VARIABLE_SIZE (ret) = 1;
     504        24268 :       C_TYPE_VARIABLY_MODIFIED (ret) = 1;
     505              :     }
     506              : 
     507      1158228 :   return c_set_type_bits (ret, type);
     508              : }
     509              : 
     510              : 
     511              : /* Build an array type of unspecified size.  */
     512              : tree
     513          151 : c_build_array_type_unspecified (tree type)
     514              : {
     515          151 :   tree upper = build2 (COMPOUND_EXPR, TREE_TYPE (size_zero_node),
     516              :                        integer_zero_node, size_zero_node);
     517          151 :   return c_build_array_type (type, build_index_type (upper));
     518              : }
     519              : 
     520              : 
     521              : tree
     522      7423665 : c_build_type_attribute_qual_variant (tree type, tree attrs, int quals)
     523              : {
     524      7423665 :   tree ret = build_type_attribute_qual_variant (type, attrs, quals);
     525      7423665 :   return c_set_type_bits (ret, type);
     526              : }
     527              : 
     528              : tree
     529      7235004 : c_build_type_attribute_variant (tree type, tree attrs)
     530              : {
     531      7235004 :   return c_build_type_attribute_qual_variant (type, attrs, TYPE_QUALS (type));
     532              : }
     533              : 
     534              : /* Reconstruct a complex derived type.  This is used to re-construct types
     535              :    with the vector attribute.  It is called via a langhook.  */
     536              : 
     537              : tree
     538       839771 : c_reconstruct_complex_type (tree type, tree bottom)
     539              : {
     540       839771 :   tree inner, outer;
     541              : 
     542       839771 :   if (TREE_CODE (type) == POINTER_TYPE)
     543              :     {
     544       174333 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     545       174333 :       outer = c_build_pointer_type_for_mode (inner, TYPE_MODE (type),
     546       174333 :                                              TYPE_REF_CAN_ALIAS_ALL (type));
     547              :     }
     548              :   else if (TREE_CODE (type) == ARRAY_TYPE)
     549              :     {
     550         7366 :       bool rso = TYPE_REVERSE_STORAGE_ORDER (type);
     551         7366 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     552         7366 :       outer = c_build_array_type (inner, TYPE_DOMAIN (type));
     553         7366 :       if (rso)
     554              :         {
     555            1 :           outer = build_distinct_type_copy (outer);
     556            1 :           TYPE_REVERSE_STORAGE_ORDER (outer) = 1;
     557              :         }
     558              : 
     559         7366 :       gcc_checking_assert (C_TYPE_VARIABLE_SIZE (type)
     560              :                            == C_TYPE_VARIABLE_SIZE (outer));
     561              :     }
     562              :   else if (TREE_CODE (type) == FUNCTION_TYPE)
     563              :     {
     564          586 :       inner = c_reconstruct_complex_type (TREE_TYPE (type), bottom);
     565          586 :       outer = c_build_function_type (inner, TYPE_ARG_TYPES (type),
     566          586 :                                      TYPE_NO_NAMED_ARGS_STDARG_P (type));
     567              :     }
     568              :   else if (TREE_CODE (type) == REFERENCE_TYPE
     569              :            || TREE_CODE (type) == OFFSET_TYPE)
     570            0 :     gcc_unreachable ();
     571              :   else
     572              :     return bottom;
     573              : 
     574       182285 :   return c_build_type_attribute_qual_variant (outer, TYPE_ATTRIBUTES (type),
     575       364570 :                                               TYPE_QUALS (type));
     576              : }
     577              : 
     578              : 
     579              : /* Helper function for c_canonical_type.  Check whether FIELD
     580              :    contains a pointer to a structure or union with tag,
     581              :    possibly nested in other type derivations, and return the
     582              :    type of this nested structure or union.  */
     583              : static tree
     584      3432306 : ptr_to_tagged_member (tree field)
     585              : {
     586      3432306 :   gcc_assert (FIELD_DECL == TREE_CODE (field));
     587      3432306 :   tree type = TREE_TYPE (field);
     588      3432306 :   bool ptr_seen = false;
     589      3432306 :   while (TREE_CODE (type) == ARRAY_TYPE
     590              :          || TREE_CODE (type) == FUNCTION_TYPE
     591      4703569 :          || TREE_CODE (type) == POINTER_TYPE)
     592              :     {
     593      1271263 :       if (TREE_CODE (type) == POINTER_TYPE)
     594       696926 :         ptr_seen = true;
     595      1271263 :       type = TREE_TYPE (type);
     596              :     }
     597              : 
     598      3432306 :   if (ptr_seen
     599       676824 :       && RECORD_OR_UNION_TYPE_P (type)
     600      3679850 :       && NULL_TREE != c_type_tag (type))
     601              :     return type;
     602              : 
     603              :   return NULL_TREE;
     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 and
     611              :    change the nested type to an incomplete type.  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       885693 : c_type_canonical (tree type)
     618              : {
     619       885693 :   gcc_assert (RECORD_OR_UNION_TYPE_P (type));
     620              : 
     621       885693 :   bool needs_mod = false;
     622      3625488 :   for (tree x = TYPE_FIELDS (type); x; x = DECL_CHAIN (x))
     623              :     {
     624      2821167 :       if (!ptr_to_tagged_member (x))
     625      2739795 :         continue;
     626              :       needs_mod = true;
     627              :       break;
     628              :     }
     629       885693 :   if (!needs_mod)
     630              :     return type;
     631              : 
     632              :   /* Construct new version with such members replaced.  */
     633        81372 :   tree n = build_distinct_type_copy (type);
     634        81372 :   tree *fields = &TYPE_FIELDS (n);
     635       692511 :   for (tree x = TYPE_FIELDS (type); x; x = DECL_CHAIN (x))
     636              :     {
     637       611139 :       tree f = copy_node (x);
     638       611139 :       if (tree m = ptr_to_tagged_member (x))
     639              :         {
     640       162017 :           tree new_node = make_node (TREE_CODE (m));
     641       162017 :           TYPE_NAME (new_node) = TYPE_NAME (m);
     642       162017 :           SET_TYPE_STRUCTURAL_EQUALITY (new_node);
     643       162017 :           new_node = qualify_type (new_node, m);
     644       162017 :           TREE_TYPE (f) = c_reconstruct_complex_type (TREE_TYPE (x),
     645              :                                                       new_node);
     646              :         }
     647       611139 :       *fields = f;
     648       611139 :       fields = &DECL_CHAIN (f);
     649              :     }
     650        81372 :   TYPE_CANONICAL (n) = n;
     651        81372 :   return n;
     652              : }
     653              : 
     654              : 
     655              : /* If NTYPE is a type of a non-variadic function with a prototype
     656              :    and OTYPE is a type of a function without a prototype and ATTRS
     657              :    contains attribute format, diagnosess and removes it from ATTRS.
     658              :    Returns the result of build_type_attribute_variant of NTYPE and
     659              :    the (possibly) modified ATTRS.  */
     660              : 
     661              : static tree
     662        10757 : c_build_functype_attribute_variant (tree ntype, tree otype, tree attrs)
     663              : {
     664        10757 :   if (!prototype_p (otype)
     665        10745 :       && prototype_p (ntype)
     666        21472 :       && lookup_attribute ("format", attrs))
     667              :     {
     668           14 :       warning_at (input_location, OPT_Wattributes,
     669              :                   "%qs attribute can only be applied to variadic functions",
     670              :                   "format");
     671           14 :       attrs = remove_attribute ("format", attrs);
     672              :     }
     673        10757 :   return c_build_type_attribute_variant (ntype, attrs);
     674              : 
     675              : }
     676              : 
     677              : /* Given a type which could be a typedef name, make sure to return the
     678              :    original type.  See set_underlying_type. */
     679              : static const_tree
     680     62370400 : c_type_original (const_tree t)
     681              : {
     682              :   /* It may even be a typedef of a typedef...
     683              :      In the case of compiler-created builtin structs the TYPE_DECL
     684              :      may be a dummy, with no DECL_ORIGINAL_TYPE.  Don't fault.  */
     685     62370400 :   while (TYPE_NAME (t)
     686     32051903 :          && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
     687     62414512 :          && DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
     688        22054 :     t = DECL_ORIGINAL_TYPE (TYPE_NAME (t));
     689     62370400 :   return t;
     690              : }
     691              : 
     692              : /* Return the tag for a tagged type.  */
     693              : tree
     694     62370400 : c_type_tag (const_tree t)
     695              : {
     696     62370400 :   gcc_assert (RECORD_OR_UNION_TYPE_P (t) || TREE_CODE (t) == ENUMERAL_TYPE);
     697     62370400 :   const_tree orig = c_type_original (t);
     698     62370400 :   tree name = TYPE_NAME (orig);
     699     62370400 :   if (!name)
     700              :     return NULL_TREE;
     701     32029849 :   if (TREE_CODE (name) == TYPE_DECL)
     702              :     {
     703            4 :       if (!DECL_NAME (name))
     704              :         return NULL_TREE;
     705            2 :       name = DECL_NAME (name);
     706              :     }
     707     32029847 :   gcc_checking_assert (TREE_CODE (name) == IDENTIFIER_NODE);
     708              :   return name;
     709              : }
     710              : 
     711              : /* Remove qualifiers but not atomic.  For arrays remove qualifiers
     712              :    on the element type but also do not remove atomic.  */
     713              : static tree
     714     63839603 : remove_qualifiers (tree t)
     715              : {
     716     63839603 :   if (!t || t == error_mark_node)
     717              :     return t;
     718     63839578 :   return TYPE_ATOMIC (strip_array_types (t))
     719     63839578 :          ? c_build_qualified_type (TYPE_MAIN_VARIANT (t), TYPE_QUAL_ATOMIC)
     720     63824003 :          : TYPE_MAIN_VARIANT (t);
     721              : }
     722              : 
     723              : 
     724              : /* Helper function for composite_type_internal.  Find a compatible type
     725              :    in a (transparent) union U compatible to T.  If found, return the
     726              :    type of the corresponding member.  Otherwise, return the union type U.  */
     727              : static tree
     728      8438280 : transparent_union_replacement (tree u, tree t)
     729              : {
     730      8438275 :   if (u == error_mark_node || t == error_mark_node
     731      8438270 :       || TREE_CODE (u) != UNION_TYPE
     732           64 :       || !(TYPE_TRANSPARENT_AGGR (u) || TYPE_NAME (u) == NULL_TREE)
     733      8438344 :       || comptypes (u, t))
     734      8438216 :     return u;
     735              : 
     736           80 :   for (tree memb = TYPE_FIELDS (u); memb; memb = DECL_CHAIN (memb))
     737              :     {
     738           80 :       tree m = remove_qualifiers (TREE_TYPE (memb));
     739           80 :       if (comptypes (m, t))
     740              :         {
     741           64 :           pedwarn (input_location, OPT_Wpedantic,
     742              :                     "function types not truly compatible in ISO C");
     743           64 :           return m;
     744              :         }
     745              :     }
     746              : 
     747              :   return u;
     748              : }
     749              : 
     750              : 
     751              : 
     752              : /* Return the composite type of two compatible types.
     753              : 
     754              :    We assume that comptypes has already been done and returned
     755              :    nonzero; if that isn't so, this may crash.  In particular, we
     756              :    assume that qualifiers match.  */
     757              : 
     758              : struct composite_cache {
     759              :   tree t1;
     760              :   tree t2;
     761              :   tree composite;
     762              :   struct composite_cache* next;
     763              : };
     764              : 
     765              : tree
     766     13360184 : composite_type_internal (tree t1, tree t2, tree cond,
     767              :                          struct composite_cache* cache)
     768              : {
     769     13360184 :   enum tree_code code1;
     770     13360184 :   enum tree_code code2;
     771     13360184 :   tree attributes;
     772              : 
     773              :   /* Save time if the two types are the same.  */
     774              : 
     775     13360184 :   if (t1 == t2) return t1;
     776              : 
     777              :   /* If one type is nonsense, use the other.  */
     778      2718896 :   if (t1 == error_mark_node)
     779              :     return t2;
     780      2718892 :   if (t2 == error_mark_node)
     781              :     return t1;
     782              : 
     783      2718890 :   code1 = TREE_CODE (t1);
     784      2718890 :   code2 = TREE_CODE (t2);
     785              : 
     786              :   /* Merge the attributes.  */
     787      2718890 :   attributes = targetm.merge_type_attributes (t1, t2);
     788              : 
     789              :   /* If one is an enumerated type and the other is the compatible
     790              :      integer type, the composite type might be either of the two
     791              :      (DR#013 question 3).  For consistency, use the enumerated type as
     792              :      the composite type.  */
     793              : 
     794      2718890 :   if (code1 == ENUMERAL_TYPE
     795          195 :       && (code2 == INTEGER_TYPE
     796          195 :           || code2 == BOOLEAN_TYPE))
     797              :     return t1;
     798      2718695 :   if (code2 == ENUMERAL_TYPE
     799           69 :       && (code1 == INTEGER_TYPE
     800           69 :           || code1 == BOOLEAN_TYPE))
     801              :     return t2;
     802              : 
     803      2718626 :   gcc_assert (code1 == code2);
     804              : 
     805      2718626 :   switch (code1)
     806              :     {
     807         6376 :     case POINTER_TYPE:
     808              :       /* For two pointers, do this recursively on the target type.  */
     809         6376 :       {
     810         6376 :         gcc_checking_assert (TYPE_QUALS (t1) == TYPE_QUALS (t2));
     811         6376 :         tree target = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
     812              :                                                cond, cache);
     813         6376 :         tree n = c_build_pointer_type_for_mode (target, TYPE_MODE (t1), false);
     814        12752 :         return c_build_type_attribute_qual_variant (n, attributes,
     815         6376 :                                                     TYPE_QUALS (t2));
     816              :       }
     817              : 
     818        10996 :     case ARRAY_TYPE:
     819        10996 :       {
     820        10996 :         tree d1 = TYPE_DOMAIN (t1);
     821        10996 :         tree d2 = TYPE_DOMAIN (t2);
     822              : 
     823              :         /* We should not have any type quals on arrays at all.  */
     824        10996 :         gcc_assert (!TYPE_QUALS_NO_ADDR_SPACE (t1)
     825              :                     && !TYPE_QUALS_NO_ADDR_SPACE (t2));
     826              : 
     827        10996 :         bool t1_complete = COMPLETE_TYPE_P (t1);
     828        10996 :         bool t2_complete = COMPLETE_TYPE_P (t2);
     829              : 
     830        10996 :         bool d1_zero = d1 == NULL_TREE || !TYPE_MAX_VALUE (d1);
     831        10996 :         bool d2_zero = d2 == NULL_TREE || !TYPE_MAX_VALUE (d2);
     832              : 
     833        10996 :         bool d1_variable = top_array_vla_p (t1);
     834        10996 :         bool d2_variable = top_array_vla_p (t2);
     835              : 
     836        10996 :         bool use1 = d1 && (d2_variable || d2_zero || !d1_variable);
     837        10996 :         bool use2 = d2 && (d1_variable || d1_zero || !d2_variable);
     838              : 
     839              :         /* If the first is an unspecified size pick the other one.  */
     840         9014 :         if (d2_variable && c_type_unspecified_p (t1))
     841              :           {
     842           29 :             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        11225 :                          && d2_variable && !c_type_unspecified_p (t2);
     851              : 
     852        10996 :         tree td;
     853        10996 :         tree elt = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
     854              :                                             cond, cache);
     855              : 
     856        10996 :         if (!use0)
     857              :           {
     858              :             /* Save space: see if the result is identical to one of the args.  */
     859        10879 :             if (elt == TREE_TYPE (t1) && use1)
     860        10088 :               return c_build_type_attribute_variant (t1, attributes);
     861          791 :             if (elt == TREE_TYPE (t2) && use2)
     862          673 :               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      2659420 :     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      2659420 :       {
    1016      2659420 :         tree valtype = composite_type_internal (TREE_TYPE (t1), TREE_TYPE (t2),
    1017              :                                                 cond, cache);
    1018      2659420 :         tree p1 = TYPE_ARG_TYPES (t1);
    1019      2659420 :         tree p2 = TYPE_ARG_TYPES (t2);
    1020              : 
    1021              :         /* Save space: see if the result is identical to one of the args.  */
    1022      2659420 :         if (valtype == TREE_TYPE (t1) && !TYPE_ARG_TYPES (t2))
    1023        10767 :           return c_build_functype_attribute_variant (t1, t2, attributes);
    1024      2649180 :         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      2648663 :         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      2648654 :         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      2648653 :         tree newargs = NULL_TREE;
    1046      2648653 :         tree *endp = &newargs;
    1047              : 
    1048      6867793 :         for (; p1; p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2))
    1049              :           {
    1050      6699285 :             if (p1 == void_list_node)
    1051              :               {
    1052      2480145 :                 *endp = void_list_node;
    1053      2480145 :                 break;
    1054              :               }
    1055      4219140 :             tree mv1 = remove_qualifiers (TREE_VALUE (p1));
    1056      4219140 :             tree mv2 = remove_qualifiers (TREE_VALUE (p2));
    1057              : 
    1058      4219140 :             gcc_assert (mv1);
    1059      4219140 :             gcc_assert (mv2);
    1060              : 
    1061      4219140 :             mv1 = transparent_union_replacement (mv1, mv2);
    1062      4219140 :             mv2 = transparent_union_replacement (mv2, mv1);
    1063              : 
    1064      4219140 :             *endp = tree_cons (NULL_TREE,
    1065              :                                composite_type_internal (mv1, mv2, cond, cache),
    1066              :                                NULL_TREE);
    1067              : 
    1068      4219140 :             endp = &TREE_CHAIN (*endp);
    1069              :           }
    1070              : 
    1071      2648653 :         t1 = c_build_function_type (valtype, newargs);
    1072      2648653 :         t1 = qualify_type (t1, t2);
    1073              :       }
    1074              :       /* FALLTHRU */
    1075              : 
    1076      2690234 :     default:
    1077      2690234 :       return c_build_type_attribute_variant (t1, attributes);
    1078              :     }
    1079              : }
    1080              : 
    1081              : tree
    1082      6464061 : composite_type_cond (tree t1, tree t2, tree cond)
    1083              : {
    1084      6464061 :   gcc_checking_assert (comptypes_check_for_composite (t1, t2));
    1085              : 
    1086      6464061 :   struct composite_cache cache = { };
    1087      6464061 :   tree n = composite_type_internal (t1, t2, cond, &cache);
    1088              : 
    1089      6464061 :   gcc_checking_assert (comptypes_check_for_composite (n, t1));
    1090      6464061 :   gcc_checking_assert (comptypes_check_for_composite (n, t2));
    1091      6464061 :   return n;
    1092              : }
    1093              : 
    1094              : 
    1095              : tree
    1096      6459590 : composite_type (tree t1, tree t2)
    1097              : {
    1098      6459590 :   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       115109 : common_pointer_type (tree t1, tree t2, tree cond)
    1109              : {
    1110       115109 :   tree attributes;
    1111       115109 :   unsigned target_quals;
    1112       115109 :   addr_space_t as1, as2, as_common;
    1113       115109 :   int quals1, quals2;
    1114              : 
    1115              :   /* Save time if the two types are the same.  */
    1116              : 
    1117       115109 :   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     13981375 : c_common_type (tree t1, tree t2)
    1174              : {
    1175     13981375 :   enum tree_code code1;
    1176     13981375 :   enum tree_code code2;
    1177              : 
    1178              :   /* If one type is nonsense, use the other.  */
    1179     13981375 :   if (t1 == error_mark_node)
    1180              :     return t2;
    1181     13981375 :   if (t2 == error_mark_node)
    1182              :     return t1;
    1183              : 
    1184     13981375 :   if (TYPE_QUALS (t1) != TYPE_UNQUALIFIED)
    1185        38004 :     t1 = TYPE_MAIN_VARIANT (t1);
    1186              : 
    1187     13981375 :   if (TYPE_QUALS (t2) != TYPE_UNQUALIFIED)
    1188        49382 :     t2 = TYPE_MAIN_VARIANT (t2);
    1189              : 
    1190     13981375 :   if (TYPE_ATTRIBUTES (t1) != NULL_TREE)
    1191              :     {
    1192       188384 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t1));
    1193       188384 :       t1 = c_build_type_attribute_variant (t1, attrs);
    1194              :     }
    1195              : 
    1196     13981375 :   if (TYPE_ATTRIBUTES (t2) != NULL_TREE)
    1197              :     {
    1198       187862 :       tree attrs = affects_type_identity_attributes (TYPE_ATTRIBUTES (t2));
    1199       187862 :       t2 = c_build_type_attribute_variant (t2, attrs);
    1200              :     }
    1201              : 
    1202              :   /* Save time if the two types are the same.  */
    1203              : 
    1204     13981375 :   if (t1 == t2) return t1;
    1205              : 
    1206      2328955 :   code1 = TREE_CODE (t1);
    1207      2328955 :   code2 = TREE_CODE (t2);
    1208              : 
    1209      2328955 :   gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE
    1210              :               || code1 == FIXED_POINT_TYPE || code1 == REAL_TYPE
    1211              :               || code1 == INTEGER_TYPE || code1 == BITINT_TYPE);
    1212      2328955 :   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      2328955 :   if ((DECIMAL_FLOAT_TYPE_P (t1) || DECIMAL_FLOAT_TYPE_P (t2))
    1220      2331378 :       && !(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      2328931 :   if (code1 == VECTOR_TYPE)
    1244              :     return t1;
    1245              : 
    1246      2328641 :   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      2328638 :   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      2239313 :   if (code1 == REAL_TYPE && code2 != REAL_TYPE)
    1275              :     return t1;
    1276              : 
    1277      2110351 :   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      2079018 :   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      2077675 :   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      2077675 :   if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
    1391              :     return t1;
    1392      1104305 :   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       739357 :   if (TYPE_MAIN_VARIANT (t1) == long_long_unsigned_type_node
    1400       739357 :       || TYPE_MAIN_VARIANT (t2) == long_long_unsigned_type_node)
    1401              :     return long_long_unsigned_type_node;
    1402              : 
    1403       650110 :   if (TYPE_MAIN_VARIANT (t1) == long_long_integer_type_node
    1404       650110 :       || 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       634792 :   if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
    1413       634792 :       || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
    1414              :     return long_unsigned_type_node;
    1415              : 
    1416       535602 :   if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
    1417       535602 :       || 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        26405 :       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       509197 :   tree mv1 = TYPE_MAIN_VARIANT (t1);
    1439       509197 :   tree mv2 = TYPE_MAIN_VARIANT (t2);
    1440              : 
    1441      2545339 :   for (int i = NUM_FLOATN_TYPES - 1; i >= 0; i--)
    1442      2036325 :     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       509014 :   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       508756 :   if (mv1 == double_type_node || mv2 == double_type_node)
    1453              :     return double_type_node;
    1454              : 
    1455       508184 :   if (mv1 == float_type_node || mv2 == float_type_node)
    1456              :     return float_type_node;
    1457              : 
    1458      2023996 :   for (int i = NUM_FLOATNX_TYPES - 1; i >= 0; i--)
    1459      1517997 :     if (mv1 == FLOATNX_TYPE_NODE (i) || mv2 == FLOATNX_TYPE_NODE (i))
    1460              :       return FLOATNX_TYPE_NODE (i);
    1461              : 
    1462       505999 :   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       505991 :   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     43040446 : comptypes_verify (tree type1, tree type2)
    1519              : {
    1520     43040446 :   if (type1 == type2 || !type1 || !type2
    1521      3512168 :       || TREE_CODE (type1) == ERROR_MARK || TREE_CODE (type2) == ERROR_MARK)
    1522              :     return true;
    1523              : 
    1524      3512167 :   gcc_checking_assert (c_verify_type (type1));
    1525      3512167 :   gcc_checking_assert (c_verify_type (type2));
    1526              : 
    1527      3512167 :   if (TYPE_CANONICAL (type1) != TYPE_CANONICAL (type2)
    1528       387591 :       && !TYPE_STRUCTURAL_EQUALITY_P (type1)
    1529      3898299 :       && !TYPE_STRUCTURAL_EQUALITY_P (type2))
    1530              :     {
    1531              :       /* FIXME: check other types. */
    1532       385821 :       if (RECORD_OR_UNION_TYPE_P (type1)
    1533       385821 :           || TREE_CODE (type1) == ENUMERAL_TYPE
    1534       385821 :           || 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     19392183 : comptypes_check_for_composite (tree t1, tree t2)
    1567              : {
    1568     19392183 :   struct comptypes_data data = { };
    1569     19392183 :   data.ignore_promoting_args = FUNCTION_TYPE == TREE_CODE (t1);
    1570     19392183 :   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     56549193 : comptypes (tree type1, tree type2)
    1587              : {
    1588     56549193 :   struct comptypes_data data = { };
    1589     56549193 :   bool ret = comptypes_internal (type1, type2, &data);
    1590              : 
    1591     56549193 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1592              : 
    1593     56549193 :   return ret;
    1594              : }
    1595              : 
    1596              : 
    1597              : /* Like comptypes, but it returns non-zero only for identical
    1598              :    types.  */
    1599              : 
    1600              : bool
    1601        46253 : comptypes_same_p (tree type1, tree type2)
    1602              : {
    1603        46253 :   struct comptypes_data data = { };
    1604        46253 :   bool ret = comptypes_internal (type1, type2, &data);
    1605              : 
    1606        46253 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1607              : 
    1608        46253 :   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      5111173 : comptypes_check_enum_int (tree type1, tree type2, bool *enum_and_int_p)
    1620              : {
    1621      5111173 :   struct comptypes_data data = { };
    1622      5111173 :   bool ret = comptypes_internal (type1, type2, &data);
    1623      5111173 :   *enum_and_int_p = data.enum_and_int_p;
    1624              : 
    1625      5111173 :   gcc_checking_assert (!ret || comptypes_verify (type1, type2));
    1626              : 
    1627      5111173 :   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     14650028 : comptypes_equiv_p (tree type1, tree type2)
    1665              : {
    1666     14650028 :   struct comptypes_data data = { };
    1667     14650028 :   data.equiv = true;
    1668     14650028 :   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     14650028 :   gcc_checking_assert (ret || !comptypes (type1, type2));
    1673              : 
    1674     14650028 :   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    134319207 : comptypes_internal (const_tree type1, const_tree type2,
    1694              :                     struct comptypes_data *data)
    1695              : {
    1696    134603412 :   const_tree t1 = type1;
    1697    134603412 :   const_tree t2 = type2;
    1698              : 
    1699              :   /* Suppress errors caused by previously reported errors.  */
    1700              : 
    1701    134603412 :   if (t1 == t2 || !t1 || !t2
    1702     45367745 :       || TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
    1703              :     return true;
    1704              : 
    1705              :   /* Qualifiers must match. C99 6.7.3p9 */
    1706              : 
    1707     45367742 :   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     45327528 :   if (TREE_CODE (t1) == ENUMERAL_TYPE
    1715         1020 :       && COMPLETE_TYPE_P (t1)
    1716     45328504 :       && TREE_CODE (t2) != ENUMERAL_TYPE)
    1717              :     {
    1718          860 :       t1 = ENUM_UNDERLYING_TYPE (t1);
    1719          860 :       if (TREE_CODE (t2) != VOID_TYPE)
    1720              :         {
    1721          856 :           data->enum_and_int_p = true;
    1722          856 :           data->different_types_p = true;
    1723              :         }
    1724              :     }
    1725     45326668 :   else if (TREE_CODE (t2) == ENUMERAL_TYPE
    1726         4724 :            && COMPLETE_TYPE_P (t2)
    1727     45331386 :            && TREE_CODE (t1) != ENUMERAL_TYPE)
    1728              :     {
    1729         4602 :       t2 = ENUM_UNDERLYING_TYPE (t2);
    1730         4602 :       if (TREE_CODE (t1) != VOID_TYPE)
    1731              :         {
    1732         3703 :           data->enum_and_int_p = true;
    1733         3703 :           data->different_types_p = true;
    1734              :         }
    1735              :     }
    1736              : 
    1737     45327528 :   if (t1 == t2)
    1738              :     return true;
    1739              : 
    1740              :   /* Different classes of types can't be compatible.  */
    1741              : 
    1742     45326152 :   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     37328263 :   if (TREE_CODE (t1) != ARRAY_TYPE
    1750     37328263 :       && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
    1751              :     return true;
    1752              : 
    1753     36990456 :   int attrval;
    1754              : 
    1755              :   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
    1756     36990456 :   if (!(attrval = comp_type_attributes (t1, t2)))
    1757              :     return false;
    1758              : 
    1759     36990079 :   if (2 == attrval)
    1760          336 :     data->warning_needed = true;
    1761              : 
    1762     36990079 :   switch (TREE_CODE (t1))
    1763              :     {
    1764      3361833 :     case INTEGER_TYPE:
    1765      3361833 :     case FIXED_POINT_TYPE:
    1766      3361833 :     case REAL_TYPE:
    1767      3361833 :     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      3361833 :       return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
    1783              : 
    1784       284205 :     case POINTER_TYPE:
    1785              :       /* Do not remove mode information.  */
    1786       284205 :       if (TYPE_MODE (t1) != TYPE_MODE (t2))
    1787              :         return false;
    1788       284205 :       data->pointedto = true;
    1789       284205 :       return comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1790              : 
    1791      9164366 :     case FUNCTION_TYPE:
    1792      9164366 :       return function_types_compatible_p (t1, t2, data);
    1793              : 
    1794       154681 :     case ARRAY_TYPE:
    1795       154681 :       {
    1796       154681 :         tree d1 = TYPE_DOMAIN (t1);
    1797       154681 :         tree d2 = TYPE_DOMAIN (t2);
    1798              : 
    1799              :         /* Target types must match incl. qualifiers.  */
    1800       154681 :         if (!comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data))
    1801              :           return false;
    1802              : 
    1803       119760 :         if ((d1 == NULL_TREE) != (d2 == NULL_TREE))
    1804         6353 :           data->different_types_p = true;
    1805              :         /* Ignore size mismatches when forming equivalence classes.  */
    1806       119760 :         if (data->equiv)
    1807              :           return true;
    1808              :         /* Sizes must match unless one is missing or variable.  */
    1809        50404 :         if (d1 == NULL_TREE || d2 == NULL_TREE || d1 == d2)
    1810              :           return true;
    1811              : 
    1812        34127 :         bool d1_zero = !TYPE_MAX_VALUE (d1);
    1813        34127 :         bool d2_zero = !TYPE_MAX_VALUE (d2);
    1814              : 
    1815        34127 :         bool d1_variable = top_array_vla_p (t1);
    1816        34127 :         bool d2_variable = top_array_vla_p (t2);
    1817              : 
    1818        34127 :         if (d1_variable != d2_variable)
    1819          943 :           data->different_types_p = true;
    1820        34127 :         if (d1_variable || d2_variable)
    1821              :           return true;
    1822         4027 :         if (d1_zero && d2_zero)
    1823              :           return true;
    1824         4027 :         if (d1_zero || d2_zero
    1825         3931 :             || !tree_int_cst_equal (TYPE_MIN_VALUE (d1), TYPE_MIN_VALUE (d2))
    1826         7958 :             || !tree_int_cst_equal (TYPE_MAX_VALUE (d1), TYPE_MAX_VALUE (d2)))
    1827         4027 :           return false;
    1828              : 
    1829              :         return true;
    1830              :       }
    1831              : 
    1832     23487186 :     case ENUMERAL_TYPE:
    1833     23487186 :     case RECORD_TYPE:
    1834     23487186 :     case UNION_TYPE:
    1835              : 
    1836     23487186 :       if (!flag_isoc23)
    1837              :         return false;
    1838              : 
    1839     23487139 :       return tagged_types_tu_compatible_p (t1, t2, data);
    1840              : 
    1841       537003 :     case VECTOR_TYPE:
    1842      1074006 :       return known_eq (TYPE_VECTOR_SUBPARTS (t1), TYPE_VECTOR_SUBPARTS (t2))
    1843       537003 :              && comptypes_internal (TREE_TYPE (t1), TREE_TYPE (t2), data);
    1844              : 
    1845              :     default:
    1846              :       return false;
    1847              :     }
    1848              :   gcc_unreachable ();
    1849              : }
    1850              : 
    1851              : /* Return true if TTL and TTR are pointers to types that are equivalent, ignoring
    1852              :    their qualifiers, except for named address spaces.  If the pointers point to
    1853              :    different named addresses, then we must determine if one address space is a
    1854              :    subset of the other.  */
    1855              : 
    1856              : static bool
    1857      1768515 : comp_target_types (location_t location, tree ttl, tree ttr)
    1858              : {
    1859      1768515 :   tree mvl = TREE_TYPE (ttl);
    1860      1768515 :   tree mvr = TREE_TYPE (ttr);
    1861      1768515 :   addr_space_t asl = TYPE_ADDR_SPACE (mvl);
    1862      1768515 :   addr_space_t asr = TYPE_ADDR_SPACE (mvr);
    1863      1768515 :   addr_space_t as_common;
    1864              : 
    1865              :   /* Fail if pointers point to incompatible address spaces.  */
    1866      1768515 :   if (!addr_space_superset (asl, asr, &as_common))
    1867              :     return 0;
    1868              : 
    1869              :   /* Qualifiers on element types of array types that are
    1870              :      pointer targets are also removed.  */
    1871      1768515 :   struct comptypes_data data = { };
    1872      1768515 :   if (!comptypes_internal (remove_qualifiers (mvl),
    1873      1768515 :                            remove_qualifiers (mvr), &data))
    1874              :     return false;
    1875              : 
    1876              :   /* For pedantic use comptypes on arrays before removing
    1877              :      qualifiers on the element type. */
    1878      1667163 :   if (TREE_CODE (mvl) == ARRAY_TYPE
    1879         1891 :       && TREE_CODE (mvr) == ARRAY_TYPE
    1880      1669054 :       && !comptypes (mvl, mvr))
    1881          190 :     pedwarn_c11 (location, OPT_Wpedantic, "invalid use of pointers to arrays "
    1882              :                                           "with different qualifiers in ISO C "
    1883              :                                           "before C23");
    1884              : 
    1885      1667163 :   if (data.warning_needed)
    1886          126 :     pedwarn (location, OPT_Wpedantic, "types are not quite compatible");
    1887              : 
    1888      1667163 :   if (data.enum_and_int_p && warn_cxx_compat)
    1889            2 :     warning_at (location, OPT_Wc___compat,
    1890              :                 "pointer target types incompatible in C++");
    1891              : 
    1892              :   return true;
    1893              : }
    1894              : 
    1895              : /* Subroutines of `comptypes'.  */
    1896              : 
    1897              : /* Return true if two 'struct', 'union', or 'enum' types T1 and T2 are
    1898              :    compatible.  The two types are not the same (which has been
    1899              :    checked earlier in comptypes_internal).  */
    1900              : 
    1901              : static bool
    1902     23487139 : tagged_types_tu_compatible_p (const_tree t1, const_tree t2,
    1903              :                               struct comptypes_data *data)
    1904              : {
    1905     23487139 :   tree s1, s2;
    1906              : 
    1907     23487139 :   if (c_type_tag (t1) != c_type_tag (t2))
    1908              :     return false;
    1909              : 
    1910              :   /* When forming equivalence classes for TYPE_CANONICAL in C23, we treat
    1911              :      structs with the same tag as equivalent, but only when they are targets
    1912              :      of pointers inside other structs.  */
    1913     19416878 :   if (data->equiv && data->pointedto && NULL_TREE != c_type_tag (t1))
    1914              :     return true;
    1915              : 
    1916              :   /* Different types without tag are incompatible except as an anonymous
    1917              :      field or when forming equivalence classes for TYPE_CANONICAL.  */
    1918     19416816 :   if (!data->anon_field && !data->equiv && NULL_TREE == c_type_tag (t1))
    1919              :     return false;
    1920              : 
    1921     14270178 :   if (!data->anon_field && TYPE_STUB_DECL (t1) != TYPE_STUB_DECL (t2))
    1922     14269133 :     data->different_types_p = true;
    1923              : 
    1924              :   /* Incomplete types are incompatible inside a TU.  */
    1925     14270178 :   if (TYPE_SIZE (t1) == NULL || TYPE_SIZE (t2) == NULL)
    1926              :     return false;
    1927              : 
    1928     14270168 :   if (ENUMERAL_TYPE != TREE_CODE (t1)
    1929     14270168 :       && (TYPE_REVERSE_STORAGE_ORDER (t1)
    1930     14270113 :           != TYPE_REVERSE_STORAGE_ORDER (t2)))
    1931              :     return false;
    1932              : 
    1933     14270158 :   if (TYPE_USER_ALIGN (t1) != TYPE_USER_ALIGN (t2))
    1934       144415 :     data->different_types_p = true;
    1935              : 
    1936              :   /* For types already being looked at in some active
    1937              :      invocation of this function, assume compatibility.
    1938              :      The cache is built as a linked list on the stack
    1939              :      with the head of the list passed downwards.  */
    1940     14270158 :   for (const struct tagged_tu_seen_cache *t = data->cache;
    1941     14279835 :        t != NULL; t = t->next)
    1942         9972 :     if (t->t1 == t1 && t->t2 == t2)
    1943              :       return true;
    1944              : 
    1945     14269863 :   const struct tagged_tu_seen_cache entry = { data->cache, t1, t2 };
    1946              : 
    1947     14269863 :   switch (TREE_CODE (t1))
    1948              :     {
    1949           55 :     case ENUMERAL_TYPE:
    1950           55 :       {
    1951           55 :         if (!comptypes (ENUM_UNDERLYING_TYPE (t1), ENUM_UNDERLYING_TYPE (t2)))
    1952              :           return false;
    1953              : 
    1954              :         /* Speed up the case where the type values are in the same order.  */
    1955           51 :         tree tv1 = TYPE_VALUES (t1);
    1956           51 :         tree tv2 = TYPE_VALUES (t2);
    1957              : 
    1958           51 :         if (tv1 == tv2)
    1959              :           return true;
    1960              : 
    1961           97 :         for (;tv1 && tv2; tv1 = TREE_CHAIN (tv1), tv2 = TREE_CHAIN (tv2))
    1962              :           {
    1963           58 :             if (TREE_PURPOSE (tv1) != TREE_PURPOSE (tv2))
    1964              :               break;
    1965              : 
    1966           51 :             if (simple_cst_equal (DECL_INITIAL (TREE_VALUE (tv1)),
    1967           51 :                                   DECL_INITIAL (TREE_VALUE (tv2))) != 1)
    1968              :               break;
    1969              :           }
    1970              : 
    1971           51 :         if (tv1 == NULL_TREE && tv2 == NULL_TREE)
    1972              :           return true;
    1973              : 
    1974           12 :         if (tv1 == NULL_TREE || tv2 == NULL_TREE)
    1975              :           return false;
    1976              : 
    1977           12 :         if (list_length (TYPE_VALUES (t1)) != list_length (TYPE_VALUES (t2)))
    1978              :           return false;
    1979              : 
    1980           20 :         for (s1 = TYPE_VALUES (t1); s1; s1 = TREE_CHAIN (s1))
    1981              :           {
    1982           16 :             s2 = purpose_member (TREE_PURPOSE (s1), TYPE_VALUES (t2));
    1983              : 
    1984           16 :             if (s2 == NULL
    1985           29 :                 || simple_cst_equal (DECL_INITIAL (TREE_VALUE (s1)),
    1986           13 :                                      DECL_INITIAL (TREE_VALUE (s2))) != 1)
    1987            8 :               return false;
    1988              :           }
    1989              : 
    1990              :         return true;
    1991              :       }
    1992              : 
    1993     14269808 :     case UNION_TYPE:
    1994     14269808 :     case RECORD_TYPE:
    1995              : 
    1996     14269808 :         if (list_length (TYPE_FIELDS (t1)) != list_length (TYPE_FIELDS (t2)))
    1997              :           return false;
    1998              : 
    1999     12327014 :         for (s1 = TYPE_FIELDS (t1), s2 = TYPE_FIELDS (t2);
    2000     13849130 :              s1 && s2;
    2001      1522116 :              s1 = DECL_CHAIN (s1), s2 = DECL_CHAIN (s2))
    2002              :           {
    2003     13783744 :             gcc_assert (TREE_CODE (s1) == FIELD_DECL);
    2004     13783744 :             gcc_assert (TREE_CODE (s2) == FIELD_DECL);
    2005              : 
    2006     13783744 :             tree ft1 = TREE_TYPE (s1);
    2007     13783744 :             tree ft2 = TREE_TYPE (s2);
    2008              : 
    2009     13783744 :             if (DECL_NAME (s1) != DECL_NAME (s2))
    2010              :               return false;
    2011              : 
    2012     12134559 :             if (DECL_ALIGN (s1) != DECL_ALIGN (s2))
    2013              :               return false;
    2014              : 
    2015      3232850 :             if (DECL_C_BIT_FIELD (s1) != DECL_C_BIT_FIELD (s2))
    2016              :                return false;
    2017              : 
    2018      3232830 :             if (DECL_C_BIT_FIELD (s1))
    2019              :               {
    2020          496 :                 if (!tree_int_cst_equal (DECL_SIZE (s1), DECL_SIZE (s2)))
    2021              :                   return false;
    2022              : 
    2023          342 :                 ft1 = DECL_BIT_FIELD_TYPE (s1);
    2024          342 :                 ft2 = DECL_BIT_FIELD_TYPE (s2);
    2025              :               }
    2026              : 
    2027      3232676 :             if (!ft1 || !ft2)
    2028              :               return false;
    2029              : 
    2030      3232676 :             if (TREE_CODE (ft1) == ERROR_MARK || TREE_CODE (ft2) == ERROR_MARK)
    2031              :               return false;
    2032              : 
    2033      3232675 :             data->anon_field = !DECL_NAME (s1);
    2034      3232675 :             data->pointedto = false;
    2035              : 
    2036      3232675 :             const struct tagged_tu_seen_cache *cache = data->cache;
    2037      3232675 :             data->cache = &entry;
    2038      3232675 :             bool ret = comptypes_internal (ft1, ft2, data);
    2039      3232675 :             data->cache = cache;
    2040      3232675 :             if (!ret)
    2041              :               return false;
    2042              : 
    2043      1591360 :             tree st1 = TYPE_SIZE (TREE_TYPE (s1));
    2044      1591360 :             tree st2 = TYPE_SIZE (TREE_TYPE (s2));
    2045              : 
    2046      1591360 :             if (data->equiv
    2047       997076 :                 && st1 && TREE_CODE (st1) == INTEGER_CST
    2048       996594 :                 && st2 && TREE_CODE (st2) == INTEGER_CST
    2049      2587948 :                 && !tree_int_cst_equal (st1, st2))
    2050              :              return false;
    2051              : 
    2052      1522150 :             tree counted_by1 = lookup_attribute ("counted_by",
    2053      1522150 :                                                  DECL_ATTRIBUTES (s1));
    2054      1522150 :             tree counted_by2 = lookup_attribute ("counted_by",
    2055      1522150 :                                                  DECL_ATTRIBUTES (s2));
    2056              :             /* If there is no counted_by attribute for both fields.  */
    2057      1522150 :             if (!counted_by1 && !counted_by2)
    2058      1522086 :               continue;
    2059              : 
    2060              :             /* If only one field has counted_by attribute.  */
    2061           64 :             if ((counted_by1 && !counted_by2)
    2062           64 :                 || (!counted_by1 && counted_by2))
    2063              :               return false;
    2064              : 
    2065              :             /* Now both s1 and s2 have counted_by attributes, check
    2066              :                whether they are the same.  */
    2067              : 
    2068           52 :             tree counted_by_field1
    2069           52 :               = lookup_field (t1, TREE_VALUE (TREE_VALUE (counted_by1)));
    2070           52 :             tree counted_by_field2
    2071           52 :               = lookup_field (t2, TREE_VALUE (TREE_VALUE (counted_by2)));
    2072              : 
    2073           52 :             gcc_assert (counted_by_field1 && counted_by_field2);
    2074              : 
    2075           94 :             while (TREE_CHAIN (counted_by_field1))
    2076           42 :               counted_by_field1 = TREE_CHAIN (counted_by_field1);
    2077           86 :             while (TREE_CHAIN (counted_by_field2))
    2078           34 :               counted_by_field2 = TREE_CHAIN (counted_by_field2);
    2079              : 
    2080           52 :             if (DECL_NAME (TREE_VALUE (counted_by_field1))
    2081           52 :                 != DECL_NAME (TREE_VALUE (counted_by_field2)))
    2082              :               return false;
    2083              :           }
    2084              :         return true;
    2085              : 
    2086            0 :     default:
    2087            0 :       gcc_unreachable ();
    2088              :     }
    2089              : }
    2090              : 
    2091              : /* Return true if two function types F1 and F2 are compatible.
    2092              :    If either type specifies no argument types,
    2093              :    the other must specify a fixed number of self-promoting arg types.
    2094              :    Otherwise, if one type specifies only the number of arguments,
    2095              :    the other must specify that number of self-promoting arg types.
    2096              :    Otherwise, the argument types must match.  */
    2097              : 
    2098              : static bool
    2099      9164366 : function_types_compatible_p (const_tree f1, const_tree f2,
    2100              :                              struct comptypes_data *data)
    2101              : {
    2102      9164366 :   tree ret1 = TREE_TYPE (f1);
    2103      9164366 :   tree ret2 = TREE_TYPE (f2);
    2104              : 
    2105              :   /* 'volatile' qualifiers on a function's return type used to mean
    2106              :      the function is noreturn.  */
    2107      9164366 :   if (TYPE_VOLATILE (ret1) != TYPE_VOLATILE (ret2))
    2108           29 :     pedwarn (input_location, 0, "function return types not compatible due to %<volatile%>");
    2109      9164366 :   if (TYPE_VOLATILE (ret1))
    2110           15 :     ret1 = build_qualified_type (TYPE_MAIN_VARIANT (ret1),
    2111           15 :                                  TYPE_QUALS (ret1) & ~TYPE_QUAL_VOLATILE);
    2112      9164366 :   if (TYPE_VOLATILE (ret2))
    2113           18 :     ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2),
    2114           18 :                                  TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE);
    2115              : 
    2116      9164366 :   bool ignore_pargs = data->ignore_promoting_args;
    2117      9164366 :   data->ignore_promoting_args = false;
    2118              : 
    2119      9164366 :   if (!comptypes_internal (ret1, ret2, data))
    2120              :     return false;
    2121              : 
    2122      9161771 :   data->ignore_promoting_args = ignore_pargs;
    2123              : 
    2124      9161771 :   tree args1 = TYPE_ARG_TYPES (f1);
    2125      9161771 :   tree args2 = TYPE_ARG_TYPES (f2);
    2126              : 
    2127      9161771 :   if ((args1 == NULL_TREE) != (args2 == NULL_TREE))
    2128        45217 :     data->different_types_p = true;
    2129              : 
    2130              :   /* An unspecified parmlist matches any specified parmlist
    2131              :      whose argument types don't need default promotions.  */
    2132              : 
    2133      9161771 :   if (args1 == NULL_TREE)
    2134              :     {
    2135        23753 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    2136              :         return false;
    2137        23750 :       if (!(data->ignore_promoting_args || self_promoting_args_p (args2)))
    2138              :         return false;
    2139        23278 :       data->ignore_promoting_args = false;
    2140              :       /* If one of these types comes from a non-prototype fn definition,
    2141              :          compare that with the other type's arglist.
    2142              :          If they don't match, ask for a warning (but no error).  */
    2143        23278 :       if (TYPE_ACTUAL_ARG_TYPES (f1)
    2144        23278 :           && !type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1), data))
    2145           12 :          data->warning_needed = true;
    2146        23278 :       return true;
    2147              :     }
    2148      9138018 :   if (args2 == NULL_TREE)
    2149              :     {
    2150        21546 :       if (TYPE_NO_NAMED_ARGS_STDARG_P (f1) != TYPE_NO_NAMED_ARGS_STDARG_P (f2))
    2151              :         return false;
    2152        21544 :       if (!(data->ignore_promoting_args || self_promoting_args_p (args1)))
    2153              :         return false;
    2154        21483 :       data->ignore_promoting_args = false;
    2155        21483 :       if (TYPE_ACTUAL_ARG_TYPES (f2)
    2156        21483 :           && !type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2), data))
    2157            1 :         data->warning_needed = true;
    2158        21483 :       return true;
    2159              :     }
    2160              : 
    2161              :   /* Both types have argument lists: compare them and propagate results.  */
    2162      9116472 :   return type_lists_compatible_p (args1, args2, data);
    2163              : }
    2164              : 
    2165              : /* Check two lists of types for compatibility, returning false for
    2166              :    incompatible, true for compatible.  */
    2167              : 
    2168              : static bool
    2169      9116548 : type_lists_compatible_p (const_tree args1, const_tree args2,
    2170              :                          struct comptypes_data *data)
    2171              : {
    2172     56642930 :   while (1)
    2173              :     {
    2174     32879739 :       if (args1 == NULL_TREE && args2 == NULL_TREE)
    2175              :         return true;
    2176              :       /* If one list is shorter than the other,
    2177              :          they fail to match.  */
    2178     23908591 :       if (args1 == NULL_TREE || args2 == NULL_TREE)
    2179              :         return false;
    2180     23908584 :       tree a1 = TREE_VALUE (args1);
    2181     23908584 :       tree a2 = TREE_VALUE (args2);
    2182     23908584 :       tree mv1 = remove_qualifiers (a1);
    2183     23908584 :       tree mv2 = remove_qualifiers (a2);
    2184              : 
    2185     23908584 :       gcc_assert (mv2);
    2186     23908584 :       gcc_assert (mv2);
    2187              : 
    2188              :       /* If one of the lists has an error marker, ignore this arg.  */
    2189     23908584 :       if (TREE_CODE (a1) == ERROR_MARK
    2190     23908580 :                || TREE_CODE (a2) == ERROR_MARK)
    2191              :         ;
    2192     23908564 :       else if (!comptypes_internal (mv1, mv2, data))
    2193              :         {
    2194       145624 :           data->different_types_p = true;
    2195              :           /* Allow  wait (union {union wait *u; int *i} *)
    2196              :              and  wait (union wait *)  to be compatible.  */
    2197       145624 :           if (TREE_CODE (a1) == UNION_TYPE
    2198          130 :               && (TYPE_NAME (a1) == NULL_TREE
    2199           98 :                   || TYPE_TRANSPARENT_AGGR (a1))
    2200          130 :               && TREE_CODE (TYPE_SIZE (a1)) == INTEGER_CST
    2201       145754 :               && tree_int_cst_equal (TYPE_SIZE (a1),
    2202          130 :                                      TYPE_SIZE (a2)))
    2203              :             {
    2204          130 :               tree memb;
    2205          130 :               for (memb = TYPE_FIELDS (a1);
    2206          166 :                    memb; memb = DECL_CHAIN (memb))
    2207              :                 {
    2208          164 :                   tree mv3 = remove_qualifiers (TREE_TYPE (memb));
    2209          164 :                   if (comptypes_internal (mv3, mv2, data))
    2210              :                     break;
    2211              :                 }
    2212              :               if (memb == NULL_TREE)
    2213              :                 return false;
    2214              :             }
    2215       145494 :           else if (TREE_CODE (a2) == UNION_TYPE
    2216          105 :                    && (TYPE_NAME (a2) == NULL_TREE
    2217           74 :                        || TYPE_TRANSPARENT_AGGR (a2))
    2218          105 :                    && TREE_CODE (TYPE_SIZE (a2)) == INTEGER_CST
    2219       145599 :                    && tree_int_cst_equal (TYPE_SIZE (a2),
    2220          105 :                                           TYPE_SIZE (a1)))
    2221              :             {
    2222          105 :               tree memb;
    2223          105 :               for (memb = TYPE_FIELDS (a2);
    2224          133 :                    memb; memb = DECL_CHAIN (memb))
    2225              :                 {
    2226          131 :                   tree mv3 = remove_qualifiers (TREE_TYPE (memb));
    2227          131 :                   if (comptypes_internal (mv3, mv1, data))
    2228              :                     break;
    2229              :                 }
    2230              :               if (memb == NULL_TREE)
    2231              :                 return false;
    2232              :             }
    2233              :           else
    2234       145389 :             return false;
    2235              :         }
    2236              : 
    2237     23763191 :       args1 = TREE_CHAIN (args1);
    2238     23763191 :       args2 = TREE_CHAIN (args2);
    2239     23763191 :     }
    2240              : }
    2241              : 
    2242              : /* Compute the size to increment a pointer by.  When a function type or void
    2243              :    type or incomplete type is passed, size_one_node is returned.
    2244              :    This function does not emit any diagnostics; the caller is responsible
    2245              :    for that.  */
    2246              : 
    2247              : static tree
    2248       234129 : c_size_in_bytes (const_tree type)
    2249              : {
    2250       234129 :   enum tree_code code = TREE_CODE (type);
    2251              : 
    2252       234129 :   if (code == FUNCTION_TYPE || code == VOID_TYPE || code == ERROR_MARK
    2253       234129 :       || !COMPLETE_TYPE_P (type))
    2254          191 :     return size_one_node;
    2255              : 
    2256              :   /* Convert in case a char is more than one unit.  */
    2257       233938 :   return size_binop_loc (input_location, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
    2258       233938 :                          size_int (TYPE_PRECISION (char_type_node)
    2259              :                                    / BITS_PER_UNIT));
    2260              : }
    2261              : 
    2262              : /* Return either DECL or its known constant value (if it has one).  */
    2263              : 
    2264              : tree
    2265     14346073 : decl_constant_value_1 (tree decl, bool in_init)
    2266              : {
    2267     14346073 :   if (/* Note that DECL_INITIAL isn't valid for a PARM_DECL.  */
    2268     14346073 :       TREE_CODE (decl) != PARM_DECL
    2269     14346073 :       && !TREE_THIS_VOLATILE (decl)
    2270     14001720 :       && TREE_READONLY (decl)
    2271        36761 :       && DECL_INITIAL (decl) != NULL_TREE
    2272        35765 :       && !error_operand_p (DECL_INITIAL (decl))
    2273              :       /* This is invalid if initial value is not constant.
    2274              :          If it has either a function call, a memory reference,
    2275              :          or a variable, then re-evaluating it could give different results.  */
    2276        35756 :       && TREE_CONSTANT (DECL_INITIAL (decl))
    2277              :       /* Check for cases where this is sub-optimal, even though valid.  */
    2278     14368767 :       && (in_init || TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR))
    2279        17578 :     return DECL_INITIAL (decl);
    2280              :   return decl;
    2281              : }
    2282              : 
    2283              : /* Return either DECL or its known constant value (if it has one).
    2284              :    Like the above, but always return decl outside of functions.  */
    2285              : 
    2286              : tree
    2287     14345825 : decl_constant_value (tree decl)
    2288              : {
    2289              :   /* Don't change a variable array bound or initial value to a constant
    2290              :      in a place where a variable is invalid.  */
    2291     14345825 :   return current_function_decl ? decl_constant_value_1 (decl, false) : decl;
    2292              : }
    2293              : 
    2294              : /* Convert the array expression EXP to a pointer.  */
    2295              : static tree
    2296       826951 : array_to_pointer_conversion (location_t loc, tree exp)
    2297              : {
    2298       826951 :   tree orig_exp = exp;
    2299       826951 :   tree type = TREE_TYPE (exp);
    2300       826951 :   tree adr;
    2301       826951 :   tree restype = TREE_TYPE (type);
    2302       826951 :   tree ptrtype;
    2303              : 
    2304       826951 :   gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
    2305              : 
    2306       826951 :   STRIP_TYPE_NOPS (exp);
    2307              : 
    2308       826951 :   copy_warning (exp, orig_exp);
    2309              : 
    2310       826951 :   ptrtype = c_build_pointer_type (restype);
    2311              : 
    2312       826951 :   if (INDIRECT_REF_P (exp))
    2313         2906 :     return convert (ptrtype, TREE_OPERAND (exp, 0));
    2314              : 
    2315              :   /* In C++ array compound literals are temporary objects unless they are
    2316              :      const or appear in namespace scope, so they are destroyed too soon
    2317              :      to use them for much of anything  (c++/53220).  */
    2318       824045 :   if (warn_cxx_compat && TREE_CODE (exp) == COMPOUND_LITERAL_EXPR)
    2319              :     {
    2320           48 :       tree decl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    2321           48 :       if (!TREE_READONLY (decl) && !TREE_STATIC (decl))
    2322           46 :         warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
    2323              :                     "converting an array compound literal to a pointer "
    2324              :                     "leads to a dangling pointer in C++");
    2325              :     }
    2326              : 
    2327       824045 :   adr = build_unary_op (loc, ADDR_EXPR, exp, true);
    2328       824045 :   return convert (ptrtype, adr);
    2329              : }
    2330              : 
    2331              : /* Convert the function expression EXP to a pointer.  */
    2332              : static tree
    2333     50618839 : function_to_pointer_conversion (location_t loc, tree exp)
    2334              : {
    2335     50618839 :   tree orig_exp = exp;
    2336              : 
    2337     50618839 :   gcc_assert (TREE_CODE (TREE_TYPE (exp)) == FUNCTION_TYPE);
    2338              : 
    2339     50618839 :   STRIP_TYPE_NOPS (exp);
    2340              : 
    2341     50618839 :   copy_warning (exp, orig_exp);
    2342              : 
    2343     50618839 :   tree exp2 = build_unary_op (loc, ADDR_EXPR, exp, false);
    2344              : 
    2345              :   /* If the function is defined and known to not require a non-local
    2346              :      context, make sure no trampoline is generated.  */
    2347     50618839 :   if (TREE_CODE (exp) == FUNCTION_DECL
    2348     50618839 :       && DECL_INITIAL (exp) && !C_FUNC_NONLOCAL_CONTEXT (exp))
    2349     16070969 :    TREE_NO_TRAMPOLINE (exp2) = 1;
    2350              : 
    2351     50618839 :   return exp2;
    2352              : }
    2353              : 
    2354              : /* Mark EXP as read, not just set, for set but not used -Wunused
    2355              :    warning purposes.  */
    2356              : 
    2357              : void
    2358    490488649 : mark_exp_read (tree exp)
    2359              : {
    2360    616904349 :   switch (TREE_CODE (exp))
    2361              :     {
    2362    203445199 :     case VAR_DECL:
    2363    203445199 :     case PARM_DECL:
    2364    203445199 :       DECL_READ_P (exp) = 1;
    2365    203445199 :       break;
    2366     19723723 :     CASE_CONVERT:
    2367     19723723 :       if (VOID_TYPE_P (TREE_TYPE (exp)))
    2368         3805 :         switch (TREE_CODE (TREE_OPERAND (exp, 0)))
    2369              :           {
    2370              :           case PREINCREMENT_EXPR:
    2371              :           case PREDECREMENT_EXPR:
    2372              :           case POSTINCREMENT_EXPR:
    2373              :           case POSTDECREMENT_EXPR:
    2374              :             return;
    2375              :           default:
    2376              :             break;
    2377              :           }
    2378              :       /* FALLTHRU */
    2379    123670235 :     case ARRAY_REF:
    2380    123670235 :     case COMPONENT_REF:
    2381    123670235 :     case MODIFY_EXPR:
    2382    123670235 :     case REALPART_EXPR:
    2383    123670235 :     case IMAGPART_EXPR:
    2384    123670235 :     case ADDR_EXPR:
    2385    123670235 :     case VIEW_CONVERT_EXPR:
    2386    123670235 :     case PREINCREMENT_EXPR:
    2387    123670235 :     case PREDECREMENT_EXPR:
    2388    123670235 :     case POSTINCREMENT_EXPR:
    2389    123670235 :     case POSTDECREMENT_EXPR:
    2390    123670235 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2391    123670235 :       break;
    2392       235983 :     case COMPOUND_EXPR:
    2393              :       /* Pattern match what build_atomic_assign produces with modifycode
    2394              :          NOP_EXPR.  */
    2395       235983 :       if (VAR_P (TREE_OPERAND (exp, 1))
    2396        27227 :           && DECL_ARTIFICIAL (TREE_OPERAND (exp, 1))
    2397       263126 :           && TREE_CODE (TREE_OPERAND (exp, 0)) == COMPOUND_EXPR)
    2398              :         {
    2399         2210 :           tree t1 = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    2400         2210 :           tree t2 = TREE_OPERAND (TREE_OPERAND (exp, 0), 1);
    2401         2210 :           if (TREE_CODE (t1) == TARGET_EXPR
    2402         2202 :               && TARGET_EXPR_SLOT (t1) == TREE_OPERAND (exp, 1)
    2403         4410 :               && TREE_CODE (t2) == CALL_EXPR)
    2404              :             {
    2405         2200 :               tree fndecl = get_callee_fndecl (t2);
    2406         2200 :               tree arg = NULL_TREE;
    2407         2200 :               if (fndecl
    2408         2200 :                   && TREE_CODE (fndecl) == FUNCTION_DECL
    2409         2200 :                   && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    2410         4400 :                   && call_expr_nargs (t2) >= 2)
    2411         2200 :                 switch (DECL_FUNCTION_CODE (fndecl))
    2412              :                   {
    2413          130 :                   case BUILT_IN_ATOMIC_STORE:
    2414          130 :                     arg = CALL_EXPR_ARG (t2, 1);
    2415          130 :                     break;
    2416         2070 :                   case BUILT_IN_ATOMIC_STORE_1:
    2417         2070 :                   case BUILT_IN_ATOMIC_STORE_2:
    2418         2070 :                   case BUILT_IN_ATOMIC_STORE_4:
    2419         2070 :                   case BUILT_IN_ATOMIC_STORE_8:
    2420         2070 :                   case BUILT_IN_ATOMIC_STORE_16:
    2421         2070 :                     arg = CALL_EXPR_ARG (t2, 0);
    2422         2070 :                     break;
    2423              :                   default:
    2424              :                     break;
    2425              :                   }
    2426         2200 :               if (arg)
    2427              :                 {
    2428         2200 :                   STRIP_NOPS (arg);
    2429         2200 :                   if (TREE_CODE (arg) == ADDR_EXPR
    2430         2200 :                       && DECL_P (TREE_OPERAND (arg, 0))
    2431         4400 :                       && TYPE_ATOMIC (TREE_TYPE (TREE_OPERAND (arg, 0))))
    2432         2200 :                     mark_exp_read (TREE_OPERAND (arg, 0));
    2433              :                 }
    2434              :             }
    2435              :         }
    2436              :       /* FALLTHRU */
    2437      2744922 :     case C_MAYBE_CONST_EXPR:
    2438      2744922 :       mark_exp_read (TREE_OPERAND (exp, 1));
    2439      2744922 :       break;
    2440          578 :     case OMP_ARRAY_SECTION:
    2441          578 :       mark_exp_read (TREE_OPERAND (exp, 0));
    2442          578 :       if (TREE_OPERAND (exp, 1))
    2443          384 :         mark_exp_read (TREE_OPERAND (exp, 1));
    2444          578 :       if (TREE_OPERAND (exp, 2))
    2445          543 :         mark_exp_read (TREE_OPERAND (exp, 2));
    2446              :       break;
    2447              :     default:
    2448              :       break;
    2449              :     }
    2450              : }
    2451              : 
    2452              : /* Perform the default conversion of arrays and functions to pointers.
    2453              :    Return the result of converting EXP.  For any other expression, just
    2454              :    return EXP.
    2455              : 
    2456              :    LOC is the location of the expression.  */
    2457              : 
    2458              : struct c_expr
    2459    362292321 : default_function_array_conversion (location_t loc, struct c_expr exp)
    2460              : {
    2461    362292321 :   tree orig_exp = exp.value;
    2462    362292321 :   tree type = TREE_TYPE (exp.value);
    2463    362292321 :   enum tree_code code = TREE_CODE (type);
    2464              : 
    2465    362292321 :   switch (code)
    2466              :     {
    2467              :     case ARRAY_TYPE:
    2468              :       {
    2469              :         bool not_lvalue = false;
    2470              :         bool lvalue_array_p;
    2471              : 
    2472       780045 :         while ((TREE_CODE (exp.value) == NON_LVALUE_EXPR
    2473       780045 :                 || CONVERT_EXPR_P (exp.value))
    2474       780045 :                && TREE_TYPE (TREE_OPERAND (exp.value, 0)) == type)
    2475              :           {
    2476            0 :             if (TREE_CODE (exp.value) == NON_LVALUE_EXPR)
    2477            0 :               not_lvalue = true;
    2478            0 :             exp.value = TREE_OPERAND (exp.value, 0);
    2479              :           }
    2480              : 
    2481       780045 :         copy_warning (exp.value, orig_exp);
    2482              : 
    2483       780045 :         lvalue_array_p = !not_lvalue && lvalue_p (exp.value);
    2484       780045 :         if (!flag_isoc99 && !lvalue_array_p)
    2485              :           {
    2486              :             /* Before C99, non-lvalue arrays do not decay to pointers.
    2487              :                Normally, using such an array would be invalid; but it can
    2488              :                be used correctly inside sizeof or as a statement expression.
    2489              :                Thus, do not give an error here; an error will result later.  */
    2490          109 :             return exp;
    2491              :           }
    2492              : 
    2493       779936 :         exp.value = array_to_pointer_conversion (loc, exp.value);
    2494              :       }
    2495       779936 :       break;
    2496       762309 :     case FUNCTION_TYPE:
    2497       762309 :       exp.value = function_to_pointer_conversion (loc, exp.value);
    2498       762309 :       break;
    2499              :     default:
    2500              :       break;
    2501              :     }
    2502              : 
    2503    362292212 :   return exp;
    2504              : }
    2505              : 
    2506              : struct c_expr
    2507        12659 : default_function_array_read_conversion (location_t loc, struct c_expr exp)
    2508              : {
    2509        12659 :   mark_exp_read (exp.value);
    2510              :   /* We only generate a call to .ACCESS_WITH_SIZE when it is a read.  */
    2511        12659 :   if (TREE_CODE (exp.value) == COMPONENT_REF
    2512        12659 :       && handle_counted_by_p (exp.value))
    2513            4 :     exp.value = handle_counted_by_for_component_ref (loc, exp.value);
    2514        12659 :   return default_function_array_conversion (loc, exp);
    2515              : }
    2516              : 
    2517              : /* Return whether EXPR should be treated as an atomic lvalue for the
    2518              :    purposes of load and store handling.  */
    2519              : 
    2520              : static bool
    2521    363387494 : really_atomic_lvalue (tree expr)
    2522              : {
    2523    363387494 :   if (error_operand_p (expr))
    2524              :     return false;
    2525    363379854 :   if (!TYPE_ATOMIC (TREE_TYPE (expr)))
    2526              :     return false;
    2527        57393 :   if (!COMPLETE_TYPE_P (TREE_TYPE (expr)))
    2528              :     return false;
    2529        57390 :   if (!lvalue_p (expr))
    2530              :     return false;
    2531              : 
    2532              :   /* Ignore _Atomic on register variables, since their addresses can't
    2533              :      be taken so (a) atomicity is irrelevant and (b) the normal atomic
    2534              :      sequences wouldn't work.  Ignore _Atomic on structures containing
    2535              :      bit-fields, since accessing elements of atomic structures or
    2536              :      unions is undefined behavior (C11 6.5.2.3#5), but it's unclear if
    2537              :      it's undefined at translation time or execution time, and the
    2538              :      normal atomic sequences again wouldn't work.  */
    2539        57532 :   while (handled_component_p (expr))
    2540              :     {
    2541          144 :       if (TREE_CODE (expr) == COMPONENT_REF
    2542          144 :           && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
    2543              :         return false;
    2544          144 :       expr = TREE_OPERAND (expr, 0);
    2545              :     }
    2546        57388 :   if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
    2547            1 :     expr = COMPOUND_LITERAL_EXPR_DECL (expr);
    2548       112572 :   if (DECL_P (expr) && C_DECL_REGISTER (expr))
    2549              :     return false;
    2550              :   return true;
    2551              : }
    2552              : 
    2553              : /* If EXPR is a named constant (C23) derived from a constexpr variable
    2554              :    - that is, a reference to such a variable, or a member extracted by
    2555              :    a sequence of structure and union (but not array) member accesses
    2556              :    (where union member accesses must access the same member as
    2557              :    initialized) - then return the corresponding initializer;
    2558              :    otherwise, return NULL_TREE.  */
    2559              : 
    2560              : static tree
    2561    360196892 : maybe_get_constexpr_init (tree expr)
    2562              : {
    2563    360196892 :   tree decl = NULL_TREE;
    2564    360196892 :   if (TREE_CODE (expr) == VAR_DECL)
    2565              :     decl = expr;
    2566    348474942 :   else if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
    2567       822278 :     decl = COMPOUND_LITERAL_EXPR_DECL (expr);
    2568       822278 :   if (decl
    2569     12544228 :       && C_DECL_DECLARED_CONSTEXPR (decl)
    2570          370 :       && DECL_INITIAL (decl) != NULL_TREE
    2571       822648 :       && !error_operand_p (DECL_INITIAL (decl)))
    2572          370 :     return DECL_INITIAL (decl);
    2573    360196522 :   if (TREE_CODE (expr) != COMPONENT_REF)
    2574              :     return NULL_TREE;
    2575       875636 :   tree inner = maybe_get_constexpr_init (TREE_OPERAND (expr, 0));
    2576       875636 :   if (inner == NULL_TREE)
    2577              :     return NULL_TREE;
    2578          126 :   while ((CONVERT_EXPR_P (inner) || TREE_CODE (inner) == NON_LVALUE_EXPR)
    2579           47 :          && !error_operand_p (inner)
    2580          220 :          && (TYPE_MAIN_VARIANT (TREE_TYPE (inner))
    2581           47 :              == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (inner, 0)))))
    2582           47 :     inner = TREE_OPERAND (inner, 0);
    2583          126 :   if (TREE_CODE (inner) != CONSTRUCTOR)
    2584              :     return NULL_TREE;
    2585          126 :   tree field = TREE_OPERAND (expr, 1);
    2586          126 :   unsigned HOST_WIDE_INT cidx;
    2587          126 :   tree cfield, cvalue;
    2588          126 :   bool have_other_init = false;
    2589          266 :   FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (inner), cidx, cfield, cvalue)
    2590              :     {
    2591          250 :       if (cfield == field)
    2592              :         return cvalue;
    2593          140 :       have_other_init = true;
    2594              :     }
    2595           16 :   if (TREE_CODE (TREE_TYPE (inner)) == UNION_TYPE
    2596           16 :       && (have_other_init || field != TYPE_FIELDS (TREE_TYPE (inner))))
    2597              :     return NULL_TREE;
    2598              :   /* Return a default initializer.  */
    2599           13 :   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (expr)))
    2600            5 :     return build_constructor (TREE_TYPE (expr), NULL);
    2601            8 :   return build_zero_cst (TREE_TYPE (expr));
    2602              : }
    2603              : 
    2604              : /* Helper function for convert_lvalue_to_rvalue called via
    2605              :    walk_tree_without_duplicates.  Find DATA inside of the expression.  */
    2606              : 
    2607              : static tree
    2608       230295 : c_find_var_r (tree *tp, int *walk_subtrees, void *data)
    2609              : {
    2610       230295 :   if (TYPE_P (*tp))
    2611            0 :     *walk_subtrees = 0;
    2612       230295 :   else if (*tp == (tree) data)
    2613              :     return *tp;
    2614              :   return NULL_TREE;
    2615              : }
    2616              : 
    2617              : /* Convert expression EXP (location LOC) from lvalue to rvalue,
    2618              :    including converting functions and arrays to pointers if CONVERT_P.
    2619              :    If READ_P, also mark the expression as having been read.  If
    2620              :    FOR_INIT, constexpr expressions of structure and union type should
    2621              :    be replaced by the corresponding CONSTRUCTOR; otherwise, only
    2622              :    constexpr scalars (including elements of structures and unions) are
    2623              :    replaced by their initializers.  */
    2624              : 
    2625              : struct c_expr
    2626    359509027 : convert_lvalue_to_rvalue (location_t loc, struct c_expr exp,
    2627              :                           bool convert_p, bool read_p, bool for_init)
    2628              : {
    2629    359509027 :   bool force_non_npc = false;
    2630    359509027 :   if (read_p)
    2631    315450791 :     mark_exp_read (exp.value);
    2632              :   /* We only generate a call to .ACCESS_WITH_SIZE when it is a read.  */
    2633    315450791 :   if (read_p && TREE_CODE (exp.value) == COMPONENT_REF
    2634       783909 :       && handle_counted_by_p (exp.value))
    2635       783880 :     exp.value = handle_counted_by_for_component_ref (loc, exp.value);
    2636              : 
    2637    359509027 :   if (convert_p)
    2638    359495768 :     exp = default_function_array_conversion (loc, exp);
    2639    359509027 :   if (!VOID_TYPE_P (TREE_TYPE (exp.value))
    2640    359509027 :       || (flag_isoc2y
    2641         1574 :           && TYPE_QUALS (TREE_TYPE (exp.value)) != TYPE_UNQUALIFIED))
    2642    357024551 :     exp.value = require_complete_type (loc, exp.value);
    2643    359509027 :   if (for_init || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (exp.value)))
    2644              :     {
    2645    359321256 :       tree init = maybe_get_constexpr_init (exp.value);
    2646    359321256 :       if (init != NULL_TREE)
    2647              :         {
    2648              :           /* A named constant of pointer type or type nullptr_t is not
    2649              :              a null pointer constant even if the initializer is
    2650              :              one.  */
    2651          367 :           if (TREE_CODE (init) == INTEGER_CST
    2652          232 :               && !INTEGRAL_TYPE_P (TREE_TYPE (init))
    2653          393 :               && integer_zerop (init))
    2654              :             force_non_npc = true;
    2655              :           exp.value = init;
    2656              :         }
    2657              :     }
    2658    359509027 :   if (really_atomic_lvalue (exp.value))
    2659              :     {
    2660        26938 :       vec<tree, va_gc> *params;
    2661        26938 :       tree nonatomic_type, tmp, tmp_addr, fndecl, func_call;
    2662        26938 :       tree expr_type = TREE_TYPE (exp.value);
    2663        26938 :       tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, false);
    2664        26938 :       tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    2665              : 
    2666        26938 :       gcc_assert (TYPE_ATOMIC (expr_type));
    2667              : 
    2668              :       /* Expansion of a generic atomic load may require an addition
    2669              :          element, so allocate enough to prevent a resize.  */
    2670        26938 :       vec_alloc (params, 4);
    2671              : 
    2672              :       /* Remove the qualifiers for the rest of the expressions and
    2673              :          create the VAL temp variable to hold the RHS.  */
    2674        26938 :       nonatomic_type = build_qualified_type (expr_type, TYPE_UNQUALIFIED);
    2675        26938 :       tmp = create_tmp_var_raw (nonatomic_type);
    2676        26938 :       tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false);
    2677        26938 :       TREE_ADDRESSABLE (tmp) = 1;
    2678              :       /* Do not disable warnings for TMP even though it's artificial.
    2679              :          -Winvalid-memory-model depends on it.  */
    2680              : 
    2681              :       /* Issue __atomic_load (&expr, &tmp, SEQ_CST);  */
    2682        26938 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    2683        26938 :       params->quick_push (expr_addr);
    2684        26938 :       params->quick_push (tmp_addr);
    2685        26938 :       params->quick_push (seq_cst);
    2686        26938 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    2687              : 
    2688              :       /* EXPR is always read.  */
    2689        26938 :       mark_exp_read (exp.value);
    2690              : 
    2691              :       /* Optimize the common case where c_build_function_call_vec
    2692              :          immediately folds __atomic_load (&expr, &tmp, SEQ_CST); into
    2693              :          tmp = __atomic_load_<N> (&expr, SEQ_CST);
    2694              :          In that case tmp is not addressable and can be initialized
    2695              :          fully by the rhs of the MODIFY_EXPR.  */
    2696        26938 :       tree tem = func_call;
    2697        26938 :       if (CONVERT_EXPR_P (tem) && VOID_TYPE_P (TREE_TYPE (tem)))
    2698              :         {
    2699        25683 :           tem = TREE_OPERAND (tem, 0);
    2700        25683 :           if (TREE_CODE (tem) == MODIFY_EXPR
    2701        25683 :               && TREE_OPERAND (tem, 0) == tmp
    2702        51366 :               && !walk_tree_without_duplicates (&TREE_OPERAND (tem, 1),
    2703              :                                                 c_find_var_r, tmp))
    2704              :             {
    2705        25683 :               TREE_ADDRESSABLE (tmp) = 0;
    2706        25683 :               func_call = TREE_OPERAND (tem, 1);
    2707              :             }
    2708              :         }
    2709              : 
    2710              :       /* Return tmp which contains the value loaded.  */
    2711        26938 :       exp.value = build4 (TARGET_EXPR, nonatomic_type, tmp, func_call,
    2712              :                           NULL_TREE, NULL_TREE);
    2713              :     }
    2714    359495768 :   if (convert_p && !error_operand_p (exp.value)
    2715    718997199 :       && (TREE_CODE (TREE_TYPE (exp.value)) != ARRAY_TYPE))
    2716    359488063 :     exp.value = convert (build_qualified_type (TREE_TYPE (exp.value), TYPE_UNQUALIFIED), exp.value);
    2717    359509027 :   if (force_non_npc)
    2718           24 :     exp.value = build1 (NOP_EXPR, TREE_TYPE (exp.value), exp.value);
    2719              : 
    2720    359509027 :   {
    2721    359509027 :     tree false_value, true_value;
    2722    359495768 :     if (convert_p && !error_operand_p (exp.value)
    2723    718997199 :         && c_hardbool_type_attr (TREE_TYPE (exp.value),
    2724              :                                  &false_value, &true_value))
    2725              :       {
    2726         9721 :         tree t = save_expr (exp.value);
    2727              : 
    2728         9721 :         mark_exp_read (exp.value);
    2729              : 
    2730         9721 :         tree trapfn = builtin_decl_explicit (BUILT_IN_TRAP);
    2731         9721 :         tree expr = build_call_expr_loc (loc, trapfn, 0);
    2732         9721 :         expr = build_compound_expr (loc, expr, boolean_true_node);
    2733         9721 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2734              :                                 fold_build2_loc (loc, NE_EXPR,
    2735              :                                                  boolean_type_node,
    2736              :                                                  t, true_value),
    2737              :                                 expr, boolean_true_node);
    2738         9721 :         expr = fold_build3_loc (loc, COND_EXPR, boolean_type_node,
    2739              :                                 fold_build2_loc (loc, NE_EXPR,
    2740              :                                                  boolean_type_node,
    2741              :                                                  t, false_value),
    2742              :                                 expr, boolean_false_node);
    2743              : 
    2744         9721 :         exp.value = expr;
    2745              :       }
    2746              :   }
    2747              : 
    2748    359509027 :   return exp;
    2749              : }
    2750              : 
    2751              : /* Wrapper for the overload above, same arguments but for tree rather than
    2752              :    c_expr.  This is important for hardbools to decay to bools.  */
    2753              : 
    2754              : static inline tree
    2755       576159 : convert_lvalue_to_rvalue (location_t loc, tree val,
    2756              :                           bool convert_p, bool read_p, bool for_init = false)
    2757              : {
    2758       576159 :   struct c_expr expr;
    2759       576159 :   memset (&expr, 0, sizeof (expr));
    2760       576159 :   expr.value = val;
    2761       576159 :   expr = convert_lvalue_to_rvalue (loc, expr, convert_p, read_p, for_init);
    2762       576159 :   return expr.value;
    2763              : }
    2764              : 
    2765              : /* EXP is an expression of integer type.  Apply the integer promotions
    2766              :    to it and return the promoted value.  */
    2767              : 
    2768              : tree
    2769     77409545 : perform_integral_promotions (tree exp)
    2770              : {
    2771     77409545 :   tree type = TREE_TYPE (exp);
    2772     77409545 :   enum tree_code code = TREE_CODE (type);
    2773              : 
    2774     77409545 :   gcc_assert (INTEGRAL_TYPE_P (type));
    2775              : 
    2776              :   /* Convert enums to the result of applying the integer promotions to
    2777              :      their underlying type.  */
    2778     77409545 :   if (code == ENUMERAL_TYPE)
    2779              :     {
    2780       650663 :       type = ENUM_UNDERLYING_TYPE (type);
    2781       650663 :       if (c_promoting_integer_type_p (type))
    2782              :         {
    2783           94 :           if (TYPE_UNSIGNED (type)
    2784           94 :               && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2785            0 :             type = unsigned_type_node;
    2786              :           else
    2787           94 :             type = integer_type_node;
    2788              :         }
    2789              : 
    2790       650663 :       return convert (type, exp);
    2791              :     }
    2792              : 
    2793              :   /* ??? This should no longer be needed now bit-fields have their
    2794              :      proper types.  */
    2795     76758882 :   if (TREE_CODE (exp) == COMPONENT_REF
    2796     76758882 :       && DECL_C_BIT_FIELD (TREE_OPERAND (exp, 1)))
    2797              :     {
    2798        62213 :       if (BITINT_TYPE_P (DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1))))
    2799              :         {
    2800          484 :           tree btype = DECL_BIT_FIELD_TYPE (TREE_OPERAND (exp, 1));
    2801          484 :           if (TREE_CODE (btype) == BITINT_TYPE)
    2802          454 :             return convert (btype, exp);
    2803              :           else
    2804           30 :             return convert (ENUM_UNDERLYING_TYPE (btype), exp);
    2805              :         }
    2806              :       /* If it's thinner than an int, promote it like a
    2807              :          c_promoting_integer_type_p, otherwise leave it alone.  */
    2808        61729 :       if (compare_tree_int (DECL_SIZE (TREE_OPERAND (exp, 1)),
    2809        61729 :                             TYPE_PRECISION (integer_type_node)) < 0)
    2810        53467 :         return convert (integer_type_node, exp);
    2811              :     }
    2812              : 
    2813     76704931 :   if (c_promoting_integer_type_p (type))
    2814              :     {
    2815              :       /* Preserve unsignedness if not really getting any wider.  */
    2816       645313 :       if (TYPE_UNSIGNED (type)
    2817       645313 :           && TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
    2818            0 :         return convert (unsigned_type_node, exp);
    2819              : 
    2820       645313 :       return convert (integer_type_node, exp);
    2821              :     }
    2822              : 
    2823              :   return exp;
    2824              : }
    2825              : 
    2826              : 
    2827              : /* Perform default promotions for C data used in expressions.
    2828              :    Enumeral types or short or char are converted to int.
    2829              :    In addition, manifest constants symbols are replaced by their values.  */
    2830              : 
    2831              : tree
    2832     86948459 : default_conversion (tree exp)
    2833              : {
    2834     86948459 :   tree orig_exp;
    2835     86948459 :   tree type = TREE_TYPE (exp);
    2836     86948459 :   enum tree_code code = TREE_CODE (type);
    2837     86948459 :   tree promoted_type;
    2838              : 
    2839     86948459 :   mark_exp_read (exp);
    2840              :   /* We only generate a call to .ACCESS_WITH_SIZE when it is a read.  */
    2841     86948459 :   if (TREE_CODE (exp) == COMPONENT_REF
    2842     86948459 :       && handle_counted_by_p (exp))
    2843       600971 :     exp = handle_counted_by_for_component_ref (EXPR_LOCATION (exp), exp);
    2844              : 
    2845              :   /* Functions and arrays have been converted during parsing.  */
    2846     86948459 :   gcc_assert (code != FUNCTION_TYPE);
    2847     86948459 :   if (code == ARRAY_TYPE)
    2848              :     return exp;
    2849              : 
    2850              :   /* Constants can be used directly unless they're not loadable.  */
    2851     86948300 :   if (TREE_CODE (exp) == CONST_DECL)
    2852            0 :     exp = DECL_INITIAL (exp);
    2853              : 
    2854              :   /* Strip no-op conversions.  */
    2855     86948300 :   orig_exp = exp;
    2856     87320132 :   STRIP_TYPE_NOPS (exp);
    2857              : 
    2858     86948300 :   copy_warning (exp, orig_exp);
    2859              : 
    2860     86948300 :   if (code == VOID_TYPE)
    2861              :     {
    2862            2 :       error_at (EXPR_LOC_OR_LOC (exp, input_location),
    2863              :                 "void value not ignored as it ought to be");
    2864            2 :       return error_mark_node;
    2865              :     }
    2866              : 
    2867     86948298 :   exp = require_complete_type (EXPR_LOC_OR_LOC (exp, input_location), exp);
    2868     86948298 :   if (exp == error_mark_node)
    2869              :     return error_mark_node;
    2870              : 
    2871     86947394 :   promoted_type = targetm.promoted_type (type);
    2872     86947394 :   if (promoted_type)
    2873            0 :     return convert (promoted_type, exp);
    2874              : 
    2875     86947394 :   if (INTEGRAL_TYPE_P (type))
    2876     76411972 :     return perform_integral_promotions (exp);
    2877              : 
    2878              :   return exp;
    2879              : }
    2880              : 
    2881              : /* Look up COMPONENT in a structure or union TYPE.
    2882              : 
    2883              :    If the component name is not found, returns NULL_TREE.  Otherwise,
    2884              :    the return value is a TREE_LIST, with each TREE_VALUE a FIELD_DECL
    2885              :    stepping down the chain to the component, which is in the last
    2886              :    TREE_VALUE of the list.  Normally the list is of length one, but if
    2887              :    the component is embedded within (nested) anonymous structures or
    2888              :    unions, the list steps down the chain to the component.  */
    2889              : 
    2890              : tree
    2891      2321665 : lookup_field (const_tree type, tree component)
    2892              : {
    2893      2321665 :   tree field;
    2894              : 
    2895              :   /* If TYPE_LANG_SPECIFIC is set, then it is a sorted array of pointers
    2896              :      to the field elements.  Use a binary search on this array to quickly
    2897              :      find the element.  Otherwise, do a linear search.  TYPE_LANG_SPECIFIC
    2898              :      will always be set for structures which have many elements.
    2899              : 
    2900              :      Duplicate field checking replaces duplicates with NULL_TREE so
    2901              :      TYPE_LANG_SPECIFIC arrays are potentially no longer sorted.  In that
    2902              :      case just iterate using DECL_CHAIN.  */
    2903              : 
    2904      2622693 :   if (TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (type)->s
    2905      2622693 :       && !seen_error ())
    2906              :     {
    2907       301007 :       int bot, top, half;
    2908       301007 :       tree *field_array = &TYPE_LANG_SPECIFIC (type)->s->elts[0];
    2909              : 
    2910       301007 :       field = TYPE_FIELDS (type);
    2911       301007 :       bot = 0;
    2912       301007 :       top = TYPE_LANG_SPECIFIC (type)->s->len;
    2913      1385178 :       while (top - bot > 1)
    2914              :         {
    2915      1355758 :           half = (top - bot + 1) >> 1;
    2916      1355758 :           field = field_array[bot+half];
    2917              : 
    2918      1355758 :           if (DECL_NAME (field) == NULL_TREE)
    2919              :             {
    2920              :               /* Step through all anon unions in linear fashion.  */
    2921            0 :               while (DECL_NAME (field_array[bot]) == NULL_TREE)
    2922              :                 {
    2923            0 :                   field = field_array[bot++];
    2924            0 :                   if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2925              :                     {
    2926            0 :                       tree anon = lookup_field (TREE_TYPE (field), component);
    2927              : 
    2928            0 :                       if (anon)
    2929            0 :                         return tree_cons (NULL_TREE, field, anon);
    2930              : 
    2931              :                       /* The Plan 9 compiler permits referring
    2932              :                          directly to an anonymous struct/union field
    2933              :                          using a typedef name.  */
    2934            0 :                       if (flag_plan9_extensions
    2935            0 :                           && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2936            0 :                           && (TREE_CODE (TYPE_NAME (TREE_TYPE (field)))
    2937              :                               == TYPE_DECL)
    2938            0 :                           && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2939              :                               == component))
    2940              :                         break;
    2941              :                     }
    2942              :                 }
    2943              : 
    2944              :               /* Entire record is only anon unions.  */
    2945            0 :               if (bot > top)
    2946              :                 return NULL_TREE;
    2947              : 
    2948              :               /* Restart the binary search, with new lower bound.  */
    2949            0 :               continue;
    2950            0 :             }
    2951              : 
    2952      1355758 :           if (DECL_NAME (field) == component)
    2953              :             break;
    2954      1084171 :           if (DECL_NAME (field) < component)
    2955              :             bot += half;
    2956              :           else
    2957       899333 :             top = bot + half;
    2958              :         }
    2959              : 
    2960       301007 :       if (DECL_NAME (field_array[bot]) == component)
    2961              :         field = field_array[bot];
    2962       271587 :       else if (DECL_NAME (field) != component)
    2963              :         return NULL_TREE;
    2964              :     }
    2965              :   else
    2966              :     {
    2967      5260113 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2968              :         {
    2969      5250820 :           if (DECL_NAME (field) == NULL_TREE
    2970      5250820 :               && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    2971              :             {
    2972        12197 :               tree anon = lookup_field (TREE_TYPE (field), component);
    2973              : 
    2974        12197 :               if (anon)
    2975         2999 :                 return tree_cons (NULL_TREE, field, anon);
    2976              : 
    2977              :               /* The Plan 9 compiler permits referring directly to an
    2978              :                  anonymous struct/union field using a typedef
    2979              :                  name.  */
    2980         9198 :               if (flag_plan9_extensions
    2981          174 :                   && TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
    2982          172 :                   && TREE_CODE (TYPE_NAME (TREE_TYPE (field))) == TYPE_DECL
    2983         9260 :                   && (DECL_NAME (TYPE_NAME (TREE_TYPE (field)))
    2984              :                       == component))
    2985              :                 break;
    2986              :             }
    2987              : 
    2988      5247817 :           if (DECL_NAME (field) == component)
    2989              :             break;
    2990              :         }
    2991              : 
    2992      2017659 :       if (field == NULL_TREE)
    2993              :         return NULL_TREE;
    2994              :     }
    2995              : 
    2996      2309373 :   return tree_cons (NULL_TREE, field, NULL_TREE);
    2997              : }
    2998              : 
    2999              : /* Recursively append candidate IDENTIFIER_NODEs to CANDIDATES.  */
    3000              : 
    3001              : static void
    3002          101 : lookup_field_fuzzy_find_candidates (tree type, tree component,
    3003              :                                     vec<tree> *candidates)
    3004              : {
    3005          101 :   tree field;
    3006          258 :   for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    3007              :     {
    3008          157 :       if (DECL_NAME (field) == NULL_TREE
    3009          157 :           && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    3010           30 :         lookup_field_fuzzy_find_candidates (TREE_TYPE (field), component,
    3011              :                                             candidates);
    3012              : 
    3013          157 :       if (DECL_NAME (field))
    3014          111 :         candidates->safe_push (DECL_NAME (field));
    3015              :     }
    3016          101 : }
    3017              : 
    3018              : /* Like "lookup_field", but find the closest matching IDENTIFIER_NODE,
    3019              :    rather than returning a TREE_LIST for an exact match.  */
    3020              : 
    3021              : static tree
    3022           71 : lookup_field_fuzzy (tree type, tree component)
    3023              : {
    3024           71 :   gcc_assert (TREE_CODE (component) == IDENTIFIER_NODE);
    3025              : 
    3026              :   /* First, gather a list of candidates.  */
    3027           71 :   auto_vec <tree> candidates;
    3028              : 
    3029           71 :   lookup_field_fuzzy_find_candidates (type, component,
    3030              :                                       &candidates);
    3031              : 
    3032           71 :   return find_closest_identifier (component, &candidates);
    3033           71 : }
    3034              : 
    3035              : /* Support function for build_component_ref's error-handling.
    3036              : 
    3037              :    Given DATUM_TYPE, and "DATUM.COMPONENT", where DATUM is *not* a
    3038              :    struct or union, should we suggest "DATUM->COMPONENT" as a hint?  */
    3039              : 
    3040              : static bool
    3041           72 : should_suggest_deref_p (tree datum_type)
    3042              : {
    3043              :   /* We don't do it for Objective-C, since Objective-C 2.0 dot-syntax
    3044              :      allows "." for ptrs; we could be handling a failed attempt
    3045              :      to access a property.  */
    3046           72 :   if (c_dialect_objc ())
    3047              :     return false;
    3048              : 
    3049              :   /* Only suggest it for pointers...  */
    3050           72 :   if (TREE_CODE (datum_type) != POINTER_TYPE)
    3051              :     return false;
    3052              : 
    3053              :   /* ...to structs/unions.  */
    3054            8 :   tree underlying_type = TREE_TYPE (datum_type);
    3055            8 :   enum tree_code code = TREE_CODE (underlying_type);
    3056            8 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    3057              :     return true;
    3058              :   else
    3059            1 :     return false;
    3060              : }
    3061              : 
    3062              : /* Give a component ref REF, decide whether we should handle its counted_by
    3063              :    attribute based on its context:
    3064              :    Do not handle counted_by when in offsetof, typeof and alignof operator.  */
    3065              : 
    3066              : static bool
    3067      2210074 : handle_counted_by_p (tree ref)
    3068              : {
    3069      2210074 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
    3070      2210074 :   tree datum = TREE_OPERAND (ref, 0);
    3071              :   /* If the component_ref is build for a offsetof, i.e., the datum
    3072              :      of the component_ref is a indirect_ref of null_pointer_node,
    3073              :      we should not generate call to .ACCESS_WITH_SIZE.  */
    3074      2210074 :   if (TREE_CODE (datum) == INDIRECT_REF
    3075      2210074 :       && TREE_OPERAND (datum, 0) == null_pointer_node)
    3076              :     return false;
    3077      2209744 :   if (in_typeof || in_alignof)
    3078         8786 :     return false;
    3079              :   return true;
    3080              : }
    3081              : 
    3082              : /* Given a component ref REF, if there is a counted_by attribute attached,
    3083              :    issue error when the element_type is a structure or union including a
    3084              :    flexible array member.  */
    3085              : 
    3086              : static void
    3087      2275560 : check_counted_by_attribute (location_t loc, tree ref)
    3088              : {
    3089      2275560 :   tree subdatum = TREE_OPERAND (ref, 1);
    3090      2275560 :   tree sub_type = TREE_TYPE (subdatum);
    3091              : 
    3092      2275560 :   if (!c_flexible_array_member_type_p (sub_type)
    3093      2275560 :       && TREE_CODE (sub_type) != POINTER_TYPE)
    3094              :     return;
    3095              : 
    3096       388029 :   tree element_type = TREE_TYPE (sub_type);
    3097              : 
    3098       388029 :   tree attr_counted_by = lookup_attribute ("counted_by",
    3099       388029 :                                            DECL_ATTRIBUTES (subdatum));
    3100       388029 :   if (attr_counted_by)
    3101              :     {
    3102              :       /* Issue error when the element_type is a structure or
    3103              :         union including a flexible array member.  */
    3104          878 :       if (RECORD_OR_UNION_TYPE_P (element_type)
    3105          878 :           && TYPE_INCLUDES_FLEXARRAY (element_type))
    3106              :         {
    3107            2 :           error_at (loc,
    3108              :                     "%<counted_by%> attribute is not allowed for a pointer to"
    3109              :                     " structure or union with flexible array member");
    3110            2 :           return;
    3111              :         }
    3112              :     }
    3113              : }
    3114              : 
    3115              : /* For a SUBDATUM field of a structure or union DATUM, generate a REF
    3116              :    to the object that represents its counted_by per the attribute
    3117              :    counted_by attached to this field if it's a flexible array member
    3118              :    or a pointer field, otherwise return NULL_TREE.
    3119              :    Set COUNTED_BY_TYPE to the TYPE of the counted_by field.
    3120              :    For example, if:
    3121              : 
    3122              :     struct P {
    3123              :       int k;
    3124              :       int x[] __attribute__ ((counted_by (k)));
    3125              :     } *p;
    3126              : 
    3127              :     for:
    3128              :     p->x
    3129              : 
    3130              :     the ref to the object that represents its element count will be:
    3131              : 
    3132              :     &(p->k)
    3133              : */
    3134              : 
    3135              : static tree
    3136       440356 : build_counted_by_ref (tree datum, tree subdatum,
    3137              :                       tree *counted_by_type)
    3138              : {
    3139       440356 :   tree sub_type = TREE_TYPE (subdatum);
    3140       440356 :   if (!c_flexible_array_member_type_p (sub_type)
    3141       440356 :       && TREE_CODE (sub_type) != POINTER_TYPE)
    3142              :     return NULL_TREE;
    3143              : 
    3144       440356 :   tree attr_counted_by = lookup_attribute ("counted_by",
    3145       440356 :                                            DECL_ATTRIBUTES (subdatum));
    3146       440356 :   if (!attr_counted_by)
    3147              :     return NULL_TREE;
    3148              : 
    3149          656 :   tree counted_by_ref = NULL_TREE;
    3150          656 :   *counted_by_type = NULL_TREE;
    3151              : 
    3152          656 :   tree type = TREE_TYPE (datum);
    3153              : 
    3154              :   /* If the type of the containing structure is an anonymous struct/union,
    3155              :      and this anonymous struct/union is not a root type, get the first
    3156              :      outer named structure/union type.  */
    3157          656 :   while (TREE_CODE (datum) == COMPONENT_REF
    3158           35 :          && c_type_tag (type) == NULL_TREE
    3159          726 :          && DECL_NAME (TREE_OPERAND (datum, 1)) == NULL_TREE)
    3160              :     {
    3161           35 :       datum = TREE_OPERAND (datum, 0);
    3162           35 :       type = TREE_TYPE (datum);
    3163              :     }
    3164              : 
    3165          656 :   tree field_id = TREE_VALUE (TREE_VALUE (attr_counted_by));
    3166          656 :   tree counted_by_field = lookup_field (type, field_id);
    3167          656 :   gcc_assert (counted_by_field);
    3168              : 
    3169         1068 :   tree counted_by_subdatum;
    3170         1068 :   do
    3171              :     {
    3172         1068 :       counted_by_subdatum = TREE_VALUE (counted_by_field);
    3173              :       /* Get the TYPE of the counted_by field.  */
    3174         1068 :       *counted_by_type = TREE_TYPE (counted_by_subdatum);
    3175              : 
    3176         1068 :       counted_by_ref
    3177         1068 :         = build3 (COMPONENT_REF, TREE_TYPE (counted_by_subdatum),
    3178              :                   datum, counted_by_subdatum, NULL_TREE);
    3179              : 
    3180         1068 :       datum = counted_by_ref;
    3181         1068 :       counted_by_field = TREE_CHAIN (counted_by_field);
    3182              :     }
    3183         1068 :   while (counted_by_field);
    3184              : 
    3185          656 :   counted_by_ref = build_fold_addr_expr (counted_by_ref);
    3186          656 :   return counted_by_ref;
    3187              : }
    3188              : 
    3189              : /* Given a COMPONENT_REF REF with the location LOC, the corresponding
    3190              :    COUNTED_BY_REF, and the COUNTED_BY_TYPE, generate the corresponding
    3191              :    call to the internal function .ACCESS_WITH_SIZE.
    3192              : 
    3193              :    A: For the Flexible Array Member, Generate an INDIRECT_REF to a call to
    3194              :    the internal function .ACCESS_WITH_SIZE.
    3195              : 
    3196              :    REF
    3197              : 
    3198              :    to:
    3199              : 
    3200              :    (*.ACCESS_WITH_SIZE (REF, COUNTED_BY_REF, (* TYPE_OF_SIZE)0,
    3201              :                         TYPE_SIZE_UNIT for element)
    3202              : 
    3203              :    NOTE: The return type of this function is the POINTER type pointing
    3204              :    to the original flexible array type.  Then the type of the INDIRECT_REF
    3205              :    is the original flexible array type.
    3206              :    The type of the first argument of this function is a POINTER type
    3207              :    to the original flexible array type.
    3208              : 
    3209              :    B: For pointers with counted_by, generate a call to the internal function
    3210              :    .ACCESS_WITH_SIZE.
    3211              : 
    3212              :     REF
    3213              : 
    3214              :     to:
    3215              : 
    3216              :     .ACCESS_WITH_SIZE (REF, COUNTED_BY_REF, (* TYPE_OF_SIZE)0,
    3217              :                        TYPE_SIZE_UNIT for element)
    3218              : 
    3219              :    NOTE: The return type of this function is the original pointer type.
    3220              :    The type of the first argument of this function is the original
    3221              :    pointer type.
    3222              : 
    3223              :    The 3rd argument of the call is a constant 0 with the pointer TYPE whose
    3224              :    pointee type is the TYPE of the object pointed by COUNTED_BY_REF.
    3225              : 
    3226              :    The 4th argument of the call is the TYPE_SIZE_UNIT of the element TYPE
    3227              :    of the array.
    3228              : 
    3229              :   */
    3230              : static tree
    3231          656 : build_access_with_size_for_counted_by (location_t loc, tree ref,
    3232              :                                        tree counted_by_ref,
    3233              :                                        tree counted_by_type)
    3234              : {
    3235          656 :   gcc_assert (c_flexible_array_member_type_p (TREE_TYPE (ref))
    3236              :               || TREE_CODE (TREE_TYPE (ref)) == POINTER_TYPE);
    3237              : 
    3238          656 :   bool is_fam = c_flexible_array_member_type_p (TREE_TYPE (ref));
    3239              : 
    3240              :   /* The result type of the call is a pointer to the flexible array type;
    3241              :      or is the original pointer type to the pointer field with counted_by.  */
    3242          656 :   tree result_type = is_fam ? c_build_pointer_type (TREE_TYPE (ref))
    3243          455 :                      : TREE_TYPE (ref);
    3244              : 
    3245          656 :   tree element_type = TREE_TYPE (TREE_TYPE (ref));
    3246          656 :   tree element_size = VOID_TYPE_P (element_type)
    3247          656 :                       ? size_one_node
    3248          656 :                       : TYPE_SIZE_UNIT (element_type);
    3249          656 :   if (element_size == NULL_TREE)
    3250              :     return ref;
    3251              : 
    3252          642 :   tree first_param = is_fam
    3253          642 :                      ? c_fully_fold (array_to_pointer_conversion (loc, ref),
    3254              :                                      false, NULL)
    3255          441 :                      : c_fully_fold (ref, false, NULL);
    3256          642 :   tree second_param
    3257          642 :     = c_fully_fold (counted_by_ref, false, NULL);
    3258          642 :   tree third_param = build_int_cst (c_build_pointer_type (counted_by_type), 0);
    3259              : 
    3260          642 :   tree call
    3261          642 :     = build_call_expr_internal_loc (loc, IFN_ACCESS_WITH_SIZE,
    3262              :                                     result_type, 4,
    3263              :                                     first_param,
    3264              :                                     second_param,
    3265              :                                     third_param,
    3266              :                                     element_size);
    3267              : 
    3268              :   /* Wrap the call with an INDIRECT_REF with the flexible array type.  */
    3269          642 :   if (is_fam)
    3270          201 :     call = build1 (INDIRECT_REF, TREE_TYPE (ref), call);
    3271          642 :   SET_EXPR_LOCATION (call, loc);
    3272          642 :   return call;
    3273              : }
    3274              : 
    3275              : /* For the COMPONENT_REF ref, check whether it has a counted_by attribute,
    3276              :    if so, wrap this COMPONENT_REF with the corresponding CALL to the
    3277              :    function .ACCESS_WITH_SIZE.
    3278              :    Otherwise, return the ref itself.  */
    3279              : 
    3280              : tree
    3281      2201038 : handle_counted_by_for_component_ref (location_t loc, tree ref)
    3282              : {
    3283      2201038 :   gcc_assert (TREE_CODE (ref) == COMPONENT_REF);
    3284      2201038 :   tree datum = TREE_OPERAND (ref, 0);
    3285      2201038 :   tree subdatum = TREE_OPERAND (ref, 1);
    3286      2201038 :   tree counted_by_type = NULL_TREE;
    3287              : 
    3288      2201038 :   if (!(c_flexible_array_member_type_p (TREE_TYPE (ref))
    3289      2130579 :         || TREE_CODE (TREE_TYPE (ref)) == POINTER_TYPE))
    3290              :     return ref;
    3291              : 
    3292       440356 :   tree counted_by_ref = build_counted_by_ref (datum, subdatum,
    3293              :                                               &counted_by_type);
    3294       440356 :   if (counted_by_ref)
    3295          656 :     ref = build_access_with_size_for_counted_by (loc, ref,
    3296              :                                                  counted_by_ref,
    3297              :                                                  counted_by_type);
    3298              :   return ref;
    3299              : }
    3300              : 
    3301              : /* Make an expression to refer to the COMPONENT field of structure or
    3302              :    union value DATUM.  COMPONENT is an IDENTIFIER_NODE.  LOC is the
    3303              :    location of the COMPONENT_REF.  COMPONENT_LOC is the location
    3304              :    of COMPONENT.  ARROW_LOC is the location of the first -> operand if
    3305              :    it is from -> operator.
    3306              :    If HANDLE_COUNTED_BY is true, check the counted_by attribute and generate
    3307              :    a call to .ACCESS_WITH_SIZE.  Otherwise, ignore the attribute.  */
    3308              : 
    3309              : tree
    3310      2273450 : build_component_ref (location_t loc, tree datum, tree component,
    3311              :                      location_t component_loc, location_t arrow_loc)
    3312              : {
    3313      2273450 :   tree type = TREE_TYPE (datum);
    3314      2273450 :   enum tree_code code = TREE_CODE (type);
    3315      2273450 :   tree field = NULL;
    3316      2273450 :   tree ref;
    3317      2273450 :   bool datum_lvalue = lvalue_p (datum);
    3318              : 
    3319      2273450 :   if (!objc_is_public (datum, component))
    3320            0 :     return error_mark_node;
    3321              : 
    3322              :   /* Detect Objective-C property syntax object.property.  */
    3323      2273450 :   if (c_dialect_objc ()
    3324      2273450 :       && (ref = objc_maybe_build_component_ref (datum, component)))
    3325              :     return ref;
    3326              : 
    3327              :   /* See if there is a field or component with name COMPONENT.  */
    3328              : 
    3329      2273450 :   if (code == RECORD_TYPE || code == UNION_TYPE)
    3330              :     {
    3331      2273378 :       if (!COMPLETE_TYPE_P (type))
    3332              :         {
    3333           19 :           c_incomplete_type_error (loc, NULL_TREE, type);
    3334           19 :           return error_mark_node;
    3335              :         }
    3336              : 
    3337      2273359 :       field = lookup_field (type, component);
    3338              : 
    3339      2273359 :       if (!field)
    3340              :         {
    3341           63 :           tree guessed_id = lookup_field_fuzzy (type, component);
    3342           63 :           if (guessed_id)
    3343              :             {
    3344              :               /* Attempt to provide a fixit replacement hint, if
    3345              :                  we have a valid range for the component.  */
    3346            0 :               location_t reported_loc
    3347           26 :                 = (component_loc != UNKNOWN_LOCATION) ? component_loc : loc;
    3348           26 :               gcc_rich_location rich_loc (reported_loc);
    3349           26 :               if (component_loc != UNKNOWN_LOCATION)
    3350           26 :                 rich_loc.add_fixit_misspelled_id (component_loc, guessed_id);
    3351           26 :               error_at (&rich_loc,
    3352              :                         "%qT has no member named %qE; did you mean %qE?",
    3353              :                         type, component, guessed_id);
    3354           26 :             }
    3355              :           else
    3356           37 :             error_at (loc, "%qT has no member named %qE", type, component);
    3357           63 :           return error_mark_node;
    3358              :         }
    3359              : 
    3360              :       /* Accessing elements of atomic structures or unions is undefined
    3361              :          behavior (C11 6.5.2.3#5).  */
    3362      2273296 :       if (TYPE_ATOMIC (type) && c_inhibit_evaluation_warnings == 0)
    3363              :         {
    3364           18 :           if (code == RECORD_TYPE)
    3365           12 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    3366              :                         "structure %qE", component, datum);
    3367              :           else
    3368            6 :             warning_at (loc, 0, "accessing a member %qE of an atomic "
    3369              :                         "union %qE", component, datum);
    3370              :         }
    3371              : 
    3372              :       /* Chain the COMPONENT_REFs if necessary down to the FIELD.
    3373              :          This might be better solved in future the way the C++ front
    3374              :          end does it - by giving the anonymous entities each a
    3375              :          separate name and type, and then have build_component_ref
    3376              :          recursively call itself.  We can't do that here.  */
    3377      2275560 :       do
    3378              :         {
    3379      2275560 :           tree subdatum = TREE_VALUE (field);
    3380      2275560 :           int quals;
    3381      2275560 :           tree subtype;
    3382      2275560 :           bool use_datum_quals;
    3383              : 
    3384      2275560 :           if (TREE_TYPE (subdatum) == error_mark_node)
    3385              :             return error_mark_node;
    3386              : 
    3387              :           /* If this is an rvalue, it does not have qualifiers in C
    3388              :              standard terms and we must avoid propagating such
    3389              :              qualifiers down to a non-lvalue array that is then
    3390              :              converted to a pointer.  */
    3391      4551120 :           use_datum_quals = (datum_lvalue
    3392      2275560 :                              || TREE_CODE (TREE_TYPE (subdatum)) != ARRAY_TYPE);
    3393              : 
    3394      2275560 :           quals = TYPE_QUALS (strip_array_types (TREE_TYPE (subdatum)));
    3395      2275560 :           if (use_datum_quals)
    3396      2275298 :             quals |= TYPE_QUALS (TREE_TYPE (datum));
    3397      2275560 :           subtype = c_build_qualified_type (TREE_TYPE (subdatum), quals);
    3398              : 
    3399      2275560 :           ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
    3400              :                         NULL_TREE);
    3401      2275560 :           SET_EXPR_LOCATION (ref, loc);
    3402              : 
    3403      2275560 :           check_counted_by_attribute (loc, ref);
    3404              : 
    3405      2275560 :           if (TREE_READONLY (subdatum)
    3406      2275560 :               || (use_datum_quals && TREE_READONLY (datum)))
    3407        30587 :             TREE_READONLY (ref) = 1;
    3408      2275560 :           if (TREE_THIS_VOLATILE (subdatum)
    3409      2274566 :               || (use_datum_quals && TREE_THIS_VOLATILE (datum)))
    3410         2428 :             TREE_THIS_VOLATILE (ref) = 1;
    3411              : 
    3412      2275560 :           if (TREE_UNAVAILABLE (subdatum))
    3413           10 :             error_unavailable_use (subdatum, NULL_TREE);
    3414      2275550 :           else if (TREE_DEPRECATED (subdatum))
    3415           16 :             warn_deprecated_use (subdatum, NULL_TREE);
    3416              : 
    3417      2275560 :           datum = ref;
    3418              : 
    3419      2275560 :           field = TREE_CHAIN (field);
    3420              :         }
    3421      2275560 :       while (field);
    3422              : 
    3423              :       return ref;
    3424              :     }
    3425           72 :   else if (should_suggest_deref_p (type))
    3426              :     {
    3427              :       /* Special-case the error message for "ptr.field" for the case
    3428              :          where the user has confused "." vs "->".  */
    3429            7 :       rich_location richloc (line_table, loc);
    3430            7 :       if (INDIRECT_REF_P (datum) && arrow_loc != UNKNOWN_LOCATION)
    3431              :         {
    3432            2 :           richloc.add_fixit_insert_before (arrow_loc, "(*");
    3433            2 :           richloc.add_fixit_insert_after (arrow_loc, ")");
    3434            2 :           error_at (&richloc,
    3435              :                     "%qE is a pointer to pointer; did you mean to dereference "
    3436              :                     "it before applying %<->%> to it?",
    3437            2 :                     TREE_OPERAND (datum, 0));
    3438              :         }
    3439              :       else
    3440              :         {
    3441              :           /* "loc" should be the "." token.  */
    3442            5 :           richloc.add_fixit_replace ("->");
    3443            5 :           error_at (&richloc,
    3444              :                     "%qE is a pointer; did you mean to use %<->%>?",
    3445              :                     datum);
    3446              :         }
    3447            7 :       return error_mark_node;
    3448            7 :     }
    3449           65 :   else if (code != ERROR_MARK)
    3450            1 :     error_at (loc,
    3451              :               "request for member %qE in something not a structure or union",
    3452              :               component);
    3453              : 
    3454           65 :   return error_mark_node;
    3455              : }
    3456              : 
    3457              : /* Given an expression PTR for a pointer, return an expression
    3458              :    for the value pointed to.
    3459              :    ERRORSTRING is the name of the operator to appear in error messages.
    3460              : 
    3461              :    LOC is the location to use for the generated tree.  */
    3462              : 
    3463              : tree
    3464      2752323 : build_indirect_ref (location_t loc, tree ptr, ref_operator errstring)
    3465              : {
    3466      2752323 :   tree pointer = default_conversion (ptr);
    3467      2752323 :   tree type = TREE_TYPE (pointer);
    3468      2752323 :   tree ref;
    3469              : 
    3470      2752323 :   if (TREE_CODE (type) == POINTER_TYPE)
    3471              :     {
    3472      2751969 :       if (CONVERT_EXPR_P (pointer)
    3473      1971163 :           || TREE_CODE (pointer) == VIEW_CONVERT_EXPR)
    3474              :         {
    3475              :           /* If a warning is issued, mark it to avoid duplicates from
    3476              :              the backend.  This only needs to be done at
    3477              :              warn_strict_aliasing > 2.  */
    3478       780806 :           if (warn_strict_aliasing > 2)
    3479       335133 :             if (strict_aliasing_warning (EXPR_LOCATION (pointer),
    3480       335133 :                                          type, TREE_OPERAND (pointer, 0)))
    3481            7 :               suppress_warning (pointer, OPT_Wstrict_aliasing_);
    3482              :         }
    3483              : 
    3484      2751969 :       if (TREE_CODE (pointer) == ADDR_EXPR
    3485      2751969 :           && (TREE_TYPE (TREE_OPERAND (pointer, 0))
    3486        67439 :               == TREE_TYPE (type)))
    3487              :         {
    3488        67430 :           ref = TREE_OPERAND (pointer, 0);
    3489        67430 :           protected_set_expr_location (ref, loc);
    3490        67430 :           return ref;
    3491              :         }
    3492              :       else
    3493              :         {
    3494      2684539 :           tree t = TREE_TYPE (type);
    3495              : 
    3496      2684539 :           ref = build1 (INDIRECT_REF, t, pointer);
    3497              : 
    3498      2684539 :           if (VOID_TYPE_P (t) && c_inhibit_evaluation_warnings == 0)
    3499          151 :             warning_at (loc, 0, "dereferencing %<void *%> pointer");
    3500              : 
    3501              :           /* We *must* set TREE_READONLY when dereferencing a pointer to const,
    3502              :              so that we get the proper error message if the result is used
    3503              :              to assign to.  Also, &* is supposed to be a no-op.
    3504              :              And ANSI C seems to specify that the type of the result
    3505              :              should be the const type.  */
    3506              :           /* A de-reference of a pointer to const is not a const.  It is valid
    3507              :              to change it via some other pointer.  */
    3508      2684539 :           TREE_READONLY (ref) = TYPE_READONLY (t);
    3509      2684539 :           TREE_SIDE_EFFECTS (ref)
    3510      2684539 :             = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer);
    3511      2684539 :           TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
    3512      2684539 :           protected_set_expr_location (ref, loc);
    3513      2684539 :           return ref;
    3514              :         }
    3515              :     }
    3516          354 :   else if (TREE_CODE (pointer) != ERROR_MARK)
    3517          278 :     invalid_indirection_error (loc, type, errstring);
    3518              : 
    3519          354 :   return error_mark_node;
    3520              : }
    3521              : 
    3522              : /* This handles expressions of the form "a[i]", which denotes
    3523              :    an array reference.
    3524              : 
    3525              :    This is logically equivalent in C to *(a+i), but we may do it differently.
    3526              :    If A is a variable or a member, we generate a primitive ARRAY_REF.
    3527              :    This avoids forcing the array out of registers, and can work on
    3528              :    arrays that are not lvalues (for example, members of structures returned
    3529              :    by functions).
    3530              : 
    3531              :    For vector types, allow vector[i] but not i[vector], and create
    3532              :    *(((type*)&vectortype) + i) for the expression.
    3533              : 
    3534              :    LOC is the location to use for the returned expression.  */
    3535              : 
    3536              : tree
    3537      3472033 : build_array_ref (location_t loc, tree array, tree index)
    3538              : {
    3539      3472033 :   tree ret;
    3540      3472033 :   bool swapped = false;
    3541      3472033 :   if (TREE_TYPE (array) == error_mark_node
    3542      3472033 :       || TREE_TYPE (index) == error_mark_node)
    3543              :     return error_mark_node;
    3544              : 
    3545      3471925 :   if (TREE_CODE (TREE_TYPE (array)) != ARRAY_TYPE
    3546      1996506 :       && TREE_CODE (TREE_TYPE (array)) != POINTER_TYPE
    3547              :       /* Allow vector[index] but not index[vector].  */
    3548      4494862 :       && !gnu_vector_type_p (TREE_TYPE (array)))
    3549              :     {
    3550          194 :       if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE
    3551          194 :           && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE)
    3552              :         {
    3553            2 :           error_at (loc,
    3554              :             "subscripted value is neither array nor pointer nor vector");
    3555              : 
    3556            2 :           return error_mark_node;
    3557              :         }
    3558          192 :       std::swap (array, index);
    3559          192 :       swapped = true;
    3560              :     }
    3561              : 
    3562      3471923 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (index)))
    3563              :     {
    3564            2 :       error_at (loc, "array subscript is not an integer");
    3565            2 :       return error_mark_node;
    3566              :     }
    3567              : 
    3568      3471921 :   if (TREE_CODE (TREE_TYPE (TREE_TYPE (array))) == FUNCTION_TYPE)
    3569              :     {
    3570           10 :       error_at (loc, "subscripted value is pointer to function");
    3571           10 :       return error_mark_node;
    3572              :     }
    3573              : 
    3574              :   /* ??? Existing practice has been to warn only when the char
    3575              :      index is syntactically the index, not for char[array].  */
    3576      3471911 :   if (!swapped)
    3577      3471725 :      warn_array_subscript_with_type_char (loc, index);
    3578              : 
    3579              :   /* Apply default promotions *after* noticing character types.  */
    3580      3471911 :   index = default_conversion (index);
    3581      3471911 :   if (index == error_mark_node)
    3582              :     return error_mark_node;
    3583              : 
    3584      3471910 :   gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE
    3585              :               || TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE);
    3586              : 
    3587      3471910 :   bool was_vector = VECTOR_TYPE_P (TREE_TYPE (array));
    3588      3471910 :   bool non_lvalue = convert_vector_to_array_for_subscript (loc, &array, index);
    3589              : 
    3590              :   /* We only generate a call to .ACCESS_WITH_SIZE when it is a read.  */
    3591      3471910 :   if (TREE_CODE (array) == COMPONENT_REF
    3592      3471910 :       && handle_counted_by_p (array))
    3593       816103 :     array = handle_counted_by_for_component_ref (loc, array);
    3594              : 
    3595      3471910 :   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
    3596              :     {
    3597      2498169 :       tree rval, type;
    3598              : 
    3599              :       /* An array that is indexed by a non-constant
    3600              :          cannot be stored in a register; we must be able to do
    3601              :          address arithmetic on its address.
    3602              :          Likewise an array of elements of variable size.  */
    3603      2498169 :       if (TREE_CODE (index) != INTEGER_CST
    3604      2498169 :           || (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array)))
    3605      2024391 :               && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
    3606              :         {
    3607       474518 :           if (!c_mark_addressable (array, true, true))
    3608            1 :             return error_mark_node;
    3609              :         }
    3610              :       /* An array that is indexed by a constant value which is not within
    3611              :          the array bounds cannot be stored in a register either; because we
    3612              :          would get a crash in store_bit_field/extract_bit_field when trying
    3613              :          to access a non-existent part of the register.  */
    3614      2498168 :       if (TREE_CODE (index) == INTEGER_CST
    3615      2024391 :           && TYPE_DOMAIN (TREE_TYPE (array))
    3616      4519200 :           && !int_fits_type_p (index, TYPE_DOMAIN (TREE_TYPE (array))))
    3617              :         {
    3618        60655 :           if (!c_mark_addressable (array, false, true))
    3619            0 :             return error_mark_node;
    3620              :           /* ISO C2Y disallows a negative integer constant expression index
    3621              :              when array subscripting has an operand of array type.  */
    3622        60655 :           if (flag_isoc2y
    3623           26 :               && !TREE_OVERFLOW (index)
    3624        60678 :               && tree_int_cst_sgn (index) < 0)
    3625           10 :             error_at (loc, "array subscript is negative");
    3626              :         }
    3627              : 
    3628      2498168 :       if ((pedantic || warn_c90_c99_compat || warn_c23_c2y_compat)
    3629      2474815 :           && ! was_vector)
    3630              :         {
    3631      1474705 :           tree foo = array;
    3632      2309947 :           while (TREE_CODE (foo) == COMPONENT_REF)
    3633       835242 :             foo = TREE_OPERAND (foo, 0);
    3634       975411 :           if ((VAR_P (foo) && C_DECL_REGISTER (foo))
    3635      2450050 :               || (TREE_CODE (foo) == COMPOUND_LITERAL_EXPR
    3636           72 :                   && C_DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (foo))))
    3637           78 :             pedwarn_c23 (loc, OPT_Wpedantic,
    3638              :                          "ISO C forbids subscripting %<register%> array "
    3639              :                          "before C2Y");
    3640      1474627 :           else if (!lvalue_p (foo))
    3641          118 :             pedwarn_c90 (loc, OPT_Wpedantic,
    3642              :                          "ISO C90 forbids subscripting non-lvalue "
    3643              :                          "array");
    3644              :         }
    3645              : 
    3646      2498168 :       if (TREE_CODE (TREE_TYPE (index)) == BITINT_TYPE
    3647      2498168 :           && TYPE_PRECISION (TREE_TYPE (index)) > TYPE_PRECISION (sizetype))
    3648            3 :         index = fold_convert (sizetype, index);
    3649              : 
    3650      2498168 :       type = TREE_TYPE (TREE_TYPE (array));
    3651      2498168 :       rval = build4 (ARRAY_REF, type, array, index, NULL_TREE, NULL_TREE);
    3652              :       /* Array ref is const/volatile if the array elements are
    3653              :          or if the array is.  */
    3654      7494504 :       TREE_READONLY (rval)
    3655      2498168 :         |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
    3656      2498168 :             | TREE_READONLY (array));
    3657      7494504 :       TREE_SIDE_EFFECTS (rval)
    3658      2498168 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    3659      2498168 :             | TREE_SIDE_EFFECTS (array));
    3660      4996336 :       TREE_THIS_VOLATILE (rval)
    3661      2498168 :         |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
    3662              :             /* This was added by rms on 16 Nov 91.
    3663              :                It fixes  vol struct foo *a;  a->elts[1]
    3664              :                in an inline function.
    3665              :                Hope it doesn't break something else.  */
    3666      2498168 :             | TREE_THIS_VOLATILE (array));
    3667      2498168 :       ret = require_complete_type (loc, rval);
    3668      2498168 :       protected_set_expr_location (ret, loc);
    3669      2498168 :       if (non_lvalue)
    3670       105162 :         ret = non_lvalue_loc (loc, ret);
    3671      2498168 :       return ret;
    3672              :     }
    3673              :   else
    3674              :     {
    3675       973741 :       tree ar = default_conversion (array);
    3676              : 
    3677       973741 :       if (ar == error_mark_node)
    3678              :         return ar;
    3679              : 
    3680       973741 :       gcc_assert (TREE_CODE (TREE_TYPE (ar)) == POINTER_TYPE);
    3681       973741 :       gcc_assert (TREE_CODE (TREE_TYPE (TREE_TYPE (ar))) != FUNCTION_TYPE);
    3682              : 
    3683       973741 :       ret = build_indirect_ref (loc, build_binary_op (loc, PLUS_EXPR, ar,
    3684              :                                                       index, false),
    3685              :                                 RO_ARRAY_INDEXING);
    3686       973741 :       if (non_lvalue)
    3687            0 :         ret = non_lvalue_loc (loc, ret);
    3688       973741 :       return ret;
    3689              :     }
    3690              : }
    3691              : 
    3692              : /* Build an OpenMP array section reference, creating an exact type for the
    3693              :    resulting expression based on the element type and bounds if possible.  If
    3694              :    we have variable bounds, create an incomplete array type for the result
    3695              :    instead.  */
    3696              : 
    3697              : tree
    3698         3951 : build_omp_array_section (location_t loc, tree array, tree index, tree length)
    3699              : {
    3700         3951 :   tree type = TREE_TYPE (array);
    3701         3951 :   gcc_assert (type);
    3702              : 
    3703         3951 :   tree sectype, eltype = TREE_TYPE (type);
    3704              : 
    3705              :   /* It's not an array or pointer type.  Just reuse the type of the original
    3706              :      expression as the type of the array section (an error will be raised
    3707              :      anyway, later).  */
    3708         3951 :   if (eltype == NULL_TREE || error_operand_p (eltype))
    3709           12 :     sectype = TREE_TYPE (array);
    3710              :   else
    3711              :     {
    3712         3939 :       tree idxtype = NULL_TREE;
    3713              : 
    3714         3939 :       if (index != NULL_TREE
    3715         3939 :           && length != NULL_TREE
    3716         3012 :           && INTEGRAL_TYPE_P (TREE_TYPE (index))
    3717         6946 :           && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    3718              :         {
    3719         3000 :           tree low = fold_convert (sizetype, index);
    3720         3000 :           tree high = fold_convert (sizetype, length);
    3721         3000 :           high = size_binop (PLUS_EXPR, low, high);
    3722         3000 :           high = size_binop (MINUS_EXPR, high, size_one_node);
    3723         3000 :           idxtype = build_range_type (sizetype, low, high);
    3724              :         }
    3725          135 :       else if ((index == NULL_TREE || integer_zerop (index))
    3726          829 :                && length != NULL_TREE
    3727         1616 :                && INTEGRAL_TYPE_P (TREE_TYPE (length)))
    3728          660 :         idxtype = build_index_type (length);
    3729              : 
    3730         3939 :       gcc_assert (!error_operand_p (idxtype));
    3731              : 
    3732         3939 :       sectype = c_build_array_type (eltype, idxtype);
    3733              :     }
    3734              : 
    3735         3951 :   return build3_loc (loc, OMP_ARRAY_SECTION, sectype, array, index, length);
    3736              : }
    3737              : 
    3738              : 
    3739              : /* Record that REF is used.  This is relevant for undeclared static
    3740              :    function and declarations referenced from a non-local context.
    3741              :    ADDRESS indicates whether the address is taken.  */
    3742              : 
    3743              : void
    3744    475427573 : mark_decl_used (tree ref, bool address)
    3745              : {
    3746    475427573 :   if (!ref || !DECL_P (ref) || in_alignof)
    3747              :     return;
    3748              : 
    3749              :   /* Non-file-scope and non-local reference in nested function.  */
    3750    348444340 :   bool nonloc_p = current_function_decl && DECL_CONTEXT (ref)
    3751    122212567 :                   && DECL_CONTEXT (current_function_decl)
    3752    475393515 :                   && DECL_CONTEXT (ref) != current_function_decl;
    3753              : 
    3754              :   /* An undeclared static function.  */
    3755    475383431 :   bool static_p = TREE_CODE (ref) == FUNCTION_DECL
    3756    101958849 :                   && DECL_INITIAL (ref) == NULL_TREE
    3757     69753349 :                   && DECL_EXTERNAL (ref)
    3758    545134172 :                   && !TREE_PUBLIC (ref);
    3759              : 
    3760    475249711 :   if (!static_p && !nonloc_p)
    3761              :     return;
    3762              : 
    3763              :   /* If we may be in an unevaluated context, delay the decision.  */
    3764       136349 :   if (in_sizeof || in_typeof || in_countof || in_generic)
    3765          273 :     return record_maybe_used_decl (ref, address);
    3766              : 
    3767       136076 :   if (static_p)
    3768       133464 :     C_DECL_USED (ref) = 1;
    3769              : 
    3770       136076 :   if (nonloc_p && (VAR_OR_FUNCTION_DECL_P (ref)
    3771              :                    || TREE_CODE (ref) == PARM_DECL))
    3772         2049 :     DECL_NONLOCAL (ref) = 1;
    3773              : 
    3774              :   /* Nothing to do anymore.  */
    3775         2612 :   if (!nonloc_p || C_FUNC_NONLOCAL_CONTEXT (current_function_decl))
    3776       134869 :     return;
    3777              : 
    3778              :   /* Filter out the cases where referencing a non-local variable does not
    3779              :      require a non-local context passed via the static chain.  */
    3780         1207 :   if (!c_type_variably_modified_p (TREE_TYPE (ref)))
    3781         1135 :     switch (TREE_CODE (ref))
    3782              :       {
    3783          215 :       case FUNCTION_DECL:
    3784              :         /* Use of another local function that requires no context is ok.  */
    3785          215 :         if (!C_FUNC_NONLOCAL_CONTEXT (ref) && DECL_INITIAL (ref))
    3786              :           return;
    3787              :         break;
    3788          438 :       case VAR_DECL:
    3789              :         /* Static variables and constexpr are ok, but for the later only
    3790              :            when the address is not taken.  */
    3791          438 :         if (TREE_STATIC (ref) || (C_DECL_DECLARED_CONSTEXPR (ref) && !address))
    3792              :           return;
    3793              :         break;
    3794              :       case TYPE_DECL:
    3795              :         /* A typedef is ok when not for a variably-modified type. */
    3796              :         return;
    3797              :       case CONST_DECL:
    3798              :         /* An enumeration constant is ok. */
    3799              :         return;
    3800              :       case PARM_DECL:
    3801              :         break;
    3802              :       case LABEL_DECL:
    3803              :         break;
    3804            0 :       default:
    3805            0 :         gcc_unreachable ();
    3806              :     }
    3807              : 
    3808              :   /* Mark all parent functions up to the nesting level of the variable as
    3809              :      as needing the non-local context.  */
    3810         2019 :   for (tree cont = current_function_decl; cont; cont = DECL_CONTEXT (cont))
    3811              :     {
    3812         2019 :       if (cont == DECL_CONTEXT (ref))
    3813              :         break;
    3814              : 
    3815              :       /* There should not be any other type of context used for function
    3816              :          except TRANSLATION_UNIT_DECL which we should be able to reach.  */
    3817         1015 :       gcc_checking_assert (TREE_CODE (cont) == FUNCTION_DECL);
    3818              : 
    3819         1015 :       if (TREE_CODE (cont) == FUNCTION_DECL)
    3820         1015 :         C_FUNC_NONLOCAL_CONTEXT (cont) = 1;
    3821              :     }
    3822              : }
    3823              : 
    3824              : 
    3825              : /* Build an external reference to identifier ID.  FUN indicates
    3826              :    whether this will be used for a function call.  LOC is the source
    3827              :    location of the identifier.  This sets *TYPE to the type of the
    3828              :    identifier, which is not the same as the type of the returned value
    3829              :    for CONST_DECLs defined as enum constants.  If the type of the
    3830              :    identifier is not available, *TYPE is set to NULL.  */
    3831              : tree
    3832    175001626 : build_external_ref (location_t loc, tree id, bool fun, tree *type)
    3833              : {
    3834    175001626 :   tree ref;
    3835    175001626 :   tree decl = lookup_name (id);
    3836              : 
    3837              :   /* In Objective-C, an instance variable (ivar) may be preferred to
    3838              :      whatever lookup_name() found.  */
    3839    175001626 :   decl = objc_lookup_ivar (decl, id);
    3840              : 
    3841    175001626 :   *type = NULL;
    3842    175001626 :   if (decl && decl != error_mark_node)
    3843              :     {
    3844    174995390 :       ref = decl;
    3845    174995390 :       *type = TREE_TYPE (ref);
    3846    174995390 :       if (DECL_P (decl) && C_DECL_UNDERSPECIFIED (decl))
    3847            4 :         error_at (loc, "underspecified %qD referenced in its initializer",
    3848              :                   decl);
    3849              :     }
    3850         6236 :   else if (fun)
    3851              :     /* Implicit function declaration.  */
    3852         4729 :     ref = implicitly_declare (loc, id);
    3853         1507 :   else if (decl == error_mark_node)
    3854              :     /* Don't complain about something that's already been
    3855              :        complained about.  */
    3856              :     return error_mark_node;
    3857              :   else
    3858              :     {
    3859         1273 :       undeclared_variable (loc, id);
    3860         1273 :       return error_mark_node;
    3861              :     }
    3862              : 
    3863              :   /* For an OpenMP map clause, we can get better diagnostics for decls with
    3864              :      unmappable types if we return the decl with an error_mark_node type,
    3865              :      rather than returning error_mark_node for the decl itself.  */
    3866    175000119 :   if (TREE_TYPE (ref) == error_mark_node
    3867    175000119 :       && !c_omp_array_section_p)
    3868              :     return error_mark_node;
    3869              : 
    3870    175000101 :   if (TREE_UNAVAILABLE (ref))
    3871           14 :     error_unavailable_use (ref, NULL_TREE);
    3872    175000087 :   else if (TREE_DEPRECATED (ref))
    3873          100 :     warn_deprecated_use (ref, NULL_TREE);
    3874              : 
    3875              :   /* Recursive call does not count as usage.  */
    3876    175000101 :   if (ref != current_function_decl)
    3877              :     {
    3878    174997439 :       TREE_USED (ref) = 1;
    3879              :     }
    3880              : 
    3881    175000101 :   mark_decl_used (ref, false);
    3882              : 
    3883    175000101 :   if (TREE_CODE (ref) == CONST_DECL)
    3884              :     {
    3885       417823 :       used_types_insert (TREE_TYPE (ref));
    3886              : 
    3887       417823 :       if (warn_cxx_compat
    3888          429 :           && TREE_CODE (TREE_TYPE (ref)) == ENUMERAL_TYPE
    3889       418250 :           && C_TYPE_DEFINED_IN_STRUCT (TREE_TYPE (ref)))
    3890              :         {
    3891            1 :           warning_at (loc, OPT_Wc___compat,
    3892              :                       "enum constant defined in struct or union "
    3893              :                       "is not visible in C++");
    3894            1 :           inform (DECL_SOURCE_LOCATION (ref), "enum constant defined here");
    3895              :         }
    3896              : 
    3897       417823 :       ref = DECL_INITIAL (ref);
    3898       417823 :       TREE_CONSTANT (ref) = 1;
    3899              :     }
    3900              :   /* C99 6.7.4p3: An inline definition of a function with external
    3901              :      linkage ... shall not contain a reference to an identifier with
    3902              :      internal linkage.  */
    3903    174582278 :   else if (current_function_decl != NULL_TREE
    3904    173069439 :            && DECL_DECLARED_INLINE_P (current_function_decl)
    3905    159400081 :            && DECL_EXTERNAL (current_function_decl)
    3906    158623967 :            && VAR_OR_FUNCTION_DECL_P (ref)
    3907     56527779 :            && (!VAR_P (ref) || TREE_STATIC (ref))
    3908     47377343 :            && ! TREE_PUBLIC (ref)
    3909    174582312 :            && DECL_CONTEXT (ref) != current_function_decl)
    3910           25 :     record_inline_static (loc, current_function_decl, ref,
    3911              :                           csi_internal);
    3912              : 
    3913              :   return ref;
    3914              : }
    3915              : 
    3916              : static struct maybe_used_decl *maybe_used_decls;
    3917              : 
    3918              : /* Record that DECL, a reference seen inside sizeof or typeof or _Countof or
    3919              :    _Generic, might be used if the operand of sizeof is a VLA type or the
    3920              :    operand of typeof is a variably modified type or the operand of _Countof has
    3921              :    a variable number of elements or the operand of _Generic is the one selected
    3922              :    as the result.  */
    3923              : 
    3924              : static void
    3925          273 : record_maybe_used_decl (tree decl, bool address)
    3926              : {
    3927          273 :   struct maybe_used_decl *t = XOBNEW (&parser_obstack, struct maybe_used_decl);
    3928          273 :   t->decl = decl;
    3929          273 :   t->level = in_sizeof + in_typeof + in_countof + in_generic;
    3930          273 :   t->address = address;
    3931          273 :   t->next = maybe_used_decls;
    3932          273 :   maybe_used_decls = t;
    3933          273 : }
    3934              : 
    3935              : /* Pop the stack of decls possibly used inside sizeof or typeof or _Countof or
    3936              :    _Generic.  If USED is false, just discard them.  If it is true, mark them
    3937              :    used (if no longer inside sizeof or typeof or _Countof or _Generic) or move
    3938              :    them to the next level up (if still inside sizeof or typeof or _Countof or
    3939              :    _Generic).  */
    3940              : 
    3941              : void
    3942      1469638 : pop_maybe_used (bool used)
    3943              : {
    3944      1469638 :   struct maybe_used_decl *p = maybe_used_decls;
    3945      1469638 :   int cur_level = in_sizeof + in_typeof + in_countof + in_generic;
    3946      1469935 :   while (p && p->level > cur_level)
    3947              :     {
    3948          297 :       if (used)
    3949              :         {
    3950           77 :           if (cur_level == 0)
    3951           53 :             mark_decl_used (p->decl, p->address);
    3952              :           else
    3953           24 :             p->level = cur_level;
    3954              :         }
    3955          297 :       p = p->next;
    3956              :     }
    3957      1469638 :   if (!used || cur_level == 0)
    3958      1469557 :     maybe_used_decls = p;
    3959      1469638 : }
    3960              : 
    3961              : /* Pop the stack of decls possibly used inside sizeof or typeof or _Countof or
    3962              :    _Generic, without acting on them, and return the pointer to the previous top
    3963              :    of the stack.  This for use at the end of a default generic association when
    3964              :    it is not yet known whether the expression is used.  If it later turns out
    3965              :    the expression is used (or treated as used before C23), restore_maybe_used
    3966              :    should be called on the return value followed by pop_maybe_used (true);
    3967              :    otherwise, the return value can be discarded.  */
    3968              : 
    3969              : struct maybe_used_decl *
    3970         1133 : save_maybe_used ()
    3971              : {
    3972         1133 :   struct maybe_used_decl *p = maybe_used_decls, *orig = p;
    3973         1133 :   int cur_level = in_sizeof + in_typeof + in_countof + in_generic;
    3974         1165 :   while (p && p->level > cur_level)
    3975           32 :     p = p->next;
    3976         1133 :   maybe_used_decls = p;
    3977         1133 :   return orig;
    3978              : }
    3979              : 
    3980              : /* Restore the stack of decls possibly used inside sizeof or typeof or _Countof
    3981              :    or _Generic returned by save_maybe_used.  It is required that the stack is
    3982              :    at exactly the point where it was left by save_maybe_used.  */
    3983              : 
    3984              : void
    3985          276 : restore_maybe_used (struct maybe_used_decl *stack)
    3986              : {
    3987          276 :   maybe_used_decls = stack;
    3988          276 : }
    3989              : 
    3990              : /* Return the result of sizeof applied to EXPR.  */
    3991              : 
    3992              : struct c_expr
    3993       313119 : c_expr_sizeof_expr (location_t loc, struct c_expr expr)
    3994              : {
    3995       313119 :   struct c_expr ret;
    3996       313119 :   if (expr.value == error_mark_node)
    3997              :     {
    3998          111 :       ret.value = error_mark_node;
    3999          111 :       ret.original_code = ERROR_MARK;
    4000          111 :       ret.original_type = NULL;
    4001          111 :       ret.m_decimal = 0;
    4002          111 :       pop_maybe_used (false);
    4003              :     }
    4004              :   else
    4005              :     {
    4006       313008 :       bool expr_const_operands = true;
    4007              : 
    4008       313008 :       if (TREE_CODE (expr.value) == PARM_DECL
    4009       313008 :           && C_ARRAY_PARAMETER (expr.value))
    4010              :         {
    4011           55 :           auto_diagnostic_group d;
    4012           55 :           if (warning_at (loc, OPT_Wsizeof_array_argument,
    4013              :                           "%<sizeof%> on array function parameter %qE will "
    4014              :                           "return size of %qT", expr.value,
    4015           55 :                           TREE_TYPE (expr.value)))
    4016           19 :             inform (DECL_SOURCE_LOCATION (expr.value), "declared here");
    4017           55 :         }
    4018       313008 :       tree folded_expr = c_fully_fold (expr.value, require_constant_value,
    4019              :                                        &expr_const_operands);
    4020       313008 :       ret.value = c_sizeof (loc, TREE_TYPE (folded_expr));
    4021       313008 :       c_last_sizeof_arg = expr.value;
    4022       313008 :       c_last_sizeof_loc = loc;
    4023       313008 :       ret.original_code = SIZEOF_EXPR;
    4024       313008 :       ret.original_type = NULL;
    4025       313008 :       ret.m_decimal = 0;
    4026       313008 :       if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)))
    4027              :         {
    4028              :           /* sizeof is evaluated when given a vla (C99 6.5.3.4p2).  */
    4029          288 :           ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    4030              :                               folded_expr, ret.value);
    4031          288 :           C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
    4032          288 :           SET_EXPR_LOCATION (ret.value, loc);
    4033              :         }
    4034       313008 :       pop_maybe_used (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)));
    4035              :     }
    4036       313119 :   return ret;
    4037              : }
    4038              : 
    4039              : /* Return the result of sizeof applied to T, a structure for the type
    4040              :    name passed to sizeof (rather than the type itself).  LOC is the
    4041              :    location of the original expression.  */
    4042              : 
    4043              : struct c_expr
    4044       332373 : c_expr_sizeof_type (location_t loc, struct c_type_name *t)
    4045              : {
    4046       332373 :   tree type;
    4047       332373 :   struct c_expr ret;
    4048       332373 :   tree type_expr = NULL_TREE;
    4049       332373 :   bool type_expr_const = true;
    4050       332373 :   type = groktypename (t, &type_expr, &type_expr_const);
    4051       332373 :   ret.value = c_sizeof (loc, type);
    4052       332373 :   c_last_sizeof_arg = type;
    4053       332373 :   c_last_sizeof_loc = loc;
    4054       332373 :   ret.original_code = SIZEOF_EXPR;
    4055       332373 :   ret.original_type = NULL;
    4056       332373 :   ret.m_decimal = 0;
    4057       332373 :   if (type == error_mark_node)
    4058              :     {
    4059            5 :       ret.value = error_mark_node;
    4060            5 :       ret.original_code = ERROR_MARK;
    4061              :     }
    4062              :   else
    4063       332326 :   if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
    4064       664609 :       && C_TYPE_VARIABLE_SIZE (type))
    4065              :     {
    4066              :       /* If the type is a [*] array, it is a VLA but is represented as
    4067              :          having a size of zero.  In such a case we must ensure that
    4068              :          the result of sizeof does not get folded to a constant by
    4069              :          c_fully_fold, because if the size is evaluated the result is
    4070              :          not constant and so constraints on zero or negative size
    4071              :          arrays must not be applied when this sizeof call is inside
    4072              :          another array declarator.  */
    4073           41 :       if (!type_expr)
    4074           16 :         type_expr = integer_zero_node;
    4075           41 :       ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    4076              :                           type_expr, ret.value);
    4077           41 :       C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !type_expr_const;
    4078              :     }
    4079       332373 :   pop_maybe_used (type != error_mark_node
    4080       332373 :                   ? C_TYPE_VARIABLE_SIZE (type) : false);
    4081       332373 :   return ret;
    4082              : }
    4083              : 
    4084              : static bool
    4085      2148794 : top_array_vla_p (const_tree type)
    4086              : {
    4087      2148794 :   if (TREE_CODE (type) != ARRAY_TYPE)
    4088              :     return false;
    4089      2148776 :   if (!COMPLETE_TYPE_P (type))
    4090              :     return false;
    4091              : 
    4092      1964262 :   tree d = TYPE_DOMAIN (type);
    4093              : 
    4094      1964262 :   if (!d)
    4095              :     return false;
    4096      1964262 :   if (!TYPE_MAX_VALUE (d))
    4097              :     return false;
    4098              : 
    4099      1963197 :   return TREE_CODE (TYPE_MAX_VALUE (d)) != INTEGER_CST
    4100      1963197 :          || TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST;
    4101              : }
    4102              : 
    4103              : /* Return the result of countof applied to EXPR.  */
    4104              : 
    4105              : struct c_expr
    4106           54 : c_expr_countof_expr (location_t loc, struct c_expr expr)
    4107              : {
    4108           54 :   struct c_expr ret;
    4109           54 :   if (expr.value == error_mark_node)
    4110              :     {
    4111            1 :       ret.value = error_mark_node;
    4112            1 :       ret.original_code = ERROR_MARK;
    4113            1 :       ret.original_type = NULL;
    4114            1 :       ret.m_decimal = 0;
    4115            1 :       pop_maybe_used (false);
    4116              :     }
    4117              :   else
    4118              :     {
    4119           53 :       bool expr_const_operands = true;
    4120              : 
    4121           53 :       tree folded_expr = c_fully_fold (expr.value, require_constant_value,
    4122              :                                        &expr_const_operands);
    4123           53 :       ret.value = c_countof_type (loc, TREE_TYPE (folded_expr));
    4124           53 :       c_last_sizeof_arg = expr.value;
    4125           53 :       c_last_sizeof_loc = loc;
    4126           53 :       ret.original_code = COUNTOF_EXPR;
    4127           53 :       ret.original_type = NULL;
    4128           53 :       ret.m_decimal = 0;
    4129           53 :       if (top_array_vla_p (TREE_TYPE (folded_expr)))
    4130              :         {
    4131              :           /* countof is evaluated when given a vla.  */
    4132           11 :           ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    4133              :                               folded_expr, ret.value);
    4134           11 :           C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !expr_const_operands;
    4135           11 :           SET_EXPR_LOCATION (ret.value, loc);
    4136              :         }
    4137           53 :       pop_maybe_used (top_array_vla_p (TREE_TYPE (folded_expr)));
    4138              :     }
    4139           54 :   return ret;
    4140              : }
    4141              : 
    4142              : /* Return the result of countof applied to T, a structure for the type
    4143              :    name passed to countof (rather than the type itself).  LOC is the
    4144              :    location of the original expression.  */
    4145              : 
    4146              : struct c_expr
    4147           18 : c_expr_countof_type (location_t loc, struct c_type_name *t)
    4148              : {
    4149           18 :   tree type;
    4150           18 :   struct c_expr ret;
    4151           18 :   tree type_expr = NULL_TREE;
    4152           18 :   bool type_expr_const = true;
    4153           18 :   type = groktypename (t, &type_expr, &type_expr_const);
    4154           18 :   ret.value = c_countof_type (loc, type);
    4155           18 :   c_last_sizeof_arg = type;
    4156           18 :   c_last_sizeof_loc = loc;
    4157           18 :   ret.original_code = COUNTOF_EXPR;
    4158           18 :   ret.original_type = NULL;
    4159           18 :   ret.m_decimal = 0;
    4160           18 :   if (type == error_mark_node)
    4161              :     {
    4162            0 :       ret.value = error_mark_node;
    4163            0 :       ret.original_code = ERROR_MARK;
    4164              :     }
    4165              :   else
    4166            8 :   if ((type_expr || TREE_CODE (ret.value) == INTEGER_CST)
    4167           22 :       && top_array_vla_p (type))
    4168              :     {
    4169              :       /* If the type is a [*] array, it is a VLA but is represented as
    4170              :          having a size of zero.  In such a case we must ensure that
    4171              :          the result of countof does not get folded to a constant by
    4172              :          c_fully_fold, because if the number of elements is evaluated
    4173              :          the result is not constant and so
    4174              :          constraints on zero or negative size arrays must not be applied
    4175              :          when this countof call is inside another array declarator.  */
    4176            6 :       if (!type_expr)
    4177            0 :         type_expr = integer_zero_node;
    4178            6 :       ret.value = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret.value),
    4179              :                           type_expr, ret.value);
    4180            6 :       C_MAYBE_CONST_EXPR_NON_CONST (ret.value) = !type_expr_const;
    4181              :     }
    4182           18 :   pop_maybe_used (type != error_mark_node ? top_array_vla_p (type) : false);
    4183           18 :   return ret;
    4184              : }
    4185              : 
    4186              : /* Return the result of maxof applied to T, a structure for the type
    4187              :    name passed to maxof (rather than the type itself).  LOC is the
    4188              :    location of the original expression.  */
    4189              : 
    4190              : struct c_expr
    4191           46 : c_expr_maxof_type (location_t loc, struct c_type_name *t)
    4192              : {
    4193           46 :   tree type;
    4194           46 :   struct c_expr ret;
    4195           46 :   tree type_expr = NULL_TREE;
    4196           46 :   bool type_expr_const = true;
    4197           46 :   type = groktypename (t, &type_expr, &type_expr_const);
    4198           46 :   ret.value = c_maxof_type (loc, type);
    4199           46 :   c_last_sizeof_arg = type;
    4200           46 :   c_last_sizeof_loc = loc;
    4201           46 :   ret.original_code = MAXOF_EXPR;
    4202           46 :   ret.original_type = NULL;
    4203           46 :   ret.m_decimal = 0;
    4204           46 :   if (type == error_mark_node)
    4205              :     {
    4206            0 :       ret.value = error_mark_node;
    4207            0 :       ret.original_code = ERROR_MARK;
    4208              :     }
    4209           46 :   pop_maybe_used (type != error_mark_node);
    4210           46 :   return ret;
    4211              : }
    4212              : 
    4213              : /* Return the result of minof applied to T, a structure for the type
    4214              :    name passed to minof (rather than the type itself).  LOC is the
    4215              :    location of the original expression.  */
    4216              : 
    4217              : struct c_expr
    4218           46 : c_expr_minof_type (location_t loc, struct c_type_name *t)
    4219              : {
    4220           46 :   tree type;
    4221           46 :   struct c_expr ret;
    4222           46 :   tree type_expr = NULL_TREE;
    4223           46 :   bool type_expr_const = true;
    4224           46 :   type = groktypename (t, &type_expr, &type_expr_const);
    4225           46 :   ret.value = c_minof_type (loc, type);
    4226           46 :   c_last_sizeof_arg = type;
    4227           46 :   c_last_sizeof_loc = loc;
    4228           46 :   ret.original_code = MINOF_EXPR;
    4229           46 :   ret.original_type = NULL;
    4230           46 :   ret.m_decimal = 0;
    4231           46 :   if (type == error_mark_node)
    4232              :     {
    4233            0 :       ret.value = error_mark_node;
    4234            0 :       ret.original_code = ERROR_MARK;
    4235              :     }
    4236           46 :   pop_maybe_used (type != error_mark_node);
    4237           46 :   return ret;
    4238              : }
    4239              : 
    4240              : /* Build a function call to function FUNCTION with parameters PARAMS.
    4241              :    The function call is at LOC.
    4242              :    PARAMS is a list--a chain of TREE_LIST nodes--in which the
    4243              :    TREE_VALUE of each node is a parameter-expression.
    4244              :    FUNCTION's data type may be a function type or a pointer-to-function.  */
    4245              : 
    4246              : tree
    4247            0 : build_function_call (location_t loc, tree function, tree params)
    4248              : {
    4249            0 :   vec<tree, va_gc> *v;
    4250            0 :   tree ret;
    4251              : 
    4252            0 :   vec_alloc (v, list_length (params));
    4253            0 :   for (; params; params = TREE_CHAIN (params))
    4254            0 :     v->quick_push (TREE_VALUE (params));
    4255            0 :   ret = c_build_function_call_vec (loc, vNULL, function, v, NULL);
    4256            0 :   vec_free (v);
    4257            0 :   return ret;
    4258              : }
    4259              : 
    4260              : /* Give a note about the location of the declaration of DECL,
    4261              :    or, failing that, a pertinent declaration for FUNCTION_EXPR.  */
    4262              : 
    4263              : static void
    4264          299 : inform_declaration (tree decl, tree function_expr)
    4265              : {
    4266          299 :   if (decl && (TREE_CODE (decl) != FUNCTION_DECL
    4267          278 :                || !DECL_IS_UNDECLARED_BUILTIN (decl)))
    4268          207 :     inform (DECL_SOURCE_LOCATION (decl), "declared here");
    4269           92 :   else if (function_expr)
    4270           92 :     switch (TREE_CODE (function_expr))
    4271              :       {
    4272              :       default:
    4273              :         break;
    4274           13 :       case COMPONENT_REF:
    4275              :         /* Show the decl of the pertinent field (e.g. for callback
    4276              :            fields in a struct.  */
    4277           13 :         {
    4278           13 :           tree field_decl = TREE_OPERAND (function_expr, 1);
    4279           13 :           if (location_t loc = DECL_SOURCE_LOCATION (field_decl))
    4280           13 :             inform (loc, "declared here");
    4281              :         }
    4282              :         break;
    4283              :       }
    4284          299 : }
    4285              : 
    4286              : 
    4287              : /* Build a function call to function FUNCTION with parameters PARAMS.
    4288              :    If FUNCTION is the result of resolving an overloaded target built-in,
    4289              :    ORIG_FUNDECL is the original function decl, otherwise it is null.
    4290              :    ORIGTYPES, if not NULL, is a vector of types; each element is
    4291              :    either NULL or the original type of the corresponding element in
    4292              :    PARAMS.  The original type may differ from TREE_TYPE of the
    4293              :    parameter for enums.  FUNCTION's data type may be a function type
    4294              :    or pointer-to-function.  This function changes the elements of
    4295              :    PARAMS.  */
    4296              : 
    4297              : tree
    4298     49919548 : build_function_call_vec (location_t loc, vec<location_t> arg_loc,
    4299              :                          tree function, vec<tree, va_gc> *params,
    4300              :                          vec<tree, va_gc> *origtypes, tree orig_fundecl)
    4301              : {
    4302     49919548 :   tree fntype, fundecl = NULL_TREE;
    4303     49919548 :   tree name = NULL_TREE, result;
    4304     49919548 :   tree tem;
    4305     49919548 :   int nargs;
    4306     49919548 :   tree *argarray;
    4307              : 
    4308              : 
    4309              :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    4310     49919548 :   STRIP_TYPE_NOPS (function);
    4311              : 
    4312              :   /* Convert anything with function type to a pointer-to-function.  */
    4313     49919548 :   if (TREE_CODE (function) == FUNCTION_DECL)
    4314              :     {
    4315     49842015 :       name = DECL_NAME (function);
    4316              : 
    4317     49842015 :       if (flag_tm)
    4318          421 :         tm_malloc_replacement (function);
    4319     49842015 :       fundecl = function;
    4320     49842015 :       if (!orig_fundecl)
    4321     49842015 :         orig_fundecl = fundecl;
    4322              :       /* Atomic functions have type checking/casting already done.  They are
    4323              :          often rewritten and don't match the original parameter list.  */
    4324     99684030 :       if (name && startswith (IDENTIFIER_POINTER (name), "__atomic_"))
    4325              :         origtypes = NULL;
    4326              :     }
    4327     49919548 :   if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
    4328     49856530 :     function = function_to_pointer_conversion (loc, function);
    4329              : 
    4330              :   /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
    4331              :      expressions, like those used for ObjC messenger dispatches.  */
    4332     49919548 :   if (params && !params->is_empty ())
    4333     38199916 :     function = objc_rewrite_function_call (function, (*params)[0]);
    4334              : 
    4335     49919548 :   function = c_fully_fold (function, false, NULL);
    4336              : 
    4337     49919548 :   fntype = TREE_TYPE (function);
    4338              : 
    4339     49919548 :   if (TREE_CODE (fntype) == ERROR_MARK)
    4340            5 :     return error_mark_node;
    4341              : 
    4342     49919543 :   if (!(TREE_CODE (fntype) == POINTER_TYPE
    4343     49919509 :         && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
    4344              :     {
    4345           37 :       if (!flag_diagnostics_show_caret && !STATEMENT_CLASS_P (function))
    4346           33 :         error_at (loc,
    4347              :                   "called object %qE is not a function or function pointer",
    4348              :                   function);
    4349            4 :       else if (DECL_P (function))
    4350              :         {
    4351            1 :           auto_diagnostic_group d;
    4352            1 :           error_at (loc,
    4353              :                     "called object %qD is not a function or function pointer",
    4354              :                     function);
    4355            1 :           inform_declaration (function, NULL_TREE);
    4356            1 :         }
    4357              :       else
    4358            3 :         error_at (loc,
    4359              :                   "called object is not a function or function pointer");
    4360           37 :       return error_mark_node;
    4361              :     }
    4362              : 
    4363     49919506 :   if (fundecl && TREE_THIS_VOLATILE (fundecl))
    4364       376992 :     current_function_returns_abnormally = 1;
    4365              : 
    4366              :   /* fntype now gets the type of function pointed to.  */
    4367     49919506 :   fntype = TREE_TYPE (fntype);
    4368     49919506 :   tree return_type = TREE_TYPE (fntype);
    4369              : 
    4370              :   /* Convert the parameters to the types declared in the
    4371              :      function prototype, or apply default promotions.  */
    4372              : 
    4373     49919506 :   nargs = convert_arguments (loc, arg_loc, fntype, params,
    4374              :                              origtypes, function, fundecl);
    4375     49919506 :   if (nargs < 0)
    4376          178 :     return error_mark_node;
    4377              : 
    4378              :   /* Check that the function is called through a compatible prototype.
    4379              :      If it is not, warn.  */
    4380     49918421 :   if (CONVERT_EXPR_P (function)
    4381          923 :       && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
    4382          215 :       && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
    4383     49919513 :       && !comptypes (fntype, TREE_TYPE (tem)))
    4384              :     {
    4385              :       /* This situation leads to run-time undefined behavior.  We can't,
    4386              :          therefore, simply error unless we can prove that all possible
    4387              :          executions of the program must execute the code.  */
    4388           20 :       warning_at (loc, 0, "function called through a non-compatible type");
    4389              : 
    4390           20 :       if (VOID_TYPE_P (return_type)
    4391           20 :           && TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
    4392            1 :         pedwarn (loc, 0,
    4393              :                  "function with qualified void return type called");
    4394              :      }
    4395              : 
    4396     49919328 :   argarray = vec_safe_address (params);
    4397              : 
    4398              :   /* Check that arguments to builtin functions match the expectations.  */
    4399     49919328 :   if (fundecl
    4400     49841852 :       && fndecl_built_in_p (fundecl)
    4401     83180176 :       && !check_builtin_function_arguments (loc, arg_loc, fundecl,
    4402              :                                             orig_fundecl, nargs, argarray))
    4403          338 :     return error_mark_node;
    4404              : 
    4405              :   /* Check that the arguments to the function are valid.  */
    4406     49918990 :   bool warned_p = check_function_arguments (loc, fundecl, fntype,
    4407              :                                             nargs, argarray, &arg_loc,
    4408              :                                             comptypes);
    4409              : 
    4410     49918990 :   if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED
    4411     49918990 :       && !VOID_TYPE_P (return_type))
    4412           11 :     return_type = c_build_qualified_type (return_type, TYPE_UNQUALIFIED);
    4413     49918990 :   if (name != NULL_TREE
    4414     99760504 :       && startswith (IDENTIFIER_POINTER (name), "__builtin_"))
    4415              :     {
    4416     32534520 :       if (require_constant_value)
    4417         3462 :         result
    4418         3462 :           = fold_build_call_array_initializer_loc (loc, return_type,
    4419              :                                                    function, nargs, argarray);
    4420              :       else
    4421     32531058 :         result = fold_build_call_array_loc (loc, return_type,
    4422              :                                             function, nargs, argarray);
    4423     32534520 :       if (TREE_CODE (result) == NOP_EXPR
    4424     32534520 :           && TREE_CODE (TREE_OPERAND (result, 0)) == INTEGER_CST)
    4425        26490 :         STRIP_TYPE_NOPS (result);
    4426              :     }
    4427              :   else
    4428     17384470 :     result = build_call_array_loc (loc, return_type,
    4429              :                                    function, nargs, argarray);
    4430              :   /* If -Wnonnull warning has been diagnosed, avoid diagnosing it again
    4431              :      later.  */
    4432     49918990 :   if (warned_p && TREE_CODE (result) == CALL_EXPR)
    4433          215 :     suppress_warning (result, OPT_Wnonnull);
    4434              : 
    4435              :   /* In this improbable scenario, a nested function returns a VM type.
    4436              :      Create a TARGET_EXPR so that the call always has a LHS, much as
    4437              :      what the C++ FE does for functions returning non-PODs.  */
    4438     49918990 :   if (c_type_variably_modified_p (TREE_TYPE (fntype)))
    4439              :     {
    4440           83 :       tree tmp = create_tmp_var_raw (TREE_TYPE (fntype));
    4441           83 :       result = build4 (TARGET_EXPR, TREE_TYPE (fntype), tmp, result,
    4442              :                        NULL_TREE, NULL_TREE);
    4443              :     }
    4444              : 
    4445     49918990 :   if (VOID_TYPE_P (TREE_TYPE (result)))
    4446              :     {
    4447      2394292 :       if (TYPE_QUALS (TREE_TYPE (result)) != TYPE_UNQUALIFIED)
    4448            2 :         pedwarn (loc, 0,
    4449              :                  "function with qualified void return type called");
    4450      2394292 :       return result;
    4451              :     }
    4452     47524698 :   return require_complete_type (loc, result);
    4453              : }
    4454              : 
    4455              : /* Like build_function_call_vec, but call also resolve_overloaded_builtin.  */
    4456              : 
    4457              : tree
    4458     49919105 : c_build_function_call_vec (location_t loc, const vec<location_t> &arg_loc,
    4459              :                            tree function, vec<tree, va_gc> *params,
    4460              :                            vec<tree, va_gc> *origtypes)
    4461              : {
    4462              :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
    4463     49919116 :   STRIP_TYPE_NOPS (function);
    4464              : 
    4465              :   /* Convert anything with function type to a pointer-to-function.  */
    4466     49919105 :   if (TREE_CODE (function) == FUNCTION_DECL)
    4467              :     {
    4468              :       /* Implement type-directed function overloading for builtins.
    4469              :          resolve_overloaded_builtin and targetm.resolve_overloaded_builtin
    4470              :          handle all the type checking.  The result is a complete expression
    4471              :          that implements this function call.  */
    4472     49841572 :       tree tem = resolve_overloaded_builtin (loc, function, params);
    4473     49841572 :       if (tem)
    4474              :         return tem;
    4475              :     }
    4476     49833154 :   return build_function_call_vec (loc, arg_loc, function, params, origtypes);
    4477              : }
    4478              : 
    4479              : /* Helper for convert_arguments called to convert the VALue of argument
    4480              :    number ARGNUM from ORIGTYPE to the corresponding parameter number
    4481              :    PARMNUM and TYPE.
    4482              :    PLOC is the location where the conversion is being performed.
    4483              :    FUNCTION and FUNDECL are the same as in convert_arguments.
    4484              :    VALTYPE is the original type of VAL before the conversion and,
    4485              :    for EXCESS_PRECISION_EXPR, the operand of the expression.
    4486              :    NPC is true if VAL represents the null pointer constant (VAL itself
    4487              :    will have been folded to an integer constant).
    4488              :    RNAME is the same as FUNCTION except in Objective C when it's
    4489              :    the function selector.
    4490              :    EXCESS_PRECISION is true when VAL was originally represented
    4491              :    as EXCESS_PRECISION_EXPR.
    4492              :    WARNOPT is the same as in convert_for_assignment.  */
    4493              : 
    4494              : static tree
    4495    125647605 : convert_argument (location_t ploc, tree function, tree fundecl,
    4496              :                   tree type, tree origtype, tree val, tree valtype,
    4497              :                   bool npc, tree rname, int parmnum, int argnum,
    4498              :                   bool excess_precision, int warnopt)
    4499              : {
    4500              :   /* Formal parm type is specified by a function prototype.  */
    4501              : 
    4502    125647605 :   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
    4503              :     {
    4504            3 :       error_at (ploc, "type of formal parameter %d is incomplete",
    4505              :                 parmnum + 1);
    4506            3 :       return error_mark_node;
    4507              :     }
    4508              : 
    4509              :   /* Optionally warn about conversions that differ from the default
    4510              :      conversions.  */
    4511    125647602 :   if (warn_traditional_conversion || warn_traditional)
    4512              :     {
    4513          193 :       if (INTEGRAL_TYPE_P (type)
    4514          107 :           && SCALAR_FLOAT_TYPE_P (valtype))
    4515           19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4516              :                     "passing argument %d of %qE as integer rather "
    4517              :                     "than floating due to prototype",
    4518              :                     argnum, rname);
    4519          193 :       if (INTEGRAL_TYPE_P (type)
    4520          107 :           && TREE_CODE (valtype) == COMPLEX_TYPE)
    4521            5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4522              :                     "passing argument %d of %qE as integer rather "
    4523              :                     "than complex due to prototype",
    4524              :                     argnum, rname);
    4525          188 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    4526           14 :                && SCALAR_FLOAT_TYPE_P (valtype))
    4527            7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4528              :                     "passing argument %d of %qE as complex rather "
    4529              :                     "than floating due to prototype",
    4530              :                     argnum, rname);
    4531          181 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4532           71 :                && INTEGRAL_TYPE_P (valtype))
    4533           19 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4534              :                     "passing argument %d of %qE as floating rather "
    4535              :                     "than integer due to prototype",
    4536              :                     argnum, rname);
    4537          162 :       else if (TREE_CODE (type) == COMPLEX_TYPE
    4538            7 :                && INTEGRAL_TYPE_P (valtype))
    4539            5 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4540              :                     "passing argument %d of %qE as complex rather "
    4541              :                     "than integer due to prototype",
    4542              :                     argnum, rname);
    4543          157 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4544           52 :                && TREE_CODE (valtype) == COMPLEX_TYPE)
    4545            7 :         warning_at (ploc, OPT_Wtraditional_conversion,
    4546              :                     "passing argument %d of %qE as floating rather "
    4547              :                     "than complex due to prototype",
    4548              :                     argnum, rname);
    4549              :       /* ??? At some point, messages should be written about
    4550              :          conversions between complex types, but that's too messy
    4551              :          to do now.  */
    4552          150 :       else if (SCALAR_FLOAT_TYPE_P (type)
    4553           45 :                && SCALAR_FLOAT_TYPE_P (valtype))
    4554              :         {
    4555           45 :           unsigned int formal_prec = TYPE_PRECISION (type);
    4556              : 
    4557              :           /* Warn if any argument is passed as `float',
    4558              :              since without a prototype it would be `double'.  */
    4559           45 :           if (formal_prec == TYPE_PRECISION (float_type_node)
    4560           45 :               && type != dfloat32_type_node)
    4561            7 :             warning_at (ploc, 0,
    4562              :                         "passing argument %d of %qE as %<float%> "
    4563              :                         "rather than %<double%> due to prototype",
    4564              :                         argnum, rname);
    4565              : 
    4566              :           /* Warn if mismatch between argument and prototype
    4567              :              for decimal float types.  Warn of conversions with
    4568              :              binary float types and of precision narrowing due to
    4569              :              prototype.  */
    4570           38 :           else if (type != valtype
    4571           32 :                    && (type == dfloat32_type_node
    4572           22 :                        || type == dfloat64_type_node
    4573           12 :                        || type == dfloat128_type_node
    4574            2 :                        || valtype == dfloat32_type_node
    4575            2 :                        || valtype == dfloat64_type_node
    4576            2 :                        || valtype == dfloat128_type_node)
    4577           38 :                    && (formal_prec
    4578           30 :                        <= TYPE_PRECISION (valtype)
    4579           14 :                        || (type == dfloat128_type_node
    4580           10 :                            && (valtype
    4581           10 :                                != dfloat64_type_node
    4582            8 :                                && (valtype
    4583              :                                    != dfloat32_type_node)))
    4584            8 :                        || (type == dfloat64_type_node
    4585            4 :                            && (valtype
    4586              :                                != dfloat32_type_node))))
    4587           24 :             warning_at (ploc, 0,
    4588              :                         "passing argument %d of %qE as %qT "
    4589              :                         "rather than %qT due to prototype",
    4590              :                         argnum, rname, type, valtype);
    4591              : 
    4592              :         }
    4593              :       /* Detect integer changing in width or signedness.
    4594              :          These warnings are only activated with
    4595              :          -Wtraditional-conversion, not with -Wtraditional.  */
    4596          105 :       else if (warn_traditional_conversion
    4597          105 :                && INTEGRAL_TYPE_P (type)
    4598          102 :                && INTEGRAL_TYPE_P (valtype))
    4599              :         {
    4600           83 :           unsigned int formal_prec = TYPE_PRECISION (type);
    4601           83 :           tree would_have_been = default_conversion (val);
    4602           83 :           tree type1 = TREE_TYPE (would_have_been);
    4603              : 
    4604           83 :           if (val == error_mark_node)
    4605              :             /* VAL could have been of incomplete type.  */;
    4606           83 :           else if (TREE_CODE (type) == ENUMERAL_TYPE
    4607           83 :                    && (TYPE_MAIN_VARIANT (type)
    4608            2 :                        == TYPE_MAIN_VARIANT (valtype)))
    4609              :             /* No warning if function asks for enum
    4610              :                and the actual arg is that enum type.  */
    4611              :             ;
    4612           81 :           else if (formal_prec != TYPE_PRECISION (type1))
    4613           14 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4614              :                         "passing argument %d of %qE "
    4615              :                         "with different width due to prototype",
    4616              :                         argnum, rname);
    4617           67 :           else if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (type1))
    4618              :             ;
    4619              :           /* Don't complain if the formal parameter type
    4620              :              is an enum, because we can't tell now whether
    4621              :              the value was an enum--even the same enum.  */
    4622           32 :           else if (TREE_CODE (type) == ENUMERAL_TYPE)
    4623              :             ;
    4624           32 :           else if (TREE_CODE (val) == INTEGER_CST
    4625            5 :                    && int_fits_type_p (val, type))
    4626              :             /* Change in signedness doesn't matter
    4627              :                if a constant value is unaffected.  */
    4628              :             ;
    4629              :           /* If the value is extended from a narrower
    4630              :              unsigned type, it doesn't matter whether we
    4631              :              pass it as signed or unsigned; the value
    4632              :              certainly is the same either way.  */
    4633           32 :           else if (TYPE_PRECISION (valtype) < TYPE_PRECISION (type)
    4634           32 :                    && TYPE_UNSIGNED (valtype))
    4635              :             ;
    4636           32 :           else if (TYPE_UNSIGNED (type))
    4637           17 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4638              :                         "passing argument %d of %qE "
    4639              :                         "as unsigned due to prototype",
    4640              :                         argnum, rname);
    4641              :           else
    4642           15 :             warning_at (ploc, OPT_Wtraditional_conversion,
    4643              :                         "passing argument %d of %qE "
    4644              :                         "as signed due to prototype",
    4645              :                         argnum, rname);
    4646              :         }
    4647              :     }
    4648              : 
    4649              :   /* Possibly restore an EXCESS_PRECISION_EXPR for the
    4650              :      sake of better warnings from convert_and_check.  */
    4651    125647602 :   if (excess_precision)
    4652          380 :     val = build1 (EXCESS_PRECISION_EXPR, valtype, val);
    4653              : 
    4654    125647602 :   tree parmval = convert_for_assignment (ploc, ploc, type,
    4655              :                                          val, origtype, ic_argpass,
    4656              :                                          npc, fundecl, function,
    4657              :                                          parmnum + 1, warnopt);
    4658    125647602 :   return parmval;
    4659              : }
    4660              : 
    4661              : /* Convert the argument expressions in the vector VALUES
    4662              :    to the types in the list TYPE_ARG_TYPES (FNTYPE).
    4663              : 
    4664              :    If the list is exhausted, or when an element has NULL as its type,
    4665              :    perform the default conversions.
    4666              : 
    4667              :    ORIGTYPES is the original types of the expressions in VALUES.  This
    4668              :    holds the type of enum values which have been converted to integral
    4669              :    types.  It may be NULL.
    4670              : 
    4671              :    FUNCTION is a tree for the called function.  It is used only for
    4672              :    error messages, where it is formatted with %qE.
    4673              : 
    4674              :    This is also where warnings about wrong number of args are generated.
    4675              : 
    4676              :    ARG_LOC are locations of function arguments (if any).
    4677              : 
    4678              :    Returns the actual number of arguments processed (which may be less
    4679              :    than the length of VALUES in some error situations), or -1 on
    4680              :    failure.  */
    4681              : 
    4682              : static int
    4683     49919506 : convert_arguments (location_t loc, vec<location_t> arg_loc, tree fntype,
    4684              :                    vec<tree, va_gc> *values, vec<tree, va_gc> *origtypes,
    4685              :                    tree function, tree fundecl)
    4686              : {
    4687     49919506 :   tree typelist = TYPE_ARG_TYPES (fntype);
    4688     49919506 :   unsigned int parmnum;
    4689     49919506 :   bool error_args = false;
    4690     49919506 :   const bool type_generic = fundecl
    4691     49919506 :     && lookup_attribute ("type generic", TYPE_ATTRIBUTES (TREE_TYPE (fundecl)));
    4692     49919506 :   bool type_generic_remove_excess_precision = false;
    4693     49919506 :   bool type_generic_overflow_p = false;
    4694     49919506 :   bool type_generic_bit_query = false;
    4695     49919506 :   tree selector;
    4696              : 
    4697              :   /* Change pointer to function to the function itself for
    4698              :      diagnostics.  */
    4699     49919506 :   if (TREE_CODE (function) == ADDR_EXPR
    4700     49919506 :       && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    4701     49844113 :     function = TREE_OPERAND (function, 0);
    4702              : 
    4703              :   /* Handle an ObjC selector specially for diagnostics.  */
    4704     49919506 :   selector = objc_message_selector ();
    4705              : 
    4706              :   /* For a call to a built-in function declared without a prototype,
    4707              :      set to the built-in function's argument list.  */
    4708     49919506 :   tree builtin_typelist = NULL_TREE;
    4709              : 
    4710              :   /* For type-generic built-in functions, determine whether excess
    4711              :      precision should be removed (classification) or not
    4712              :      (comparison).  */
    4713     49919506 :   if (fundecl
    4714     49919506 :       && fndecl_built_in_p (fundecl, BUILT_IN_NORMAL))
    4715              :     {
    4716      1405107 :       built_in_function code = DECL_FUNCTION_CODE (fundecl);
    4717      1405107 :       if (C_DECL_BUILTIN_PROTOTYPE (fundecl))
    4718              :         {
    4719              :           /* For a call to a built-in function declared without a prototype
    4720              :              use the types of the parameters of the internal built-in to
    4721              :              match those of the arguments to.  */
    4722       691962 :           if (tree bdecl = builtin_decl_explicit (code))
    4723       691962 :             builtin_typelist = TYPE_ARG_TYPES (TREE_TYPE (bdecl));
    4724              :         }
    4725              : 
    4726              :       /* For type-generic built-in functions, determine whether excess
    4727              :          precision should be removed (classification) or not
    4728              :          (comparison).  */
    4729      1405107 :       if (type_generic)
    4730        60977 :         switch (code)
    4731              :           {
    4732         5399 :           case BUILT_IN_ISFINITE:
    4733         5399 :           case BUILT_IN_ISINF:
    4734         5399 :           case BUILT_IN_ISINF_SIGN:
    4735         5399 :           case BUILT_IN_ISNAN:
    4736         5399 :           case BUILT_IN_ISNORMAL:
    4737         5399 :           case BUILT_IN_ISSIGNALING:
    4738         5399 :           case BUILT_IN_FPCLASSIFY:
    4739         5399 :             type_generic_remove_excess_precision = true;
    4740         5399 :             break;
    4741              : 
    4742        21026 :           case BUILT_IN_ADD_OVERFLOW_P:
    4743        21026 :           case BUILT_IN_SUB_OVERFLOW_P:
    4744        21026 :           case BUILT_IN_MUL_OVERFLOW_P:
    4745              :             /* The last argument of these type-generic builtins
    4746              :                should not be promoted.  */
    4747        21026 :             type_generic_overflow_p = true;
    4748        21026 :             break;
    4749              : 
    4750         1348 :           case BUILT_IN_CLZG:
    4751         1348 :           case BUILT_IN_CTZG:
    4752         1348 :           case BUILT_IN_CLRSBG:
    4753         1348 :           case BUILT_IN_FFSG:
    4754         1348 :           case BUILT_IN_PARITYG:
    4755         1348 :           case BUILT_IN_POPCOUNTG:
    4756              :             /* The first argument of these type-generic builtins
    4757              :                should not be promoted.  */
    4758         1348 :             type_generic_bit_query = true;
    4759         1348 :             break;
    4760              : 
    4761              :           default:
    4762              :             break;
    4763              :           }
    4764              :     }
    4765              : 
    4766              :   /* Scan the given expressions (VALUES) and types (TYPELIST), producing
    4767              :      individual converted arguments.  */
    4768              : 
    4769     49919506 :   tree typetail, builtin_typetail, val;
    4770     49919506 :   for (typetail = typelist,
    4771     49919506 :          builtin_typetail = builtin_typelist,
    4772     49919506 :          parmnum = 0;
    4773    176504969 :        values && values->iterate (parmnum, &val);
    4774              :        ++parmnum)
    4775              :     {
    4776              :       /* The type of the function parameter (if it was declared with one).  */
    4777    252231218 :       tree type = typetail ? TREE_VALUE (typetail) : NULL_TREE;
    4778              :       /* The type of the built-in function parameter (if the function
    4779              :          is a built-in).  Used to detect type incompatibilities in
    4780              :          calls to built-ins declared without a prototype.  */
    4781    126585499 :       tree builtin_type = (builtin_typetail
    4782    127624372 :                            ? TREE_VALUE (builtin_typetail) : NULL_TREE);
    4783              :       /* The original type of the argument being passed to the function.  */
    4784    126585499 :       tree valtype = TREE_TYPE (val);
    4785              :       /* The called function (or function selector in Objective C).  */
    4786    126585499 :       tree rname = function;
    4787    126585499 :       int argnum = parmnum + 1;
    4788    126585499 :       const char *invalid_func_diag;
    4789              :       /* Set for EXCESS_PRECISION_EXPR arguments.  */
    4790    126585499 :       bool excess_precision = false;
    4791              :       /* The value of the argument after conversion to the type
    4792              :          of the function parameter it is passed to.  */
    4793    126585499 :       tree parmval;
    4794              :       /* Some __atomic_* builtins have additional hidden argument at
    4795              :          position 0.  */
    4796    126585499 :       location_t ploc
    4797    126316651 :         = !arg_loc.is_empty () && values->length () == arg_loc.length ()
    4798    126316051 :           ? expansion_point_location_if_in_system_header (arg_loc[parmnum])
    4799    126585499 :           : input_location;
    4800              : 
    4801    126585499 :       if (type == void_type_node)
    4802              :         {
    4803           33 :           auto_diagnostic_group d;
    4804           33 :           int num_expected = parmnum;
    4805           33 :           int num_actual = values->length ();
    4806           33 :           gcc_rich_location rich_loc (loc);
    4807           33 :           if (ploc != input_location)
    4808           32 :             rich_loc.add_range (ploc);
    4809           33 :           if (selector)
    4810            0 :             error_at (&rich_loc,
    4811              :                       "too many arguments to method %qE; expected %i, have %i",
    4812              :                       selector, num_expected, num_actual);
    4813              :           else
    4814           33 :             error_at (&rich_loc,
    4815              :                       "too many arguments to function %qE; expected %i, have %i",
    4816              :                       function, num_expected, num_actual);
    4817           33 :           inform_declaration (fundecl, function);
    4818           65 :           return error_args ? -1 : (int) parmnum;
    4819           33 :         }
    4820              : 
    4821    126585466 :       if (builtin_type == void_type_node)
    4822              :         {
    4823           12 :           auto_diagnostic_group d;
    4824           12 :           if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    4825              :                           "too many arguments to built-in function %qE "
    4826              :                           "expecting %d", function, parmnum))
    4827           12 :             inform_declaration (fundecl, function);
    4828           12 :           builtin_typetail = NULL_TREE;
    4829           12 :         }
    4830              : 
    4831        90517 :       if (!typetail && parmnum == 0 && !TYPE_NO_NAMED_ARGS_STDARG_P (fntype)
    4832    126675864 :           && !(fundecl && fndecl_built_in_p (fundecl)))
    4833              :         {
    4834         6961 :           auto_diagnostic_group d;
    4835         6961 :           bool warned;
    4836         6961 :           if (selector)
    4837            0 :             warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
    4838              :                                  "ISO C23 does not allow arguments"
    4839              :                                  " for method %qE declared without parameters",
    4840              :                                  function);
    4841              :           else
    4842         6961 :             warned = warning_at (loc, OPT_Wdeprecated_non_prototype,
    4843              :                                  "ISO C23 does not allow arguments"
    4844              :                                  " for function %qE declared without parameters",
    4845              :                                  function);
    4846         6961 :           if (warned)
    4847            4 :             inform_declaration (fundecl, function);
    4848         6961 :         }
    4849              : 
    4850    126585466 :       if (selector && argnum > 2)
    4851              :         {
    4852            0 :           rname = selector;
    4853            0 :           argnum -= 2;
    4854              :         }
    4855              : 
    4856              :       /* Determine if VAL is a null pointer constant before folding it.  */
    4857    126585466 :       bool npc = null_pointer_constant_p (val);
    4858              : 
    4859              :       /* If there is excess precision and a prototype, convert once to
    4860              :          the required type rather than converting via the semantic
    4861              :          type.  Likewise without a prototype a float value represented
    4862              :          as long double should be converted once to double.  But for
    4863              :          type-generic classification functions excess precision must
    4864              :          be removed here.  */
    4865    126585466 :       if (TREE_CODE (val) == EXCESS_PRECISION_EXPR
    4866          433 :           && (type || !type_generic || !type_generic_remove_excess_precision))
    4867              :         {
    4868          413 :           val = TREE_OPERAND (val, 0);
    4869          413 :           excess_precision = true;
    4870              :         }
    4871    126585466 :       val = c_fully_fold (val, false, NULL);
    4872    253170933 :       STRIP_TYPE_NOPS (val);
    4873              : 
    4874    126585466 :       val = require_complete_type (ploc, val);
    4875              : 
    4876              :       /* Some floating-point arguments must be promoted to double when
    4877              :          no type is specified by a prototype.  This applies to
    4878              :          arguments of type float, and to architecture-specific types
    4879              :          (ARM __fp16), but not to _FloatN or _FloatNx types.  */
    4880    126585466 :       bool promote_float_arg = false;
    4881    126585466 :       if (type == NULL_TREE
    4882       939780 :           && TREE_CODE (valtype) == REAL_TYPE
    4883       269595 :           && (TYPE_PRECISION (valtype)
    4884       269595 :               <= TYPE_PRECISION (double_type_node))
    4885       262349 :           && TYPE_MAIN_VARIANT (valtype) != double_type_node
    4886       131373 :           && TYPE_MAIN_VARIANT (valtype) != long_double_type_node
    4887    126716839 :           && !DECIMAL_FLOAT_MODE_P (TYPE_MODE (valtype)))
    4888              :         {
    4889              :           /* Promote this argument, unless it has a _FloatN or
    4890              :              _FloatNx type.  */
    4891      1027486 :           promote_float_arg = true;
    4892      1027486 :           for (int i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    4893       900123 :             if (TYPE_MAIN_VARIANT (valtype) == FLOATN_NX_TYPE_NODE (i))
    4894              :               {
    4895              :                 promote_float_arg = false;
    4896              :                 break;
    4897              :               }
    4898              :           /* Don't promote __bf16 either.  */
    4899       130640 :           if (TYPE_MAIN_VARIANT (valtype) == bfloat16_type_node)
    4900    126454896 :             promote_float_arg = false;
    4901              :         }
    4902              : 
    4903    126585466 :       if (type != NULL_TREE)
    4904              :         {
    4905    125645686 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    4906    125645686 :           parmval = convert_argument (ploc, function, fundecl, type, origtype,
    4907              :                                       val, valtype, npc, rname, parmnum, argnum,
    4908              :                                       excess_precision, 0);
    4909              :         }
    4910              :       /* A NULLPTR type is just a nullptr always.  */
    4911       939780 :       else if (TREE_CODE (TREE_TYPE (val)) == NULLPTR_TYPE)
    4912            9 :         parmval = omit_one_operand_loc (ploc, TREE_TYPE (val), nullptr_node, val);
    4913       939771 :       else if (promote_float_arg)
    4914              :         {
    4915       127293 :           if (type_generic)
    4916              :             parmval = val;
    4917              :           else
    4918              :             {
    4919              :               /* Convert `float' to `double'.  */
    4920       124522 :               if (warn_double_promotion && !c_inhibit_evaluation_warnings)
    4921            6 :                 warning_at (ploc, OPT_Wdouble_promotion,
    4922              :                             "implicit conversion from %qT to %qT when passing "
    4923              :                             "argument to function",
    4924              :                             valtype, double_type_node);
    4925       124522 :               parmval = convert (double_type_node, val);
    4926              :             }
    4927              :         }
    4928       812478 :       else if ((excess_precision && !type_generic)
    4929       812476 :                || (type_generic_overflow_p && parmnum == 2)
    4930       791454 :                || (type_generic_bit_query && parmnum == 0))
    4931              :         /* A "double" argument with excess precision being passed
    4932              :            without a prototype or in variable arguments.
    4933              :            The last argument of __builtin_*_overflow_p should not be
    4934              :            promoted, similarly the first argument of
    4935              :            __builtin_{clz,ctz,clrsb,ffs,parity,popcount}g.  */
    4936        22366 :         parmval = convert (valtype, val);
    4937      1580224 :       else if ((invalid_func_diag =
    4938       790112 :                 targetm.calls.invalid_arg_for_unprototyped_fn (typelist, fundecl, val)))
    4939              :         {
    4940            0 :           error (invalid_func_diag);
    4941            0 :           return -1;
    4942              :         }
    4943       790112 :       else if (TREE_CODE (val) == ADDR_EXPR && reject_gcc_builtin (val))
    4944              :         {
    4945              :           return -1;
    4946              :         }
    4947              :       else
    4948              :         /* Convert `short' and `char' to full-size `int'.  */
    4949       790109 :         parmval = default_conversion (val);
    4950              : 
    4951    126585463 :       (*values)[parmnum] = parmval;
    4952    126585463 :       if (parmval == error_mark_node)
    4953          105 :         error_args = true;
    4954              : 
    4955    126585463 :       if (!type && builtin_type && TREE_CODE (builtin_type) != VOID_TYPE)
    4956              :         {
    4957              :           /* For a call to a built-in function declared without a prototype,
    4958              :              perform the conversions from the argument to the expected type
    4959              :              but issue warnings rather than errors for any mismatches.
    4960              :              Ignore the converted argument and use the PARMVAL obtained
    4961              :              above by applying default conversions instead.  */
    4962         1919 :           tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
    4963         1919 :           convert_argument (ploc, function, fundecl, builtin_type, origtype,
    4964              :                             val, valtype, npc, rname, parmnum, argnum,
    4965              :                             excess_precision,
    4966              :                             OPT_Wbuiltin_declaration_mismatch);
    4967              :         }
    4968              : 
    4969    126585463 :       if (typetail)
    4970    125645686 :         typetail = TREE_CHAIN (typetail);
    4971              : 
    4972    126585463 :       if (builtin_typetail)
    4973      1038856 :         builtin_typetail = TREE_CHAIN (builtin_typetail);
    4974              :     }
    4975              : 
    4976     88119339 :   gcc_assert (parmnum == vec_safe_length (values));
    4977              : 
    4978     99506165 :   if (typetail != NULL_TREE && TREE_VALUE (typetail) != void_type_node)
    4979              :     {
    4980              :       /* Not enough args.
    4981              :          Determine minimum number of arguments required.  */
    4982              :       int min_expected_num = 0;
    4983          231 :       bool at_least_p = false;
    4984              :       tree iter = typelist;
    4985          386 :       while (true)
    4986              :         {
    4987          231 :           if (!iter)
    4988              :             {
    4989              :               /* Variadic arguments; stop iterating.  */
    4990              :               at_least_p = true;
    4991              :               break;
    4992              :             }
    4993          222 :           if (iter == void_list_node)
    4994              :             /* End of arguments; stop iterating.  */
    4995              :             break;
    4996          155 :           ++min_expected_num;
    4997          155 :           iter = TREE_CHAIN (iter);
    4998              :         }
    4999           76 :       auto_diagnostic_group d;
    5000           76 :       int actual_num = vec_safe_length (values);
    5001          143 :       error_at (loc,
    5002              :                 at_least_p
    5003              :                 ? G_("too few arguments to function %qE; expected at least %i, have %i")
    5004              :                 : G_("too few arguments to function %qE; expected %i, have %i"),
    5005              :                 function, min_expected_num, actual_num);
    5006           76 :       inform_declaration (fundecl, function);
    5007           76 :       return -1;
    5008           76 :     }
    5009              : 
    5010     50575135 :   if (builtin_typetail && TREE_VALUE (builtin_typetail) != void_type_node)
    5011              :     {
    5012              :       unsigned nargs = parmnum;
    5013          616 :       for (tree t = builtin_typetail; t; t = TREE_CHAIN (t))
    5014          428 :         ++nargs;
    5015              : 
    5016          188 :       auto_diagnostic_group d;
    5017          188 :       if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    5018              :                       "too few arguments to built-in function %qE "
    5019              :                       "expecting %u", function, nargs - 1))
    5020          173 :         inform_declaration (fundecl, function);
    5021          188 :     }
    5022              : 
    5023     49919394 :   return error_args ? -1 : (int) parmnum;
    5024              : }
    5025              : 
    5026              : /* This is the entry point used by the parser to build unary operators
    5027              :    in the input.  CODE, a tree_code, specifies the unary operator, and
    5028              :    ARG is the operand.  For unary plus, the C parser currently uses
    5029              :    CONVERT_EXPR for code.
    5030              : 
    5031              :    LOC is the location to use for the tree generated.
    5032              : */
    5033              : 
    5034              : struct c_expr
    5035      8170553 : parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg)
    5036              : {
    5037      8170553 :   struct c_expr result;
    5038              : 
    5039      8170553 :   result.original_code = code;
    5040      8170553 :   result.original_type = NULL;
    5041      8170553 :   result.m_decimal = 0;
    5042              : 
    5043      8170553 :   if (reject_gcc_builtin (arg.value))
    5044              :     {
    5045            2 :       result.value = error_mark_node;
    5046              :     }
    5047              :   else
    5048              :     {
    5049      8170551 :       result.value = build_unary_op (loc, code, arg.value, false);
    5050              : 
    5051      8170551 :       if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value))
    5052            5 :         overflow_warning (loc, result.value, arg.value);
    5053              :     }
    5054              : 
    5055              :   /* We are typically called when parsing a prefix token at LOC acting on
    5056              :      ARG.  Reflect this by updating the source range of the result to
    5057              :      start at LOC and end at the end of ARG.  */
    5058      8170553 :   set_c_expr_source_range (&result,
    5059              :                            loc, arg.get_finish ());
    5060              : 
    5061      8170553 :   return result;
    5062              : }
    5063              : 
    5064              : /* Returns true if TYPE is a character type, *not* including wchar_t.  */
    5065              : 
    5066              : bool
    5067      1268821 : char_type_p (tree type)
    5068              : {
    5069      1268821 :   return (type == char_type_node
    5070       978128 :           || type == unsigned_char_type_node
    5071       959064 :           || type == signed_char_type_node
    5072       958216 :           || type == char16_type_node
    5073      2006537 :           || type == char32_type_node);
    5074              : }
    5075              : 
    5076              : /* This is the entry point used by the parser to build binary operators
    5077              :    in the input.  CODE, a tree_code, specifies the binary operator, and
    5078              :    ARG1 and ARG2 are the operands.  In addition to constructing the
    5079              :    expression, we check for operands that were written with other binary
    5080              :    operators in a way that is likely to confuse the user.  ORIG_ARG1 is
    5081              :    the original first operand for TRUTH_{AND,OR}IF_EXPR before it is
    5082              :    converted to truth value, otherwise NULL_TREE.
    5083              : 
    5084              :    LOCATION is the location of the binary operator.  */
    5085              : 
    5086              : struct c_expr
    5087      9336818 : parser_build_binary_op (location_t location, enum tree_code code,
    5088              :                         struct c_expr arg1, struct c_expr arg2, tree orig_arg1)
    5089              : {
    5090      9336818 :   struct c_expr result;
    5091      9336818 :   result.m_decimal = 0;
    5092              : 
    5093      9336818 :   enum tree_code code1 = arg1.original_code;
    5094      9336818 :   enum tree_code code2 = arg2.original_code;
    5095      9336818 :   tree type1 = (arg1.original_type
    5096      9336818 :                 ? arg1.original_type
    5097      5993399 :                 : TREE_TYPE (arg1.value));
    5098      9336818 :   tree type2 = (arg2.original_type
    5099      9336818 :                 ? arg2.original_type
    5100      6890183 :                 : TREE_TYPE (arg2.value));
    5101              : 
    5102      9336818 :   result.value = build_binary_op (location, code,
    5103              :                                   arg1.value, arg2.value, true);
    5104      9336817 :   result.original_code = code;
    5105      9336817 :   result.original_type = NULL;
    5106      9336817 :   result.m_decimal = 0;
    5107              : 
    5108      9336817 :   if (TREE_CODE (result.value) == ERROR_MARK)
    5109              :     {
    5110         1297 :       set_c_expr_source_range (&result,
    5111              :                                arg1.get_start (),
    5112              :                                arg2.get_finish ());
    5113         1297 :       return result;
    5114              :     }
    5115              : 
    5116      9335520 :   if (location != UNKNOWN_LOCATION)
    5117      9335520 :     protected_set_expr_location (result.value, location);
    5118              : 
    5119      9335520 :   set_c_expr_source_range (&result,
    5120              :                            arg1.get_start (),
    5121              :                            arg2.get_finish ());
    5122              : 
    5123              :   /* Check for cases such as x+y<<z which users are likely
    5124              :      to misinterpret.  */
    5125      9335520 :   if (warn_parentheses)
    5126      2009470 :     warn_about_parentheses (location, code, code1, arg1.value, code2,
    5127              :                             arg2.value);
    5128              : 
    5129      9335520 :   if (warn_logical_op)
    5130          340 :     warn_logical_operator (location, code, TREE_TYPE (result.value),
    5131              :                            code1, arg1.value, code2, arg2.value);
    5132              : 
    5133      9335520 :   if (warn_constant_logical_operand
    5134      2007885 :       && (code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR)
    5135        74290 :       && INTEGRAL_NB_TYPE_P (type1)
    5136        72520 :       && INTEGRAL_NB_TYPE_P (type2))
    5137              :     {
    5138        70955 :       const char *name = code == TRUTH_ANDIF_EXPR ? "&&" : "||";
    5139        70955 :       if (orig_arg1 == NULL_TREE)
    5140            0 :         orig_arg1 = arg1.value;
    5141        76352 :       auto enum_other_than_0_1 = [] (tree type) {
    5142         5397 :         if (TREE_CODE (type) != ENUMERAL_TYPE)
    5143              :           return false;
    5144           48 :         for (tree l = TYPE_VALUES (type); l; l = TREE_CHAIN (l))
    5145              :           {
    5146           40 :             tree v = DECL_INITIAL (TREE_VALUE (l));
    5147           40 :             if (!integer_zerop (v) && !integer_onep (v))
    5148              :               return true;
    5149              :           }
    5150              :         return false;
    5151              :       };
    5152       212849 :       auto diagnose_constant_logical_operand = [=] (tree val, tree type) {
    5153       141894 :         if (TREE_CODE (val) != INTEGER_CST || integer_zerop (val))
    5154       136473 :           return false;
    5155         5421 :         if (integer_onep (val) && !enum_other_than_0_1 (type))
    5156              :           return false;
    5157           32 :         gcc_rich_location richloc (location);
    5158           32 :         richloc.add_fixit_replace (name + 1);
    5159           32 :         auto_diagnostic_group d;
    5160           32 :         if (warning_at (location, OPT_Wconstant_logical_operand,
    5161              :                         "use of logical %qs with constant operand %qE",
    5162              :                         name, val))
    5163           32 :           inform (&richloc, "use %qs for bitwise operation", name + 1);
    5164           32 :         return true;
    5165           32 :       };
    5166        70955 :       if (!diagnose_constant_logical_operand (arg2.value, type2))
    5167        70939 :         diagnose_constant_logical_operand (orig_arg1, type1);
    5168              :     }
    5169              : 
    5170      9335520 :   if (warn_tautological_compare)
    5171              :     {
    5172      2007983 :       tree lhs = arg1.value;
    5173      2007983 :       tree rhs = arg2.value;
    5174      2007983 :       if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    5175              :         {
    5176            2 :           if (C_MAYBE_CONST_EXPR_PRE (lhs) != NULL_TREE
    5177            2 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (lhs)))
    5178              :             lhs = NULL_TREE;
    5179              :           else
    5180            2 :             lhs = C_MAYBE_CONST_EXPR_EXPR (lhs);
    5181              :         }
    5182      2007983 :       if (TREE_CODE (rhs) == C_MAYBE_CONST_EXPR)
    5183              :         {
    5184           12 :           if (C_MAYBE_CONST_EXPR_PRE (rhs) != NULL_TREE
    5185           12 :               && TREE_SIDE_EFFECTS (C_MAYBE_CONST_EXPR_PRE (rhs)))
    5186              :             rhs = NULL_TREE;
    5187              :           else
    5188           12 :             rhs = C_MAYBE_CONST_EXPR_EXPR (rhs);
    5189              :         }
    5190      2007983 :       if (lhs != NULL_TREE && rhs != NULL_TREE)
    5191      2007983 :         warn_tautological_cmp (location, code, lhs, rhs);
    5192              :     }
    5193              : 
    5194      9335520 :   if (warn_logical_not_paren
    5195      2008066 :       && TREE_CODE_CLASS (code) == tcc_comparison
    5196       409380 :       && code1 == TRUTH_NOT_EXPR
    5197       409380 :       && code2 != TRUTH_NOT_EXPR
    5198              :       /* Avoid warning for !!x == y.  */
    5199      9335654 :       && (TREE_CODE (arg1.value) != NE_EXPR
    5200           27 :           || !integer_zerop (TREE_OPERAND (arg1.value, 1))))
    5201              :     {
    5202              :       /* Avoid warning for !b == y where b has _Bool type.  */
    5203          107 :       tree t = integer_zero_node;
    5204          107 :       if (TREE_CODE (arg1.value) == EQ_EXPR
    5205           98 :           && integer_zerop (TREE_OPERAND (arg1.value, 1))
    5206          205 :           && TREE_TYPE (TREE_OPERAND (arg1.value, 0)) == integer_type_node)
    5207              :         {
    5208           90 :           t = TREE_OPERAND (arg1.value, 0);
    5209          199 :           do
    5210              :             {
    5211          199 :               if (TREE_TYPE (t) != integer_type_node)
    5212              :                 break;
    5213          180 :               if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
    5214           90 :                 t = C_MAYBE_CONST_EXPR_EXPR (t);
    5215           90 :               else if (CONVERT_EXPR_P (t))
    5216           19 :                 t = TREE_OPERAND (t, 0);
    5217              :               else
    5218              :                 break;
    5219              :             }
    5220              :           while (1);
    5221              :         }
    5222          107 :       if (!C_BOOLEAN_TYPE_P (TREE_TYPE (t)))
    5223           88 :         warn_logical_not_parentheses (location, code, arg1.value, arg2.value);
    5224              :     }
    5225              : 
    5226              :   /* Warn about comparisons against string literals, with the exception
    5227              :      of testing for equality or inequality of a string literal with NULL.  */
    5228      9335520 :   if (code == EQ_EXPR || code == NE_EXPR)
    5229              :     {
    5230      1171063 :       if ((code1 == STRING_CST
    5231           16 :            && !integer_zerop (tree_strip_nop_conversions (arg2.value)))
    5232      1171074 :           || (code2 == STRING_CST
    5233           39 :               && !integer_zerop (tree_strip_nop_conversions (arg1.value))))
    5234           36 :         warning_at (location, OPT_Waddress,
    5235              :                     "comparison with string literal results in unspecified behavior");
    5236              :       /* Warn for ptr == '\0', it's likely that it should've been ptr[0].  */
    5237      1171063 :       if (POINTER_TYPE_P (type1)
    5238        90693 :           && null_pointer_constant_p (arg2.value)
    5239      1192177 :           && char_type_p (type2))
    5240              :         {
    5241           18 :           auto_diagnostic_group d;
    5242           18 :           if (warning_at (location, OPT_Wpointer_compare,
    5243              :                             "comparison between pointer and zero character "
    5244              :                             "constant"))
    5245           10 :             inform (arg1.get_start (),
    5246              :                       "did you mean to dereference the pointer?");
    5247           18 :         }
    5248      1171045 :       else if (POINTER_TYPE_P (type2)
    5249        88007 :                && null_pointer_constant_p (arg1.value)
    5250      1171315 :                && char_type_p (type1))
    5251              :         {
    5252           10 :           auto_diagnostic_group d;
    5253           10 :           if (warning_at (location, OPT_Wpointer_compare,
    5254              :                             "comparison between pointer and zero character "
    5255              :                             "constant"))
    5256           10 :             inform (arg2.get_start (),
    5257              :                       "did you mean to dereference the pointer?");
    5258           10 :         }
    5259              :     }
    5260      8164457 :   else if (TREE_CODE_CLASS (code) == tcc_comparison
    5261       997752 :            && (code1 == STRING_CST || code2 == STRING_CST))
    5262            0 :     warning_at (location, OPT_Waddress,
    5263              :                 "comparison with string literal results in unspecified "
    5264              :                 "behavior");
    5265              : 
    5266      9335520 :   if (warn_zero_as_null_pointer_constant
    5267           24 :       && c_inhibit_evaluation_warnings == 0
    5268           24 :       && TREE_CODE_CLASS (code) == tcc_comparison)
    5269              :     {
    5270           24 :       if ((TREE_CODE (type1) == POINTER_TYPE
    5271           17 :            || TREE_CODE (type1) == NULLPTR_TYPE)
    5272            9 :           && INTEGRAL_TYPE_P (type2)
    5273           33 :           && null_pointer_constant_p (arg2.value))
    5274            9 :         warning_at (arg2.get_location(), OPT_Wzero_as_null_pointer_constant,
    5275              :                     "zero as null pointer constant");
    5276              : 
    5277           24 :       if ((TREE_CODE (type2) == POINTER_TYPE
    5278           15 :            || TREE_CODE (type2) == NULLPTR_TYPE)
    5279           11 :           && INTEGRAL_TYPE_P (type1)
    5280           35 :           && null_pointer_constant_p (arg1.value))
    5281           11 :         warning_at (arg1.get_location(), OPT_Wzero_as_null_pointer_constant,
    5282              :                     "zero as null pointer constant");
    5283              :     }
    5284              : 
    5285      9335520 :   if (warn_array_compare
    5286      2007821 :       && TREE_CODE_CLASS (code) == tcc_comparison
    5287       409165 :       && TREE_CODE (type1) == ARRAY_TYPE
    5288           38 :       && TREE_CODE (type2) == ARRAY_TYPE)
    5289           15 :     do_warn_array_compare (location, code, arg1.value, arg2.value);
    5290              : 
    5291      2182833 :   if (TREE_OVERFLOW_P (result.value)
    5292          299 :       && !TREE_OVERFLOW_P (arg1.value)
    5293      9335812 :       && !TREE_OVERFLOW_P (arg2.value))
    5294          249 :     overflow_warning (location, result.value);
    5295              : 
    5296              :   /* Warn about comparisons of different enum types.  */
    5297      9335519 :   if (warn_enum_compare
    5298      2027873 :       && TREE_CODE_CLASS (code) == tcc_comparison
    5299       413636 :       && TREE_CODE (type1) == ENUMERAL_TYPE
    5300         7169 :       && TREE_CODE (type2) == ENUMERAL_TYPE
    5301      9342624 :       && TYPE_MAIN_VARIANT (type1) != TYPE_MAIN_VARIANT (type2))
    5302            2 :     warning_at (location, OPT_Wenum_compare,
    5303              :                 "comparison between %qT and %qT",
    5304              :                 type1, type2);
    5305              : 
    5306      9335519 :   if (warn_xor_used_as_pow
    5307      9335519 :       && code == BIT_XOR_EXPR
    5308        77180 :       && arg1.m_decimal
    5309          730 :       && arg2.m_decimal)
    5310          427 :     check_for_xor_used_as_pow (arg1.get_location (), arg1.value,
    5311              :                                location,
    5312              :                                arg2.get_location (), arg2.value);
    5313              : 
    5314              :   return result;
    5315              : }
    5316              : 
    5317              : /* Return a tree for the difference of pointers OP0 and OP1.
    5318              :    The resulting tree has type ptrdiff_t.  If POINTER_SUBTRACT sanitization is
    5319              :    enabled, assign to INSTRUMENT_EXPR call to libsanitizer.  */
    5320              : 
    5321              : static tree
    5322         3709 : pointer_diff (location_t loc, tree op0, tree op1, tree *instrument_expr)
    5323              : {
    5324         3709 :   tree restype = ptrdiff_type_node;
    5325         3709 :   tree result, inttype;
    5326              : 
    5327         3709 :   addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op0)));
    5328         3709 :   addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (op1)));
    5329         3709 :   tree target_type = TREE_TYPE (TREE_TYPE (op0));
    5330         3709 :   tree orig_op0 = op0;
    5331         3709 :   tree orig_op1 = op1;
    5332              : 
    5333              :   /* If the operands point into different address spaces, we need to
    5334              :      explicitly convert them to pointers into the common address space
    5335              :      before we can subtract the numerical address values.  */
    5336         3709 :   if (as0 != as1)
    5337              :     {
    5338            0 :       addr_space_t as_common;
    5339            0 :       tree common_type;
    5340              : 
    5341              :       /* Determine the common superset address space.  This is guaranteed
    5342              :          to exist because the caller verified that comp_target_types
    5343              :          returned non-zero.  */
    5344            0 :       if (!addr_space_superset (as0, as1, &as_common))
    5345            0 :         gcc_unreachable ();
    5346              : 
    5347            0 :       common_type = common_pointer_type (TREE_TYPE (op0), TREE_TYPE (op1), NULL_TREE);
    5348            0 :       op0 = convert (common_type, op0);
    5349            0 :       op1 = convert (common_type, op1);
    5350              :     }
    5351              : 
    5352              :   /* Determine integer type result of the subtraction.  This will usually
    5353              :      be the same as the result type (ptrdiff_t), but may need to be a wider
    5354              :      type if pointers for the address space are wider than ptrdiff_t.  */
    5355         3709 :   if (TYPE_PRECISION (restype) < TYPE_PRECISION (TREE_TYPE (op0)))
    5356            0 :     inttype = c_common_type_for_size (TYPE_PRECISION (TREE_TYPE (op0)), 0);
    5357              :   else
    5358              :     inttype = restype;
    5359              : 
    5360         3709 :   if (VOID_TYPE_P (target_type))
    5361          146 :     pedwarn (loc, OPT_Wpointer_arith,
    5362              :              "pointer of type %<void *%> used in subtraction");
    5363         3709 :   if (TREE_CODE (target_type) == FUNCTION_TYPE)
    5364            4 :     pedwarn (loc, OPT_Wpointer_arith,
    5365              :              "pointer to a function used in subtraction");
    5366              : 
    5367         3709 :   if (current_function_decl != NULL_TREE
    5368         3709 :       && sanitize_flags_p (SANITIZE_POINTER_SUBTRACT))
    5369              :     {
    5370           70 :       op0 = save_expr (c_fully_fold (op0, false, NULL));
    5371           70 :       op1 = save_expr (c_fully_fold (op1, false, NULL));
    5372              : 
    5373           70 :       tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_SUBTRACT);
    5374           70 :       *instrument_expr = build_call_expr_loc (loc, tt, 2, op0, op1);
    5375              :     }
    5376              : 
    5377              :   /* First do the subtraction, then build the divide operator
    5378              :      and only convert at the very end.
    5379              :      Do not do default conversions in case restype is a short type.  */
    5380              : 
    5381              :   /* POINTER_DIFF_EXPR requires a signed integer type of the same size as
    5382              :      pointers.  If some platform cannot provide that, or has a larger
    5383              :      ptrdiff_type to support differences larger than half the address
    5384              :      space, cast the pointers to some larger integer type and do the
    5385              :      computations in that type.  */
    5386         3709 :   if (TYPE_PRECISION (inttype) > TYPE_PRECISION (TREE_TYPE (op0)))
    5387            0 :     op0 = build_binary_op (loc, MINUS_EXPR, convert (inttype, op0),
    5388              :                            convert (inttype, op1), false);
    5389              :   else
    5390              :     {
    5391              :       /* Cast away qualifiers.  */
    5392         3709 :       op0 = convert (c_common_type (TREE_TYPE (op0), TREE_TYPE (op0)), op0);
    5393         3709 :       op1 = convert (c_common_type (TREE_TYPE (op1), TREE_TYPE (op1)), op1);
    5394         3709 :       op0 = build2_loc (loc, POINTER_DIFF_EXPR, inttype, op0, op1);
    5395              :     }
    5396              : 
    5397              :   /* This generates an error if op1 is pointer to incomplete type.  */
    5398         3709 :   if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1))))
    5399            4 :     error_at (loc, "arithmetic on pointer to an incomplete type");
    5400         3705 :   else if (verify_type_context (loc, TCTX_POINTER_ARITH,
    5401         3705 :                                 TREE_TYPE (TREE_TYPE (orig_op0))))
    5402         7410 :     verify_type_context (loc, TCTX_POINTER_ARITH,
    5403         3705 :                          TREE_TYPE (TREE_TYPE (orig_op1)));
    5404              : 
    5405         3709 :   op1 = c_size_in_bytes (target_type);
    5406              : 
    5407         3709 :   if (pointer_to_zero_sized_aggr_p (TREE_TYPE (orig_op1)))
    5408            4 :     error_at (loc, "arithmetic on pointer to an empty aggregate");
    5409              : 
    5410              :   /* Divide by the size, in easiest possible way.  */
    5411         3709 :   result = fold_build2_loc (loc, EXACT_DIV_EXPR, inttype,
    5412              :                             op0, convert (inttype, op1));
    5413              : 
    5414              :   /* Convert to final result type if necessary.  */
    5415         3709 :   return convert (restype, result);
    5416              : }
    5417              : 
    5418              : /* Expand atomic compound assignments into an appropriate sequence as
    5419              :    specified by the C11 standard section 6.5.16.2.
    5420              : 
    5421              :        _Atomic T1 E1
    5422              :        T2 E2
    5423              :        E1 op= E2
    5424              : 
    5425              :   This sequence is used for all types for which these operations are
    5426              :   supported.
    5427              : 
    5428              :   In addition, built-in versions of the 'fe' prefixed routines may
    5429              :   need to be invoked for floating point (real, complex or vector) when
    5430              :   floating-point exceptions are supported.  See 6.5.16.2 footnote 113.
    5431              : 
    5432              :   T1 newval;
    5433              :   T1 old;
    5434              :   T1 *addr
    5435              :   T2 val
    5436              :   fenv_t fenv
    5437              : 
    5438              :   addr = &E1;
    5439              :   val = (E2);
    5440              :   __atomic_load (addr, &old, SEQ_CST);
    5441              :   feholdexcept (&fenv);
    5442              : loop:
    5443              :     newval = old op val;
    5444              :     if (__atomic_compare_exchange_strong (addr, &old, &newval, SEQ_CST,
    5445              :                                           SEQ_CST))
    5446              :       goto done;
    5447              :     feclearexcept (FE_ALL_EXCEPT);
    5448              :     goto loop:
    5449              : done:
    5450              :   feupdateenv (&fenv);
    5451              : 
    5452              :   The compiler will issue the __atomic_fetch_* built-in when possible,
    5453              :   otherwise it will generate the generic form of the atomic operations.
    5454              :   This requires temp(s) and has their address taken.  The atomic processing
    5455              :   is smart enough to figure out when the size of an object can utilize
    5456              :   a lock-free version, and convert the built-in call to the appropriate
    5457              :   lock-free routine.  The optimizers will then dispose of any temps that
    5458              :   are no longer required, and lock-free implementations are utilized as
    5459              :   long as there is target support for the required size.
    5460              : 
    5461              :   If the operator is NOP_EXPR, then this is a simple assignment, and
    5462              :   an __atomic_store is issued to perform the assignment rather than
    5463              :   the above loop.  */
    5464              : 
    5465              : /* Build an atomic assignment at LOC, expanding into the proper
    5466              :    sequence to store LHS MODIFYCODE= RHS.  Return a value representing
    5467              :    the result of the operation, unless RETURN_OLD_P, in which case
    5468              :    return the old value of LHS (this is only for postincrement and
    5469              :    postdecrement).  */
    5470              : 
    5471              : static tree
    5472        30433 : build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode,
    5473              :                      tree rhs, bool return_old_p)
    5474              : {
    5475        30433 :   tree fndecl, func_call;
    5476        30433 :   vec<tree, va_gc> *params;
    5477        30433 :   tree val, nonatomic_lhs_type, nonatomic_rhs_type, newval, newval_addr;
    5478        30433 :   tree old, old_addr;
    5479        30433 :   tree compound_stmt = NULL_TREE;
    5480        30433 :   tree stmt, goto_stmt;
    5481        30433 :   tree loop_label, loop_decl, done_label, done_decl;
    5482              : 
    5483        30433 :   tree lhs_type = TREE_TYPE (lhs);
    5484        30433 :   tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false);
    5485        30433 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
    5486        30433 :   tree rhs_semantic_type = TREE_TYPE (rhs);
    5487        30433 :   tree nonatomic_rhs_semantic_type;
    5488        30433 :   tree rhs_type;
    5489              : 
    5490        30433 :   gcc_assert (TYPE_ATOMIC (lhs_type));
    5491              : 
    5492        30433 :   if (return_old_p)
    5493         2313 :     gcc_assert (modifycode == PLUS_EXPR || modifycode == MINUS_EXPR);
    5494              : 
    5495              :   /* Allocate enough vector items for a compare_exchange.  */
    5496        30433 :   vec_alloc (params, 6);
    5497              : 
    5498              :   /* Create a compound statement to hold the sequence of statements
    5499              :      with a loop.  */
    5500        30433 :   if (modifycode != NOP_EXPR)
    5501              :     {
    5502        19954 :       compound_stmt = c_begin_compound_stmt (false);
    5503              : 
    5504              :       /* For consistency with build_modify_expr on non-_Atomic,
    5505              :          mark the lhs as read.  Also, it would be very hard to match
    5506              :          such expressions in mark_exp_read.  */
    5507        19954 :       mark_exp_read (lhs);
    5508              :     }
    5509              : 
    5510              :   /* Remove any excess precision (which is only present here in the
    5511              :      case of compound assignments).  */
    5512        30433 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    5513              :     {
    5514            0 :       gcc_assert (modifycode != NOP_EXPR);
    5515            0 :       rhs = TREE_OPERAND (rhs, 0);
    5516              :     }
    5517        30433 :   rhs_type = TREE_TYPE (rhs);
    5518              : 
    5519              :   /* Fold the RHS if it hasn't already been folded.  */
    5520        30433 :   if (modifycode != NOP_EXPR)
    5521        19954 :     rhs = c_fully_fold (rhs, false, NULL);
    5522              : 
    5523              :   /* Remove the qualifiers for the rest of the expressions and create
    5524              :      the VAL temp variable to hold the RHS.  */
    5525        30433 :   nonatomic_lhs_type = build_qualified_type (lhs_type, TYPE_UNQUALIFIED);
    5526        30433 :   nonatomic_rhs_type = build_qualified_type (rhs_type, TYPE_UNQUALIFIED);
    5527        30433 :   nonatomic_rhs_semantic_type = build_qualified_type (rhs_semantic_type,
    5528              :                                                       TYPE_UNQUALIFIED);
    5529        30433 :   val = create_tmp_var_raw (nonatomic_rhs_type);
    5530        30433 :   TREE_ADDRESSABLE (val) = 1;
    5531        30433 :   suppress_warning (val);
    5532        30433 :   rhs = build4 (TARGET_EXPR, nonatomic_rhs_type, val, rhs, NULL_TREE,
    5533              :                 NULL_TREE);
    5534        30433 :   TREE_SIDE_EFFECTS (rhs) = 1;
    5535        30433 :   SET_EXPR_LOCATION (rhs, loc);
    5536        30433 :   if (modifycode != NOP_EXPR)
    5537        19954 :     add_stmt (rhs);
    5538              : 
    5539              :   /* NOP_EXPR indicates it's a straight store of the RHS. Simply issue
    5540              :      an atomic_store.  */
    5541        30433 :   if (modifycode == NOP_EXPR)
    5542              :     {
    5543        10479 :       compound_stmt = rhs;
    5544              :       /* Build __atomic_store (&lhs, &val, SEQ_CST)  */
    5545        10479 :       rhs = build_unary_op (loc, ADDR_EXPR, val, false);
    5546        10479 :       fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
    5547        10479 :       params->quick_push (lhs_addr);
    5548        10479 :       params->quick_push (rhs);
    5549        10479 :       params->quick_push (seq_cst);
    5550        10479 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5551              : 
    5552        10479 :       compound_stmt = build2 (COMPOUND_EXPR, void_type_node,
    5553              :                               compound_stmt, func_call);
    5554              : 
    5555              :       /* VAL is the value which was stored, return a COMPOUND_STMT of
    5556              :          the statement and that value.  */
    5557        10479 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, val);
    5558              :     }
    5559              : 
    5560              :   /* Attempt to implement the atomic operation as an __atomic_fetch_* or
    5561              :      __atomic_*_fetch built-in rather than a CAS loop.  atomic_bool type
    5562              :      isn't applicable for such builtins.  ??? Do we want to handle enums?  */
    5563        19954 :   if ((TREE_CODE (lhs_type) == INTEGER_TYPE || POINTER_TYPE_P (lhs_type))
    5564        13941 :       && TREE_CODE (rhs_type) == INTEGER_TYPE)
    5565              :     {
    5566        11713 :       built_in_function fncode;
    5567        11713 :       switch (modifycode)
    5568              :         {
    5569         3075 :         case PLUS_EXPR:
    5570         3075 :         case POINTER_PLUS_EXPR:
    5571         2124 :           fncode = (return_old_p
    5572         3075 :                     ? BUILT_IN_ATOMIC_FETCH_ADD_N
    5573              :                     : BUILT_IN_ATOMIC_ADD_FETCH_N);
    5574              :           break;
    5575         2889 :         case MINUS_EXPR:
    5576         2094 :           fncode = (return_old_p
    5577         2889 :                     ? BUILT_IN_ATOMIC_FETCH_SUB_N
    5578              :                     : BUILT_IN_ATOMIC_SUB_FETCH_N);
    5579              :           break;
    5580          609 :         case BIT_AND_EXPR:
    5581          609 :           fncode = (return_old_p
    5582          609 :                     ? BUILT_IN_ATOMIC_FETCH_AND_N
    5583              :                     : BUILT_IN_ATOMIC_AND_FETCH_N);
    5584              :           break;
    5585          609 :         case BIT_IOR_EXPR:
    5586          609 :           fncode = (return_old_p
    5587          609 :                     ? BUILT_IN_ATOMIC_FETCH_OR_N
    5588              :                     : BUILT_IN_ATOMIC_OR_FETCH_N);
    5589              :           break;
    5590          609 :         case BIT_XOR_EXPR:
    5591          609 :           fncode = (return_old_p
    5592          609 :                     ? BUILT_IN_ATOMIC_FETCH_XOR_N
    5593              :                     : BUILT_IN_ATOMIC_XOR_FETCH_N);
    5594              :           break;
    5595         3922 :         default:
    5596         3922 :           goto cas_loop;
    5597              :         }
    5598              : 
    5599              :       /* We can only use "_1" through "_16" variants of the atomic fetch
    5600              :          built-ins.  */
    5601         7791 :       unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE_UNIT (lhs_type));
    5602         7791 :       if (size != 1 && size != 2 && size != 4 && size != 8 && size != 16)
    5603            0 :         goto cas_loop;
    5604              : 
    5605              :       /* If this is a pointer type, we need to multiply by the size of
    5606              :          the pointer target type.  */
    5607         7791 :       if (POINTER_TYPE_P (lhs_type))
    5608              :         {
    5609         1018 :           if (!COMPLETE_TYPE_P (TREE_TYPE (lhs_type))
    5610              :               /* ??? This would introduce -Wdiscarded-qualifiers
    5611              :                  warning: __atomic_fetch_* expect volatile void *
    5612              :                  type as the first argument.  (Assignments between
    5613              :                  atomic and non-atomic objects are OK.) */
    5614         1018 :               || TYPE_RESTRICT (lhs_type))
    5615           17 :             goto cas_loop;
    5616         1001 :           tree sz = TYPE_SIZE_UNIT (TREE_TYPE (lhs_type));
    5617         1001 :           rhs = fold_build2_loc (loc, MULT_EXPR, ptrdiff_type_node,
    5618              :                                  convert (ptrdiff_type_node, rhs),
    5619              :                                  convert (ptrdiff_type_node, sz));
    5620              :         }
    5621              : 
    5622              :       /* Build __atomic_fetch_* (&lhs, &val, SEQ_CST), or
    5623              :          __atomic_*_fetch (&lhs, &val, SEQ_CST).  */
    5624         7774 :       fndecl = builtin_decl_explicit (fncode);
    5625         7774 :       params->quick_push (lhs_addr);
    5626         7774 :       params->quick_push (rhs);
    5627         7774 :       params->quick_push (seq_cst);
    5628         7774 :       func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5629              : 
    5630         7774 :       newval = create_tmp_var_raw (nonatomic_lhs_type);
    5631         7774 :       TREE_ADDRESSABLE (newval) = 1;
    5632         7774 :       suppress_warning (newval);
    5633         7774 :       rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, func_call,
    5634              :                     NULL_TREE, NULL_TREE);
    5635         7774 :       SET_EXPR_LOCATION (rhs, loc);
    5636         7774 :       add_stmt (rhs);
    5637              : 
    5638              :       /* Finish the compound statement.  */
    5639         7774 :       compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    5640              : 
    5641              :       /* NEWVAL is the value which was stored, return a COMPOUND_STMT of
    5642              :          the statement and that value.  */
    5643         7774 :       return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt, newval);
    5644              :     }
    5645              : 
    5646         8241 : cas_loop:
    5647              :   /* Create the variables and labels required for the op= form.  */
    5648        12180 :   old = create_tmp_var_raw (nonatomic_lhs_type);
    5649        12180 :   old_addr = build_unary_op (loc, ADDR_EXPR, old, false);
    5650        12180 :   TREE_ADDRESSABLE (old) = 1;
    5651        12180 :   suppress_warning (old);
    5652              : 
    5653        12180 :   newval = create_tmp_var_raw (nonatomic_lhs_type);
    5654        12180 :   newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false);
    5655        12180 :   TREE_ADDRESSABLE (newval) = 1;
    5656        12180 :   suppress_warning (newval);
    5657              : 
    5658        12180 :   loop_decl = create_artificial_label (loc);
    5659        12180 :   loop_label = build1 (LABEL_EXPR, void_type_node, loop_decl);
    5660              : 
    5661        12180 :   done_decl = create_artificial_label (loc);
    5662        12180 :   done_label = build1 (LABEL_EXPR, void_type_node, done_decl);
    5663              : 
    5664              :   /* __atomic_load (addr, &old, SEQ_CST).  */
    5665        12180 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
    5666        12180 :   params->quick_push (lhs_addr);
    5667        12180 :   params->quick_push (old_addr);
    5668        12180 :   params->quick_push (seq_cst);
    5669        12180 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5670        12180 :   old = build4 (TARGET_EXPR, nonatomic_lhs_type, old, func_call, NULL_TREE,
    5671              :                 NULL_TREE);
    5672        12180 :   add_stmt (old);
    5673        12180 :   params->truncate (0);
    5674              : 
    5675              :   /* Create the expressions for floating-point environment
    5676              :      manipulation, if required.  */
    5677        12180 :   bool need_fenv = (flag_trapping_math
    5678        12180 :                     && (FLOAT_TYPE_P (lhs_type) || FLOAT_TYPE_P (rhs_type)));
    5679        12180 :   tree hold_call = NULL_TREE, clear_call = NULL_TREE, update_call = NULL_TREE;
    5680        12180 :   if (need_fenv)
    5681         7054 :     targetm.atomic_assign_expand_fenv (&hold_call, &clear_call, &update_call);
    5682              : 
    5683        12180 :   if (hold_call)
    5684         7054 :     add_stmt (hold_call);
    5685              : 
    5686              :   /* loop:  */
    5687        12180 :   add_stmt (loop_label);
    5688              : 
    5689              :   /* newval = old + val;  */
    5690        12180 :   if (rhs_type != rhs_semantic_type)
    5691            0 :     val = build1 (EXCESS_PRECISION_EXPR, nonatomic_rhs_semantic_type, val);
    5692        12180 :   rhs = build_binary_op (loc, modifycode,
    5693              :                          convert_lvalue_to_rvalue (loc, old, true, true),
    5694              :                          val, true);
    5695        12180 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    5696              :     {
    5697            0 :       tree eptype = TREE_TYPE (rhs);
    5698            0 :       rhs = c_fully_fold (TREE_OPERAND (rhs, 0), false, NULL);
    5699            0 :       rhs = build1 (EXCESS_PRECISION_EXPR, eptype, rhs);
    5700              :     }
    5701              :   else
    5702        12180 :     rhs = c_fully_fold (rhs, false, NULL);
    5703        12180 :   rhs = convert_for_assignment (loc, UNKNOWN_LOCATION, nonatomic_lhs_type,
    5704              :                                 rhs, NULL_TREE, ic_assign, false, NULL_TREE,
    5705              :                                 NULL_TREE, 0);
    5706              :   /* The temporary variable for NEWVAL is only gimplified correctly (in
    5707              :      particular, given a DECL_CONTEXT) if used in a TARGET_EXPR.  To avoid
    5708              :      subsequent ICEs in nested function processing after an error, ensure such
    5709              :      a TARGET_EXPR is built even after an error.  */
    5710        12180 :   if (rhs == error_mark_node)
    5711           10 :     rhs = old;
    5712        12180 :   rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, rhs, NULL_TREE,
    5713              :                 NULL_TREE);
    5714        12180 :   SET_EXPR_LOCATION (rhs, loc);
    5715        12180 :   add_stmt (rhs);
    5716              : 
    5717              :   /* if (__atomic_compare_exchange (addr, &old, &new, false, SEQ_CST, SEQ_CST))
    5718              :        goto done;  */
    5719        12180 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_COMPARE_EXCHANGE);
    5720        12180 :   params->quick_push (lhs_addr);
    5721        12180 :   params->quick_push (old_addr);
    5722        12180 :   params->quick_push (newval_addr);
    5723        12180 :   params->quick_push (integer_zero_node);
    5724        12180 :   params->quick_push (seq_cst);
    5725        12180 :   params->quick_push (seq_cst);
    5726        12180 :   func_call = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
    5727              : 
    5728        12180 :   goto_stmt = build1 (GOTO_EXPR, void_type_node, done_decl);
    5729        12180 :   SET_EXPR_LOCATION (goto_stmt, loc);
    5730              : 
    5731        12180 :   stmt = build3 (COND_EXPR, void_type_node, func_call, goto_stmt, NULL_TREE);
    5732        12180 :   SET_EXPR_LOCATION (stmt, loc);
    5733        12180 :   add_stmt (stmt);
    5734              : 
    5735        12180 :   if (clear_call)
    5736         7054 :     add_stmt (clear_call);
    5737              : 
    5738              :   /* goto loop;  */
    5739        12180 :   goto_stmt  = build1 (GOTO_EXPR, void_type_node, loop_decl);
    5740        12180 :   SET_EXPR_LOCATION (goto_stmt, loc);
    5741        12180 :   add_stmt (goto_stmt);
    5742              : 
    5743              :   /* done:  */
    5744        12180 :   add_stmt (done_label);
    5745              : 
    5746        12180 :   if (update_call)
    5747         7054 :     add_stmt (update_call);
    5748              : 
    5749              :   /* Finish the compound statement.  */
    5750        12180 :   compound_stmt = c_end_compound_stmt (loc, compound_stmt, false);
    5751              : 
    5752              :   /* NEWVAL is the value that was successfully stored, return a
    5753              :      COMPOUND_EXPR of the statement and the appropriate value.  */
    5754        23787 :   return build2 (COMPOUND_EXPR, nonatomic_lhs_type, compound_stmt,
    5755        12180 :                  return_old_p ? old : newval);
    5756              : }
    5757              : 
    5758              : /* Construct and perhaps optimize a tree representation
    5759              :    for a unary operation.  CODE, a tree_code, specifies the operation
    5760              :    and XARG is the operand.
    5761              :    For any CODE other than ADDR_EXPR, NOCONVERT suppresses the default
    5762              :    promotions (such as from short to int).
    5763              :    For ADDR_EXPR, the default promotions are not applied; NOCONVERT allows
    5764              :    non-lvalues; this is only used to handle conversion of non-lvalue arrays
    5765              :    to pointers in C99.
    5766              : 
    5767              :    LOCATION is the location of the operator.  */
    5768              : 
    5769              : tree
    5770     60555489 : build_unary_op (location_t location, enum tree_code code, tree xarg,
    5771              :                 bool noconvert)
    5772              : {
    5773              :   /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
    5774     60555489 :   tree arg = xarg;
    5775     60555489 :   tree argtype = NULL_TREE;
    5776     60555489 :   enum tree_code typecode;
    5777     60555489 :   tree val;
    5778     60555489 :   tree ret = error_mark_node;
    5779     60555489 :   tree eptype = NULL_TREE;
    5780     60555489 :   const char *invalid_op_diag;
    5781              : 
    5782     60555489 :   gcc_checking_assert (!is_access_with_size_p (arg));
    5783              : 
    5784     60555489 :   bool int_operands = EXPR_INT_CONST_OPERANDS (xarg);
    5785      6464746 :   if (int_operands)
    5786      6464746 :     arg = remove_c_maybe_const_expr (arg);
    5787              : 
    5788     60555489 :   if (code != ADDR_EXPR)
    5789      8542506 :     arg = require_complete_type (location, arg);
    5790              : 
    5791     60555489 :   typecode = TREE_CODE (TREE_TYPE (arg));
    5792     60555489 :   if (typecode == ERROR_MARK)
    5793           74 :     return error_mark_node;
    5794     60555415 :   if (typecode == ENUMERAL_TYPE || typecode == BOOLEAN_TYPE)
    5795        32260 :     typecode = INTEGER_TYPE;
    5796              : 
    5797    121110830 :   if ((invalid_op_diag
    5798     60555415 :        = targetm.invalid_unary_op (code, TREE_TYPE (xarg))))
    5799              :     {
    5800            0 :       error_at (location, invalid_op_diag);
    5801            0 :       return error_mark_node;
    5802              :     }
    5803              : 
    5804     60555415 :   if (TREE_CODE (arg) == EXCESS_PRECISION_EXPR)
    5805              :     {
    5806          245 :       eptype = TREE_TYPE (arg);
    5807          245 :       arg = TREE_OPERAND (arg, 0);
    5808              :     }
    5809              : 
    5810     60555415 :   switch (code)
    5811              :     {
    5812        28759 :     case CONVERT_EXPR:
    5813              :       /* This is used for unary plus, because a CONVERT_EXPR
    5814              :          is enough to prevent anybody from looking inside for
    5815              :          associativity, but won't generate any code.  */
    5816        28764 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5817           13 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    5818           10 :             || typecode == BITINT_TYPE
    5819            5 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    5820              :         {
    5821            1 :           error_at (location, "wrong type argument to unary plus");
    5822            1 :           return error_mark_node;
    5823              :         }
    5824        28758 :       else if (!noconvert)
    5825        28758 :         arg = default_conversion (arg);
    5826        28758 :       arg = non_lvalue_loc (location, arg);
    5827        28758 :       break;
    5828              : 
    5829      6701019 :     case NEGATE_EXPR:
    5830      7148515 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5831       484168 :             || typecode == FIXED_POINT_TYPE || typecode == COMPLEX_TYPE
    5832       452901 :             || typecode == BITINT_TYPE
    5833       447496 :             || gnu_vector_type_p (TREE_TYPE (arg))))
    5834              :         {
    5835            1 :           error_at (location, "wrong type argument to unary minus");
    5836            1 :           return error_mark_node;
    5837              :         }
    5838      6701018 :       else if (!noconvert)
    5839      6701012 :         arg = default_conversion (arg);
    5840              :       break;
    5841              : 
    5842       295412 :     case BIT_NOT_EXPR:
    5843              :       /* ~ works on integer types and non float vectors. */
    5844       295412 :       if (typecode == INTEGER_TYPE
    5845       295412 :           || typecode == BITINT_TYPE
    5846       295412 :           || (gnu_vector_type_p (TREE_TYPE (arg))
    5847         2059 :               && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (arg))))
    5848              :         {
    5849              :           tree e = arg;
    5850              : 
    5851              :           /* Warn if the expression has boolean value.  */
    5852       294813 :           while (TREE_CODE (e) == COMPOUND_EXPR)
    5853           11 :             e = TREE_OPERAND (e, 1);
    5854              : 
    5855       589588 :           if ((C_BOOLEAN_TYPE_P (TREE_TYPE (arg))
    5856       589588 :                || truth_value_p (TREE_CODE (e))))
    5857              :             {
    5858          148 :               auto_diagnostic_group d;
    5859          148 :               if (warning_at (location, OPT_Wbool_operation,
    5860              :                                 "%<~%> on a boolean expression"))
    5861              :                 {
    5862           12 :                   gcc_rich_location richloc (location);
    5863           12 :                   richloc.add_fixit_insert_before (location, "!");
    5864           12 :                   inform (&richloc, "did you mean to use logical not?");
    5865           12 :                 }
    5866          148 :             }
    5867       294802 :           if (!noconvert)
    5868       294799 :             arg = default_conversion (arg);
    5869              :         }
    5870          610 :       else if (typecode == COMPLEX_TYPE)
    5871              :         {
    5872          605 :           code = CONJ_EXPR;
    5873          605 :           pedwarn (location, OPT_Wpedantic,
    5874              :                    "ISO C does not support %<~%> for complex conjugation");
    5875          605 :           if (!noconvert)
    5876          605 :             arg = default_conversion (arg);
    5877              :         }
    5878              :       else
    5879              :         {
    5880            5 :           error_at (location, "wrong type argument to bit-complement");
    5881            5 :           return error_mark_node;
    5882              :         }
    5883              :       break;
    5884              : 
    5885            3 :     case ABS_EXPR:
    5886            3 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE))
    5887              :         {
    5888            0 :           error_at (location, "wrong type argument to abs");
    5889            0 :           return error_mark_node;
    5890              :         }
    5891            3 :       else if (!noconvert)
    5892            0 :         arg = default_conversion (arg);
    5893              :       break;
    5894              : 
    5895            7 :     case ABSU_EXPR:
    5896            7 :       if (!(typecode == INTEGER_TYPE))
    5897              :         {
    5898            0 :           error_at (location, "wrong type argument to absu");
    5899            0 :           return error_mark_node;
    5900              :         }
    5901            7 :       else if (!noconvert)
    5902            0 :         arg = default_conversion (arg);
    5903              :       break;
    5904              : 
    5905            0 :     case CONJ_EXPR:
    5906              :       /* Conjugating a real value is a no-op, but allow it anyway.  */
    5907            0 :       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
    5908              :             || typecode == COMPLEX_TYPE))
    5909              :         {
    5910            0 :           error_at (location, "wrong type argument to conjugation");
    5911            0 :           return error_mark_node;
    5912              :         }
    5913            0 :       else if (!noconvert)
    5914            0 :         arg = default_conversion (arg);
    5915              :       break;
    5916              : 
    5917       378344 :     case TRUTH_NOT_EXPR:
    5918       378344 :       if (typecode != INTEGER_TYPE && typecode != FIXED_POINT_TYPE
    5919         7145 :           && typecode != REAL_TYPE && typecode != POINTER_TYPE
    5920           21 :           && typecode != COMPLEX_TYPE && typecode != NULLPTR_TYPE
    5921           18 :           && typecode != BITINT_TYPE)
    5922              :         {
    5923           10 :           error_at (location,
    5924              :                     "wrong type argument to unary exclamation mark");
    5925           10 :           return error_mark_node;
    5926              :         }
    5927       378334 :       if (int_operands)
    5928              :         {
    5929       139865 :           arg = c_objc_common_truthvalue_conversion (location, xarg);
    5930       139865 :           arg = remove_c_maybe_const_expr (arg);
    5931              :         }
    5932              :       else
    5933       238469 :         arg = c_objc_common_truthvalue_conversion (location, arg);
    5934       378334 :       ret = invert_truthvalue_loc (location, arg);
    5935              :       /* If the TRUTH_NOT_EXPR has been folded, reset the location.  */
    5936       378334 :       if (EXPR_P (ret) && EXPR_HAS_LOCATION (ret))
    5937       238076 :         location = EXPR_LOCATION (ret);
    5938       378334 :       goto return_build_unary_op;
    5939              : 
    5940       203100 :     case REALPART_EXPR:
    5941       203100 :     case IMAGPART_EXPR:
    5942       203100 :       ret = build_real_imag_expr (location, code, arg);
    5943       203100 :       if (ret == error_mark_node)
    5944              :         return error_mark_node;
    5945       203092 :       if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE)
    5946            2 :         eptype = TREE_TYPE (eptype);
    5947       203092 :       goto return_build_unary_op;
    5948              : 
    5949       935819 :     case PREINCREMENT_EXPR:
    5950       935819 :     case POSTINCREMENT_EXPR:
    5951       935819 :     case PREDECREMENT_EXPR:
    5952       935819 :     case POSTDECREMENT_EXPR:
    5953              : 
    5954       935819 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    5955              :         {
    5956            2 :           tree inner = build_unary_op (location, code,
    5957            2 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    5958              :                                        noconvert);
    5959            2 :           if (inner == error_mark_node)
    5960              :             return error_mark_node;
    5961            4 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    5962            2 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    5963            2 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    5964            2 :           C_MAYBE_CONST_EXPR_NON_CONST (ret) = 1;
    5965            2 :           goto return_build_unary_op;
    5966              :         }
    5967              : 
    5968              :       /* Complain about anything that is not a true lvalue.  In
    5969              :          Objective-C, skip this check for property_refs.  */
    5970       935817 :       if (!objc_is_property_ref (arg)
    5971      1871634 :           && !lvalue_or_else (location,
    5972       935817 :                               arg, ((code == PREINCREMENT_EXPR
    5973       935817 :                                      || code == POSTINCREMENT_EXPR)
    5974              :                                     ? lv_increment
    5975              :                                     : lv_decrement)))
    5976           22 :         return error_mark_node;
    5977              : 
    5978       935795 :       if (warn_cxx_compat && TREE_CODE (TREE_TYPE (arg)) == ENUMERAL_TYPE)
    5979              :         {
    5980            4 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5981            2 :             warning_at (location, OPT_Wc___compat,
    5982              :                         "increment of enumeration value is invalid in C++");
    5983              :           else
    5984            2 :             warning_at (location, OPT_Wc___compat,
    5985              :                         "decrement of enumeration value is invalid in C++");
    5986              :         }
    5987              : 
    5988       935795 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    5989              :         {
    5990          664 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    5991          328 :             warning_at (location, OPT_Wbool_operation,
    5992              :                         "increment of a boolean expression");
    5993              :           else
    5994          336 :             warning_at (location, OPT_Wbool_operation,
    5995              :                         "decrement of a boolean expression");
    5996              :         }
    5997              : 
    5998              :       /* Ensure the argument is fully folded inside any SAVE_EXPR.  */
    5999       935795 :       arg = c_fully_fold (arg, false, NULL, true);
    6000              : 
    6001       935795 :       bool atomic_op;
    6002       935795 :       atomic_op = really_atomic_lvalue (arg);
    6003              : 
    6004              :       /* Increment or decrement the real part of the value,
    6005              :          and don't change the imaginary part.  */
    6006       935795 :       if (typecode == COMPLEX_TYPE)
    6007              :         {
    6008           57 :           tree real, imag;
    6009              : 
    6010           57 :           pedwarn_c23 (location, OPT_Wpedantic,
    6011              :                        "ISO C does not support %<++%> and %<--%> on complex "
    6012              :                        "types before C2Y");
    6013              : 
    6014           57 :           if (!atomic_op)
    6015              :             {
    6016           53 :               arg = stabilize_reference (arg);
    6017           53 :               real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg,
    6018              :                                      true);
    6019           53 :               imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg,
    6020              :                                      true);
    6021           53 :               real = build_unary_op (EXPR_LOCATION (arg), code, real, true);
    6022           53 :               if (real == error_mark_node || imag == error_mark_node)
    6023              :                 return error_mark_node;
    6024           53 :               ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg),
    6025              :                             real, imag);
    6026           53 :               goto return_build_unary_op;
    6027              :             }
    6028              :         }
    6029              : 
    6030              :       /* Report invalid types.  */
    6031              : 
    6032       935742 :       if (typecode != POINTER_TYPE && typecode != FIXED_POINT_TYPE
    6033       705322 :           && typecode != INTEGER_TYPE && typecode != REAL_TYPE
    6034          208 :           && typecode != COMPLEX_TYPE && typecode != BITINT_TYPE
    6035       935798 :           && !gnu_vector_type_p (TREE_TYPE (arg)))
    6036              :         {
    6037            5 :           if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    6038            3 :             error_at (location, "wrong type argument to increment");
    6039              :           else
    6040            2 :             error_at (location, "wrong type argument to decrement");
    6041              : 
    6042            5 :           return error_mark_node;
    6043              :         }
    6044              : 
    6045       935737 :       {
    6046       935737 :         tree inc;
    6047              : 
    6048       935737 :         argtype = TREE_TYPE (arg);
    6049              : 
    6050              :         /* Compute the increment.  */
    6051              : 
    6052       935737 :         if (typecode == POINTER_TYPE)
    6053              :           {
    6054              :             /* If pointer target is an incomplete type,
    6055              :                we just cannot know how to do the arithmetic.  */
    6056       230420 :             if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (argtype)))
    6057              :               {
    6058           27 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    6059           17 :                   error_at (location,
    6060              :                             "increment of pointer to an incomplete type %qT",
    6061           17 :                             TREE_TYPE (argtype));
    6062              :                 else
    6063           10 :                   error_at (location,
    6064              :                             "decrement of pointer to an incomplete type %qT",
    6065           10 :                             TREE_TYPE (argtype));
    6066              :               }
    6067       230393 :             else if (TREE_CODE (TREE_TYPE (argtype)) == FUNCTION_TYPE
    6068       230393 :                      || VOID_TYPE_P (TREE_TYPE (argtype)))
    6069              :               {
    6070           10 :                 if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
    6071            6 :                   pedwarn (location, OPT_Wpointer_arith,
    6072              :                            "wrong type argument to increment");
    6073              :                 else
    6074            4 :                   pedwarn (location, OPT_Wpointer_arith,
    6075              :                            "wrong type argument to decrement");
    6076              :               }
    6077              :             else
    6078       460766 :               verify_type_context (location, TCTX_POINTER_ARITH,
    6079       230383 :                                    TREE_TYPE (argtype));
    6080              : 
    6081       230420 :             inc = c_size_in_bytes (TREE_TYPE (argtype));
    6082       230420 :             inc = convert_to_ptrofftype_loc (location, inc);
    6083              :           }
    6084       705317 :         else if (FRACT_MODE_P (TYPE_MODE (argtype)))
    6085              :           {
    6086              :             /* For signed fract types, we invert ++ to -- or
    6087              :                -- to ++, and change inc from 1 to -1, because
    6088              :                it is not possible to represent 1 in signed fract constants.
    6089              :                For unsigned fract types, the result always overflows and
    6090              :                we get an undefined (original) or the maximum value.  */
    6091            0 :             if (code == PREINCREMENT_EXPR)
    6092              :               code = PREDECREMENT_EXPR;
    6093              :             else if (code == PREDECREMENT_EXPR)
    6094              :               code = PREINCREMENT_EXPR;
    6095              :             else if (code == POSTINCREMENT_EXPR)
    6096              :               code = POSTDECREMENT_EXPR;
    6097              :             else /* code == POSTDECREMENT_EXPR  */
    6098            0 :               code = POSTINCREMENT_EXPR;
    6099              : 
    6100            0 :             inc = integer_minus_one_node;
    6101            0 :             inc = convert (argtype, inc);
    6102              :           }
    6103              :         else
    6104              :           {
    6105       705266 :             inc = VECTOR_TYPE_P (argtype)
    6106       705317 :               ? build_one_cst (argtype)
    6107              :               : integer_one_node;
    6108       705317 :             inc = convert (argtype, inc);
    6109              :           }
    6110              : 
    6111              :         /* If 'arg' is an Objective-C PROPERTY_REF expression, then we
    6112              :            need to ask Objective-C to build the increment or decrement
    6113              :            expression for it.  */
    6114       935737 :         if (objc_is_property_ref (arg))
    6115            0 :           return objc_build_incr_expr_for_property_ref (location, code,
    6116           20 :                                                         arg, inc);
    6117              : 
    6118              :         /* Report a read-only lvalue.  */
    6119       935737 :         if (TYPE_READONLY (argtype))
    6120              :           {
    6121           20 :             readonly_error (location, arg,
    6122           20 :                             ((code == PREINCREMENT_EXPR
    6123           20 :                               || code == POSTINCREMENT_EXPR)
    6124              :                              ? lv_increment : lv_decrement));
    6125           20 :             return error_mark_node;
    6126              :           }
    6127       935717 :         else if (TREE_READONLY (arg))
    6128            4 :           readonly_warning (arg,
    6129            4 :                             ((code == PREINCREMENT_EXPR
    6130            4 :                               || code == POSTINCREMENT_EXPR)
    6131              :                              ? lv_increment : lv_decrement));
    6132              : 
    6133              :         /* If the argument is atomic, use the special code sequences for
    6134              :            atomic compound assignment.  */
    6135       935717 :         if (atomic_op)
    6136              :           {
    6137         4469 :             arg = stabilize_reference (arg);
    6138         8938 :             ret = build_atomic_assign (location, arg,
    6139         4469 :                                        ((code == PREINCREMENT_EXPR
    6140         4469 :                                          || code == POSTINCREMENT_EXPR)
    6141              :                                         ? PLUS_EXPR
    6142              :                                         : MINUS_EXPR),
    6143         4469 :                                        (FRACT_MODE_P (TYPE_MODE (argtype))
    6144              :                                         ? inc
    6145              :                                         : integer_one_node),
    6146              :                                        (code == POSTINCREMENT_EXPR
    6147         4469 :                                         || code == POSTDECREMENT_EXPR));
    6148       935717 :             goto return_build_unary_op;
    6149              :           }
    6150              : 
    6151       931248 :         tree true_res;
    6152       931248 :         if (c_hardbool_type_attr (TREE_TYPE (arg), NULL, &true_res))
    6153              :           {
    6154          364 :             tree larg = stabilize_reference (arg);
    6155          364 :             tree sarg = save_expr (larg);
    6156          364 :             switch (code)
    6157              :               {
    6158           91 :               case PREINCREMENT_EXPR:
    6159           91 :                 val = build2 (MODIFY_EXPR, TREE_TYPE (larg), larg, true_res);
    6160           91 :                 val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), sarg, val);
    6161           91 :                 break;
    6162           91 :               case POSTINCREMENT_EXPR:
    6163           91 :                 val = build2 (MODIFY_EXPR, TREE_TYPE (larg), larg, true_res);
    6164           91 :                 val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), val, sarg);
    6165           91 :                 val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), sarg, val);
    6166           91 :                 break;
    6167           91 :               case PREDECREMENT_EXPR:
    6168           91 :                 {
    6169           91 :                   tree rarg = convert_lvalue_to_rvalue (location, sarg,
    6170              :                                                         true, true);
    6171           91 :                   rarg = invert_truthvalue_loc (location, rarg);
    6172           91 :                   rarg = convert (TREE_TYPE (sarg), rarg);
    6173           91 :                   val = build2 (MODIFY_EXPR, TREE_TYPE (larg), larg, rarg);
    6174              :                 }
    6175           91 :                 break;
    6176           91 :               case POSTDECREMENT_EXPR:
    6177           91 :                 {
    6178           91 :                   tree rarg = convert_lvalue_to_rvalue (location, sarg,
    6179              :                                                         true, true);
    6180           91 :                   rarg = invert_truthvalue_loc (location, rarg);
    6181           91 :                   tree iarg = convert (TREE_TYPE (larg), rarg);
    6182           91 :                   val = build2 (MODIFY_EXPR, TREE_TYPE (larg), larg, iarg);
    6183           91 :                   val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), val, sarg);
    6184           91 :                   val = build2 (COMPOUND_EXPR, TREE_TYPE (larg), sarg, val);
    6185              :                 }
    6186           91 :                 break;
    6187              :               default:
    6188              :                 gcc_unreachable ();
    6189              :               }
    6190          364 :             TREE_SIDE_EFFECTS (val) = 1;
    6191              :           }
    6192       930884 :         else if (C_BOOLEAN_TYPE_P (TREE_TYPE (arg)))
    6193           64 :           val = boolean_increment (code, arg);
    6194              :         else
    6195       930820 :           val = build2 (code, TREE_TYPE (arg), arg, inc);
    6196       931248 :         TREE_SIDE_EFFECTS (val) = 1;
    6197       931248 :         if (TYPE_QUALS (TREE_TYPE (val)) != TYPE_UNQUALIFIED)
    6198         3939 :           TREE_TYPE (val) = c_build_qualified_type (TREE_TYPE (val),
    6199              :                                                     TYPE_UNQUALIFIED);
    6200       931248 :         ret = val;
    6201       931248 :         goto return_build_unary_op;
    6202              :       }
    6203              : 
    6204     52012942 :     case ADDR_EXPR:
    6205              :       /* Note that this operation never does default_conversion.  */
    6206              : 
    6207              :       /* The operand of unary '&' must be an lvalue (which excludes
    6208              :          expressions of type void), or, in C99, the result of a [] or
    6209              :          unary '*' operator.  */
    6210     52012942 :       if (VOID_TYPE_P (TREE_TYPE (arg))
    6211           25 :           && TYPE_QUALS (TREE_TYPE (arg)) == TYPE_UNQUALIFIED
    6212     52012961 :           && (!INDIRECT_REF_P (arg) || !flag_isoc99))
    6213           18 :         pedwarn (location, 0, "taking address of expression of type %<void%>");
    6214              : 
    6215              :       /* Let &* cancel out to simplify resulting code.  */
    6216     52012942 :       if (INDIRECT_REF_P (arg))
    6217              :         {
    6218              :           /* Don't let this be an lvalue.  */
    6219        22320 :           if (lvalue_p (TREE_OPERAND (arg, 0)))
    6220        16821 :             return non_lvalue_loc (location, TREE_OPERAND (arg, 0));
    6221         5499 :           ret = TREE_OPERAND (arg, 0);
    6222         5499 :           goto return_build_unary_op;
    6223              :         }
    6224              : 
    6225              :       /* Anything not already handled and not a true memory reference
    6226              :          or a non-lvalue array is an error.  */
    6227     51990622 :       if (typecode != FUNCTION_TYPE && !noconvert
    6228     51990622 :           && !lvalue_or_else (location, arg, lv_addressof))
    6229           17 :         return error_mark_node;
    6230              : 
    6231              :       /* Move address operations inside C_MAYBE_CONST_EXPR to simplify
    6232              :          folding later.  */
    6233     51990605 :       if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR)
    6234              :         {
    6235           14 :           tree inner = build_unary_op (location, code,
    6236           14 :                                        C_MAYBE_CONST_EXPR_EXPR (arg),
    6237              :                                        noconvert);
    6238           28 :           ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    6239           14 :                         C_MAYBE_CONST_EXPR_PRE (arg), inner);
    6240           14 :           gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg));
    6241           14 :           C_MAYBE_CONST_EXPR_NON_CONST (ret)
    6242           14 :             = C_MAYBE_CONST_EXPR_NON_CONST (arg);
    6243           14 :           goto return_build_unary_op;
    6244              :         }
    6245              : 
    6246              :       /* Ordinary case; arg is a COMPONENT_REF or a decl.  */
    6247              : 
    6248     51990591 :       argtype = TREE_TYPE (arg);
    6249              : 
    6250              :       /* If the lvalue is const or volatile, merge that into the type
    6251              :          to which the address will point.  This is only needed
    6252              :          for function types.  */
    6253     51990591 :       if ((DECL_P (arg) || REFERENCE_CLASS_P (arg))
    6254     51498137 :           && (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg))
    6255     82091764 :           && TREE_CODE (argtype) == FUNCTION_TYPE)
    6256              :         {
    6257     30021146 :           int orig_quals = TYPE_QUALS (strip_array_types (argtype));
    6258     30021146 :           int quals = orig_quals;
    6259              : 
    6260     30021146 :           if (TREE_READONLY (arg))
    6261     29644878 :             quals |= TYPE_QUAL_CONST;
    6262     30021146 :           if (TREE_THIS_VOLATILE (arg))
    6263       377180 :             quals |= TYPE_QUAL_VOLATILE;
    6264              : 
    6265     30021146 :           argtype = c_build_qualified_type (argtype, quals);
    6266              :         }
    6267              : 
    6268     51990591 :       switch (TREE_CODE (arg))
    6269              :         {
    6270        65606 :         case COMPONENT_REF:
    6271        65606 :           if (DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)))
    6272              :             {
    6273            8 :               error_at (location, "cannot take address of bit-field %qD",
    6274            8 :                         TREE_OPERAND (arg, 1));
    6275            8 :               return error_mark_node;
    6276              :             }
    6277              : 
    6278              :           /* fall through */
    6279              : 
    6280       139852 :         case ARRAY_REF:
    6281       139852 :           if (TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (arg, 0))))
    6282              :             {
    6283           78 :               if (!AGGREGATE_TYPE_P (TREE_TYPE (arg))
    6284            7 :                   && !POINTER_TYPE_P (TREE_TYPE (arg))
    6285           75 :                   && !VECTOR_TYPE_P (TREE_TYPE (arg)))
    6286              :                 {
    6287            6 :                   error_at (location, "cannot take address of scalar with "
    6288              :                             "reverse storage order");
    6289            6 :                   return error_mark_node;
    6290              :                 }
    6291              : 
    6292           63 :               if (TREE_CODE (TREE_TYPE (arg)) == ARRAY_TYPE
    6293           63 :                   && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (arg)))
    6294           58 :                 warning_at (location, OPT_Wscalar_storage_order,
    6295              :                             "address of array with reverse scalar storage "
    6296              :                             "order requested");
    6297              :             }
    6298              : 
    6299     51990577 :         default:
    6300     51990577 :           break;
    6301              :         }
    6302              : 
    6303     51990577 :       if (!c_mark_addressable (arg))
    6304           20 :         return error_mark_node;
    6305              : 
    6306     51990557 :       gcc_assert (TREE_CODE (arg) != COMPONENT_REF
    6307              :                   || !DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1)));
    6308              : 
    6309     51990557 :       argtype = c_build_pointer_type (argtype);
    6310              : 
    6311              :       /* ??? Cope with user tricks that amount to offsetof.  Delete this
    6312              :          when we have proper support for integer constant expressions.  */
    6313     51990557 :       val = get_base_address (arg);
    6314     51990557 :       if (val && INDIRECT_REF_P (val)
    6315     52014589 :           && TREE_CONSTANT (TREE_OPERAND (val, 0)))
    6316              :         {
    6317          540 :           ret = fold_offsetof (arg, argtype);
    6318          540 :           goto return_build_unary_op;
    6319              :         }
    6320              : 
    6321     51990017 :       val = build1 (ADDR_EXPR, argtype, arg);
    6322              : 
    6323     51990017 :       ret = val;
    6324     51990017 :       goto return_build_unary_op;
    6325              : 
    6326           10 :     case PAREN_EXPR:
    6327           10 :       ret = build1 (code, TREE_TYPE (arg), arg);
    6328           10 :       goto return_build_unary_op;
    6329              : 
    6330            0 :     default:
    6331            0 :       gcc_unreachable ();
    6332              :     }
    6333              : 
    6334      7025193 :   if (argtype == NULL_TREE)
    6335      7025193 :     argtype = TREE_TYPE (arg);
    6336      7025193 :   if (TREE_CODE (arg) == INTEGER_CST)
    6337      6320538 :     ret = (require_constant_value
    6338      6320538 :            ? fold_build1_initializer_loc (location, code, argtype, arg)
    6339      6301947 :            : fold_build1_loc (location, code, argtype, arg));
    6340              :   else
    6341       704655 :     ret = build1 (code, argtype, arg);
    6342     60538471 :  return_build_unary_op:
    6343     60538471 :   gcc_assert (ret != error_mark_node);
    6344      6465222 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret)
    6345     67003684 :       && !(TREE_CODE (xarg) == INTEGER_CST && !TREE_OVERFLOW (xarg)))
    6346          562 :     ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret);
    6347     60537909 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands)
    6348           74 :     ret = note_integer_operands (ret);
    6349     60538471 :   if (eptype)
    6350          245 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    6351     60538471 :   protected_set_expr_location (ret, location);
    6352     60538471 :   return ret;
    6353              : }
    6354              : 
    6355              : /* Return nonzero if REF is an lvalue valid for this language.
    6356              :    Lvalues can be assigned, unless their type has TYPE_READONLY.
    6357              :    Lvalues can have their address taken, unless they have C_DECL_REGISTER.  */
    6358              : 
    6359              : bool
    6360    178337735 : lvalue_p (const_tree ref)
    6361              : {
    6362    179838919 :   const enum tree_code code = TREE_CODE (ref);
    6363              : 
    6364    179838919 :   switch (code)
    6365              :     {
    6366      1476371 :     case REALPART_EXPR:
    6367      1476371 :     case IMAGPART_EXPR:
    6368      1476371 :     case COMPONENT_REF:
    6369      1476371 :       return lvalue_p (TREE_OPERAND (ref, 0));
    6370              : 
    6371        24813 :     case C_MAYBE_CONST_EXPR:
    6372        24813 :       return lvalue_p (TREE_OPERAND (ref, 1));
    6373              : 
    6374              :     case COMPOUND_LITERAL_EXPR:
    6375              :     case STRING_CST:
    6376              :       return true;
    6377              : 
    6378     25502458 :     case MEM_REF:
    6379     25502458 :     case TARGET_MEM_REF:
    6380              :       /* MEM_REFs can appear from -fgimple parsing or folding, so allow them
    6381              :          here as well.  */
    6382     25502458 :     case INDIRECT_REF:
    6383     25502458 :     case ARRAY_REF:
    6384     25502458 :     case VAR_DECL:
    6385     25502458 :     case PARM_DECL:
    6386     25502458 :     case RESULT_DECL:
    6387     25502458 :     case ERROR_MARK:
    6388     25502458 :       return (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
    6389     25502458 :               && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE);
    6390              : 
    6391            6 :     case BIND_EXPR:
    6392            6 :       return TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE;
    6393              : 
    6394      7080521 :     case CALL_EXPR:
    6395      7080521 :       return is_access_with_size_p (ref);
    6396              : 
    6397              :     default:
    6398              :       return false;
    6399              :     }
    6400              : }
    6401              : 
    6402              : /* Give a warning for storing in something that is read-only in GCC
    6403              :    terms but not const in ISO C terms.  */
    6404              : 
    6405              : static void
    6406            5 : readonly_warning (tree arg, enum lvalue_use use)
    6407              : {
    6408            5 :   switch (use)
    6409              :     {
    6410            1 :     case lv_assign:
    6411            1 :       warning (0, "assignment of read-only location %qE", arg);
    6412            1 :       break;
    6413            2 :     case lv_increment:
    6414            2 :       warning (0, "increment of read-only location %qE", arg);
    6415            2 :       break;
    6416            2 :     case lv_decrement:
    6417            2 :       warning (0, "decrement of read-only location %qE", arg);
    6418            2 :       break;
    6419            0 :     default:
    6420            0 :       gcc_unreachable ();
    6421              :     }
    6422            5 :   return;
    6423              : }
    6424              : 
    6425              : 
    6426              : /* Return nonzero if REF is an lvalue valid for this language;
    6427              :    otherwise, print an error message and return zero.  USE says
    6428              :    how the lvalue is being used and so selects the error message.
    6429              :    LOCATION is the location at which any error should be reported.  */
    6430              : 
    6431              : static int
    6432      4724112 : lvalue_or_else (location_t loc, const_tree ref, enum lvalue_use use)
    6433              : {
    6434      4724112 :   int win = lvalue_p (ref);
    6435              : 
    6436      4724112 :   if (!win)
    6437           75 :     lvalue_error (loc, use);
    6438              : 
    6439      4724112 :   return win;
    6440              : }
    6441              : 
    6442              : /* Mark EXP saying that we need to be able to take the
    6443              :    address of it; it should not be allocated in a register.
    6444              :    Returns true if successful.  ARRAY_REF_P is true if this
    6445              :    is for ARRAY_REF construction - in that case we don't want
    6446              :    to look through VIEW_CONVERT_EXPR from VECTOR_TYPE to ARRAY_TYPE,
    6447              :    it is fine to use ARRAY_REFs for vector subscripts on vector
    6448              :    register variables.  If OVERRIDE_REGISTER, clear DECL_REGISTER rather
    6449              :    than producing an error for taking the address of a register.  */
    6450              : 
    6451              : bool
    6452     52535579 : c_mark_addressable (tree exp, bool array_ref_p, bool override_register)
    6453              : {
    6454     52535579 :   tree x = exp;
    6455              : 
    6456     53116291 :   while (1)
    6457     53116291 :     switch (TREE_CODE (x))
    6458              :       {
    6459        10029 :       case VIEW_CONVERT_EXPR:
    6460        10029 :         if (array_ref_p
    6461         9919 :             && TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
    6462        19948 :             && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (x, 0))))
    6463              :           return true;
    6464          110 :         x = TREE_OPERAND (x, 0);
    6465          110 :         break;
    6466              : 
    6467       396394 :       case COMPONENT_REF:
    6468       396394 :         if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
    6469              :           {
    6470            6 :             error ("cannot take address of bit-field %qD",
    6471            3 :                    TREE_OPERAND (x, 1));
    6472            3 :             return false;
    6473              :           }
    6474              :         /* FALLTHRU */
    6475       580602 :       case ADDR_EXPR:
    6476       580602 :       case ARRAY_REF:
    6477       580602 :       case REALPART_EXPR:
    6478       580602 :       case IMAGPART_EXPR:
    6479       580602 :         x = TREE_OPERAND (x, 0);
    6480       580602 :         break;
    6481              : 
    6482          587 :       case COMPOUND_LITERAL_EXPR:
    6483          587 :         if (C_DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (x)))
    6484              :           {
    6485           16 :             if (override_register)
    6486           12 :               DECL_REGISTER (COMPOUND_LITERAL_EXPR_DECL (x)) = 0;
    6487              :             else
    6488              :               {
    6489            4 :                 error ("address of register compound literal requested");
    6490            4 :                 return false;
    6491              :               }
    6492              :           }
    6493          583 :         TREE_ADDRESSABLE (x) = 1;
    6494          583 :         TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (x)) = 1;
    6495          583 :         return true;
    6496              : 
    6497            0 :       case CONSTRUCTOR:
    6498            0 :         TREE_ADDRESSABLE (x) = 1;
    6499            0 :         return true;
    6500              : 
    6501      1323936 :       case VAR_DECL:
    6502      1323936 :       case CONST_DECL:
    6503      1323936 :       case PARM_DECL:
    6504      1323936 :       case RESULT_DECL:
    6505      1323936 :         if (C_DECL_REGISTER (x)
    6506      1323936 :             && DECL_NONLOCAL (x))
    6507              :           {
    6508            0 :             if (TREE_PUBLIC (x) || is_global_var (x))
    6509              :               {
    6510            0 :                 error
    6511            0 :                   ("global register variable %qD used in nested function", x);
    6512            0 :                 return false;
    6513              :               }
    6514            0 :             pedwarn (input_location, 0, "register variable %qD used in nested function", x);
    6515              :           }
    6516      1323936 :         else if (C_DECL_REGISTER (x))
    6517              :           {
    6518           73 :             if (TREE_PUBLIC (x) || is_global_var (x))
    6519            4 :               error ("address of global register variable %qD requested", x);
    6520          123 :             else if (override_register && !DECL_HARD_REGISTER (x))
    6521              :               {
    6522           54 :                 DECL_REGISTER (x) = 0;
    6523           54 :                 TREE_ADDRESSABLE (x) = 1;
    6524           54 :                 mark_decl_used (x, true);
    6525           54 :                 return true;
    6526              :               }
    6527              :             else
    6528           15 :               error ("address of register variable %qD requested", x);
    6529           19 :             return false;
    6530              :           }
    6531              : 
    6532              :         /* FALLTHRU */
    6533     51957362 :       case FUNCTION_DECL:
    6534     51957362 :         TREE_ADDRESSABLE (x) = 1;
    6535     51957362 :         mark_decl_used (x, true);
    6536              :         /* FALLTHRU */
    6537              :       default:
    6538              :         return true;
    6539              :     }
    6540              : }
    6541              : 
    6542              : /* Convert EXPR to TYPE, warning about conversion problems with
    6543              :    constants.  SEMANTIC_TYPE is the type this conversion would use
    6544              :    without excess precision. If SEMANTIC_TYPE is NULL, this function
    6545              :    is equivalent to convert_and_check. This function is a wrapper that
    6546              :    handles conversions that may be different than
    6547              :    the usual ones because of excess precision.  */
    6548              : 
    6549              : static tree
    6550     23647066 : ep_convert_and_check (location_t loc, tree type, tree expr,
    6551              :                       tree semantic_type)
    6552              : {
    6553     23647066 :   if (TREE_TYPE (expr) == type)
    6554              :     return expr;
    6555              : 
    6556              :   /* For C11, integer conversions may have results with excess
    6557              :      precision.  */
    6558      2062755 :   if (flag_isoc11 || !semantic_type)
    6559      2062751 :     return convert_and_check (loc, type, expr);
    6560              : 
    6561            4 :   if (TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
    6562            4 :       && TREE_TYPE (expr) != semantic_type)
    6563              :     {
    6564              :       /* For integers, we need to check the real conversion, not
    6565              :          the conversion to the excess precision type.  */
    6566            4 :       expr = convert_and_check (loc, semantic_type, expr);
    6567              :     }
    6568              :   /* Result type is the excess precision type, which should be
    6569              :      large enough, so do not check.  */
    6570            4 :   return convert (type, expr);
    6571              : }
    6572              : 
    6573              : /* If EXPR refers to a built-in declared without a prototype returns
    6574              :    the actual type of the built-in and, if non-null, set *BLTIN to
    6575              :    a pointer to the built-in.  Otherwise return the type of EXPR
    6576              :    and clear *BLTIN if non-null.  */
    6577              : 
    6578              : static tree
    6579      2830884 : type_or_builtin_type (tree expr, tree *bltin = NULL)
    6580              : {
    6581      2830884 :   tree dummy;
    6582      2830884 :   if (!bltin)
    6583            0 :     bltin = &dummy;
    6584              : 
    6585      2830884 :   *bltin = NULL_TREE;
    6586              : 
    6587      2830884 :   tree type = TREE_TYPE (expr);
    6588      2830884 :   if (TREE_CODE (expr) != ADDR_EXPR)
    6589              :     return type;
    6590              : 
    6591       209292 :   tree oper = TREE_OPERAND (expr, 0);
    6592       209292 :   if (!DECL_P (oper)
    6593       170729 :       || TREE_CODE (oper) != FUNCTION_DECL
    6594       245716 :       || !fndecl_built_in_p (oper, BUILT_IN_NORMAL))
    6595              :     return type;
    6596              : 
    6597         2086 :   built_in_function code = DECL_FUNCTION_CODE (oper);
    6598         2086 :   if (!C_DECL_BUILTIN_PROTOTYPE (oper))
    6599              :     return type;
    6600              : 
    6601         1977 :   if ((*bltin = builtin_decl_implicit (code)))
    6602          991 :     type = c_build_pointer_type (TREE_TYPE (*bltin));
    6603              : 
    6604              :   return type;
    6605              : }
    6606              : 
    6607              : /* Build and return a conditional expression IFEXP ? OP1 : OP2.  If
    6608              :    IFEXP_BCP then the condition is a call to __builtin_constant_p, and
    6609              :    if folded to an integer constant then the unselected half may
    6610              :    contain arbitrary operations not normally permitted in constant
    6611              :    expressions.  Set the location of the expression to LOC.  */
    6612              : 
    6613              : tree
    6614       403868 : build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
    6615              :                         tree op1, tree op1_original_type, location_t op1_loc,
    6616              :                         tree op2, tree op2_original_type, location_t op2_loc)
    6617              : {
    6618       403868 :   tree type1;
    6619       403868 :   tree type2;
    6620       403868 :   tree result_type = NULL;
    6621       403868 :   tree semantic_result_type = NULL;
    6622       403868 :   tree orig_op1 = op1, orig_op2 = op2;
    6623       403868 :   bool int_const, op1_int_operands, op2_int_operands, int_operands;
    6624       403868 :   bool ifexp_int_operands;
    6625       403868 :   tree ret;
    6626              : 
    6627       403868 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
    6628       110373 :   if (op1_int_operands)
    6629       110373 :     op1 = remove_c_maybe_const_expr (op1);
    6630       403868 :   op2_int_operands = EXPR_INT_CONST_OPERANDS (orig_op2);
    6631       145571 :   if (op2_int_operands)
    6632       145571 :     op2 = remove_c_maybe_const_expr (op2);
    6633       403868 :   ifexp_int_operands = EXPR_INT_CONST_OPERANDS (ifexp);
    6634       242765 :   if (ifexp_int_operands)
    6635       242765 :     ifexp = remove_c_maybe_const_expr (ifexp);
    6636              : 
    6637              :   /* Promote both alternatives.  */
    6638              : 
    6639       403868 :   if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE)
    6640       399946 :     op1 = default_conversion (op1);
    6641       403868 :   if (TREE_CODE (TREE_TYPE (op2)) != VOID_TYPE)
    6642       374023 :     op2 = default_conversion (op2);
    6643              : 
    6644       403868 :   if (TREE_CODE (ifexp) == ERROR_MARK
    6645       403799 :       || TREE_CODE (TREE_TYPE (op1)) == ERROR_MARK
    6646       807653 :       || TREE_CODE (TREE_TYPE (op2)) == ERROR_MARK)
    6647           83 :     return error_mark_node;
    6648              : 
    6649       403785 :   tree bltin1 = NULL_TREE;
    6650       403785 :   tree bltin2 = NULL_TREE;
    6651       403785 :   type1 = type_or_builtin_type (op1, &bltin1);
    6652       403785 :   const enum tree_code code1 = TREE_CODE (type1);
    6653       403785 :   type2 = type_or_builtin_type (op2, &bltin2);
    6654       403785 :   const enum tree_code code2 = TREE_CODE (type2);
    6655              : 
    6656       403785 :   if (code1 == POINTER_TYPE && reject_gcc_builtin (op1))
    6657            1 :     return error_mark_node;
    6658              : 
    6659       403784 :   if (code2 == POINTER_TYPE && reject_gcc_builtin (op2))
    6660            1 :     return error_mark_node;
    6661              : 
    6662              :   /* C90 does not permit non-lvalue arrays in conditional expressions.
    6663              :      In C99 they will be pointers by now.  */
    6664       403783 :   if (code1 == ARRAY_TYPE || code2 == ARRAY_TYPE)
    6665              :     {
    6666            1 :       error_at (colon_loc, "non-lvalue array in conditional expression");
    6667            1 :       return error_mark_node;
    6668              :     }
    6669              : 
    6670       403782 :   if ((TREE_CODE (op1) == EXCESS_PRECISION_EXPR
    6671       403776 :        || TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    6672            7 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
    6673            0 :           || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    6674            7 :       && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    6675            0 :           || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    6676              :     {
    6677            7 :       semantic_result_type = c_common_type (type1, type2);
    6678            7 :       if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
    6679              :         {
    6680            6 :           op1 = TREE_OPERAND (op1, 0);
    6681            6 :           type1 = TREE_TYPE (op1);
    6682            6 :           gcc_assert (TREE_CODE (type1) == code1);
    6683              :         }
    6684            7 :       if (TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
    6685              :         {
    6686            1 :           op2 = TREE_OPERAND (op2, 0);
    6687            1 :           type2 = TREE_TYPE (op2);
    6688            1 :           gcc_assert (TREE_CODE (type2) == code2);
    6689              :         }
    6690              :     }
    6691              : 
    6692       403782 :   if (warn_cxx_compat)
    6693              :     {
    6694          420 :       tree t1 = op1_original_type ? op1_original_type : TREE_TYPE (orig_op1);
    6695          420 :       tree t2 = op2_original_type ? op2_original_type : TREE_TYPE (orig_op2);
    6696              : 
    6697          420 :       if (TREE_CODE (t1) == ENUMERAL_TYPE
    6698            6 :           && TREE_CODE (t2) == ENUMERAL_TYPE
    6699          426 :           && TYPE_MAIN_VARIANT (t1) != TYPE_MAIN_VARIANT (t2))
    6700            2 :         warning_at (colon_loc, OPT_Wc___compat,
    6701              :                     "different enum types in conditional is "
    6702              :                     "invalid in C++: %qT vs %qT", t1, t2);
    6703              :     }
    6704              : 
    6705       403782 :   if (warn_zero_as_null_pointer_constant
    6706           20 :       && c_inhibit_evaluation_warnings == 0)
    6707              :     {
    6708           20 :       if ((code1 == POINTER_TYPE || code1 == NULLPTR_TYPE)
    6709           20 :           && INTEGRAL_TYPE_P (type2) && null_pointer_constant_p (orig_op2))
    6710            5 :         warning_at (op2_loc, OPT_Wzero_as_null_pointer_constant,
    6711              :                     "zero as null pointer constant");
    6712              : 
    6713           20 :       if ((code2 == POINTER_TYPE || code2 == NULLPTR_TYPE)
    6714           20 :           && INTEGRAL_TYPE_P (type1) && null_pointer_constant_p (orig_op1))
    6715            5 :         warning_at (op1_loc, OPT_Wzero_as_null_pointer_constant,
    6716              :                     "zero as null pointer constant");
    6717              :     }
    6718              : 
    6719              :   /* Quickly detect the usual case where op1 and op2 have the same type
    6720              :      after promotion.  */
    6721       403782 :   if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))
    6722              :     {
    6723       268733 :       if (type1 == type2)
    6724              :         result_type = type1;
    6725              :       else
    6726         6399 :         result_type = TYPE_MAIN_VARIANT (type1);
    6727              :     }
    6728       135049 :   else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE
    6729        80393 :             || code1 == COMPLEX_TYPE || code1 == BITINT_TYPE)
    6730        54704 :            && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
    6731        26152 :                || code2 == COMPLEX_TYPE || code2 == BITINT_TYPE))
    6732              :     {
    6733              :       /* In C11, a conditional expression between a floating-point
    6734              :          type and an integer type should convert the integer type to
    6735              :          the evaluation format of the floating-point type, with
    6736              :          possible excess precision.  */
    6737        28652 :       tree eptype1 = type1;
    6738        28652 :       tree eptype2 = type2;
    6739        28652 :       if (flag_isoc11)
    6740              :         {
    6741        28339 :           tree eptype;
    6742        11641 :           if (ANY_INTEGRAL_TYPE_P (type1)
    6743        28339 :               && (eptype = excess_precision_type (type2)) != NULL_TREE)
    6744              :             {
    6745            2 :               eptype2 = eptype;
    6746            2 :               if (!semantic_result_type)
    6747            2 :                 semantic_result_type = c_common_type (type1, type2);
    6748              :             }
    6749          501 :           else if (ANY_INTEGRAL_TYPE_P (type2)
    6750        28337 :                    && (eptype = excess_precision_type (type1)) != NULL_TREE)
    6751              :             {
    6752         4626 :               eptype1 = eptype;
    6753         4626 :               if (!semantic_result_type)
    6754         4626 :                 semantic_result_type = c_common_type (type1, type2);
    6755              :             }
    6756              :         }
    6757        28652 :       result_type = c_common_type (eptype1, eptype2);
    6758        28652 :       if (result_type == error_mark_node)
    6759              :         return error_mark_node;
    6760        28650 :       do_warn_double_promotion (result_type, type1, type2,
    6761              :                                 "implicit conversion from %qT to %qT to "
    6762              :                                 "match other result of conditional",
    6763              :                                 colon_loc);
    6764              : 
    6765              :       /* If -Wsign-compare, warn here if type1 and type2 have
    6766              :          different signedness.  We'll promote the signed to unsigned
    6767              :          and later code won't know it used to be different.
    6768              :          Do this check on the original types, so that explicit casts
    6769              :          will be considered, but default promotions won't.  */
    6770        28650 :       if (c_inhibit_evaluation_warnings == 0)
    6771              :         {
    6772        28459 :           int unsigned_op1 = TYPE_UNSIGNED (TREE_TYPE (orig_op1));
    6773        28459 :           int unsigned_op2 = TYPE_UNSIGNED (TREE_TYPE (orig_op2));
    6774              : 
    6775        28459 :           if (unsigned_op1 ^ unsigned_op2)
    6776              :             {
    6777              :               /* Do not warn if the result type is signed, since the
    6778              :                  signed type will only be chosen if it can represent
    6779              :                  all the values of the unsigned type.  */
    6780        13020 :               if (!TYPE_UNSIGNED (result_type))
    6781              :                 /* OK */;
    6782              :               else
    6783              :                 {
    6784        12916 :                   bool op1_maybe_const = true;
    6785        12916 :                   bool op2_maybe_const = true;
    6786              : 
    6787              :                   /* Do not warn if the signed quantity is an
    6788              :                      unsuffixed integer literal (or some static
    6789              :                      constant expression involving such literals) and
    6790              :                      it is non-negative.  This warning requires the
    6791              :                      operands to be folded for best results, so do
    6792              :                      that folding in this case even without
    6793              :                      warn_sign_compare to avoid warning options
    6794              :                      possibly affecting code generation.  */
    6795        12916 :                   c_inhibit_evaluation_warnings
    6796        12916 :                     += (ifexp == truthvalue_false_node);
    6797        12916 :                   op1 = c_fully_fold (op1, require_constant_value,
    6798              :                                       &op1_maybe_const);
    6799        12916 :                   c_inhibit_evaluation_warnings
    6800        12916 :                     -= (ifexp == truthvalue_false_node);
    6801              : 
    6802        12916 :                   c_inhibit_evaluation_warnings
    6803        12916 :                     += (ifexp == truthvalue_true_node);
    6804        12916 :                   op2 = c_fully_fold (op2, require_constant_value,
    6805              :                                       &op2_maybe_const);
    6806        12916 :                   c_inhibit_evaluation_warnings
    6807        12916 :                     -= (ifexp == truthvalue_true_node);
    6808              : 
    6809        12916 :                   if (warn_sign_compare)
    6810              :                     {
    6811         1245 :                       if ((unsigned_op2
    6812          685 :                            && tree_expr_nonnegative_p (op1))
    6813         1248 :                           || (unsigned_op1
    6814          560 :                               && tree_expr_nonnegative_p (op2)))
    6815              :                         /* OK */;
    6816           10 :                       else if (unsigned_op2)
    6817            3 :                         warning_at (op1_loc, OPT_Wsign_compare,
    6818              :                                     "operand of %<?:%> changes signedness from "
    6819              :                                     "%qT to %qT due to unsignedness of other "
    6820            3 :                                     "operand", TREE_TYPE (orig_op1),
    6821            3 :                                     TREE_TYPE (orig_op2));
    6822              :                       else
    6823            7 :                         warning_at (op2_loc, OPT_Wsign_compare,
    6824              :                                     "operand of %<?:%> changes signedness from "
    6825              :                                     "%qT to %qT due to unsignedness of other "
    6826            7 :                                     "operand", TREE_TYPE (orig_op2),
    6827            7 :                                     TREE_TYPE (orig_op1));
    6828              :                     }
    6829        12916 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
    6830         7567 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
    6831        12916 :                   if (!op2_maybe_const || TREE_CODE (op2) != INTEGER_CST)
    6832         4394 :                     op2 = c_wrap_maybe_const (op2, !op2_maybe_const);
    6833              :                 }
    6834              :             }
    6835              :         }
    6836              :     }
    6837       106397 :   else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
    6838              :     {
    6839        25995 :       if (code1 != VOID_TYPE || code2 != VOID_TYPE)
    6840        25995 :         pedwarn (colon_loc, OPT_Wpedantic,
    6841              :                  "ISO C forbids conditional expr with only one void side");
    6842        25995 :       result_type = void_type_node;
    6843              :     }
    6844        80402 :   else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
    6845              :     {
    6846        80005 :       addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
    6847        80005 :       addr_space_t as2 = TYPE_ADDR_SPACE (TREE_TYPE (type2));
    6848        80005 :       addr_space_t as_common;
    6849              : 
    6850        80005 :       if (comp_target_types (colon_loc, type1, type2))
    6851              :         {
    6852         2620 :           ifexp = save_expr (ifexp);
    6853         2620 :           result_type = common_pointer_type (type1, type2, ifexp);
    6854              :         }
    6855        77385 :       else if (null_pointer_constant_p (orig_op1))
    6856              :         result_type = type2;
    6857        73223 :       else if (null_pointer_constant_p (orig_op2))
    6858              :         result_type = type1;
    6859        35279 :       else if (!addr_space_superset (as1, as2, &as_common))
    6860              :         {
    6861            0 :           error_at (colon_loc, "pointers to disjoint address spaces "
    6862              :                     "used in conditional expression");
    6863            0 :           return error_mark_node;
    6864              :         }
    6865        35279 :       else if ((VOID_TYPE_P (TREE_TYPE (type1))
    6866          326 :                 && !TYPE_ATOMIC (TREE_TYPE (type1)))
    6867        35281 :                || (VOID_TYPE_P (TREE_TYPE (type2))
    6868        34908 :                    && !TYPE_ATOMIC (TREE_TYPE (type2))))
    6869              :         {
    6870        35231 :           tree t1 = TREE_TYPE (type1);
    6871        35231 :           tree t2 = TREE_TYPE (type2);
    6872        35231 :           if (!(VOID_TYPE_P (t1)
    6873          325 :                 && !TYPE_ATOMIC (t1)))
    6874              :            {
    6875              :              /* roles are swapped */
    6876        34907 :              t1 = t2;
    6877        34907 :              t2 = TREE_TYPE (type1);
    6878              :            }
    6879        35231 :           tree t2_stripped = strip_array_types (t2);
    6880        35231 :           if ((TREE_CODE (t2) == ARRAY_TYPE)
    6881        35231 :               && (TYPE_QUALS (t2_stripped) & ~TYPE_QUALS (t1)))
    6882              :             {
    6883           18 :               if (!flag_isoc23)
    6884            6 :                 warning_at (colon_loc, OPT_Wdiscarded_array_qualifiers,
    6885              :                             "pointer to array loses qualifier "
    6886              :                             "in conditional expression");
    6887           12 :               else if (warn_c11_c23_compat > 0)
    6888            6 :                 warning_at (colon_loc, OPT_Wc11_c23_compat,
    6889              :                             "pointer to array loses qualifier "
    6890              :                             "in conditional expression in ISO C before C23");
    6891              :             }
    6892        35231 :           if (TREE_CODE (t2) == FUNCTION_TYPE)
    6893            4 :             pedwarn (colon_loc, OPT_Wpedantic,
    6894              :                      "ISO C forbids conditional expr between "
    6895              :                      "%<void *%> and function pointer");
    6896              :           /* for array, use qualifiers of element type */
    6897        35231 :           if (flag_isoc23)
    6898        11450 :             t2 = t2_stripped;
    6899        35231 :           result_type = c_build_pointer_type (qualify_type (t1, t2));
    6900              :         }
    6901              :       /* Objective-C pointer comparisons are a bit more lenient.  */
    6902           48 :       else if (objc_have_common_type (type1, type2, -3, NULL_TREE))
    6903            0 :         result_type = objc_common_type (type1, type2);
    6904              :       else
    6905              :         {
    6906           48 :           int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
    6907           48 :           enum diagnostics::kind kind = diagnostics::kind::permerror;
    6908           48 :           if (!flag_isoc99)
    6909              :             /* This downgrade to a warning ensures that -std=gnu89
    6910              :                -pedantic-errors does not flag these mismatches between
    6911              :                builtins as errors (as diagnostics::kind::permerror would)
    6912              :                ISO C99 and later do not have implicit function declarations,
    6913              :                so the mismatch cannot occur naturally there.  */
    6914            5 :             kind = (bltin1 && bltin2
    6915            5 :                     ? diagnostics::kind::warning
    6916              :                     : diagnostics::kind::pedwarn);
    6917           48 :           if (emit_diagnostic (kind, colon_loc, OPT_Wincompatible_pointer_types,
    6918              :                                "pointer type mismatch "
    6919              :                                "in conditional expression"))
    6920              :             {
    6921           46 :               inform (op1_loc, "first expression has type %qT", type1);
    6922           46 :               inform (op2_loc, "second expression has type %qT", type2);
    6923              :             }
    6924           48 :           result_type = c_build_pointer_type
    6925           48 :                           (c_build_qualified_type (void_type_node, qual));
    6926              :         }
    6927              :     }
    6928          397 :   else if (code1 == POINTER_TYPE
    6929          277 :            && (code2 == INTEGER_TYPE || code2 == BITINT_TYPE))
    6930              :     {
    6931          273 :       if (!null_pointer_constant_p (orig_op2))
    6932           14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    6933              :                        "pointer/integer type mismatch "
    6934              :                        "in conditional expression");
    6935              :       else
    6936              :         {
    6937          259 :           op2 = null_pointer_node;
    6938              :         }
    6939              :       result_type = type1;
    6940              :     }
    6941          124 :   else if (code2 == POINTER_TYPE
    6942           90 :            && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
    6943              :     {
    6944           86 :       if (!null_pointer_constant_p (orig_op1))
    6945           14 :         permerror_opt (colon_loc, OPT_Wint_conversion,
    6946              :                        "pointer/integer type mismatch "
    6947              :                        "in conditional expression");
    6948              :       else
    6949              :         {
    6950           72 :           op1 = null_pointer_node;
    6951              :         }
    6952              :       result_type = type2;
    6953              :     }
    6954              :   /* 6.5.15: "if one is a null pointer constant (other than a pointer) or has
    6955              :      type nullptr_t and the other is a pointer, the result type is the pointer
    6956              :      type."  */
    6957           38 :   else if (code1 == NULLPTR_TYPE && code2 == POINTER_TYPE)
    6958              :     result_type = type2;
    6959           34 :   else if (code1 == POINTER_TYPE && code2 == NULLPTR_TYPE)
    6960              :     result_type = type1;
    6961            8 :   else if (RECORD_OR_UNION_TYPE_P (type1) && RECORD_OR_UNION_TYPE_P (type2)
    6962           38 :            && comptypes (TYPE_MAIN_VARIANT (type1),
    6963            8 :                          TYPE_MAIN_VARIANT (type2)))
    6964            8 :     result_type = composite_type (TYPE_MAIN_VARIANT (type1),
    6965            8 :                                   TYPE_MAIN_VARIANT (type2));
    6966              : 
    6967       403758 :   if (!result_type)
    6968              :     {
    6969           22 :       if (flag_cond_mismatch)
    6970            0 :         result_type = void_type_node;
    6971              :       else
    6972              :         {
    6973           22 :           error_at (colon_loc, "type mismatch in conditional expression");
    6974           22 :           return error_mark_node;
    6975              :         }
    6976              :     }
    6977              : 
    6978              :   /* Merge const and volatile flags of the incoming types.  */
    6979       403758 :   result_type
    6980       403758 :     = build_type_variant (result_type,
    6981              :                           TYPE_READONLY (type1) || TYPE_READONLY (type2),
    6982              :                           TYPE_VOLATILE (type1) || TYPE_VOLATILE (type2));
    6983              : 
    6984       403758 :   op1 = ep_convert_and_check (colon_loc, result_type, op1,
    6985              :                               semantic_result_type);
    6986       403758 :   op2 = ep_convert_and_check (colon_loc, result_type, op2,
    6987              :                               semantic_result_type);
    6988              : 
    6989       403758 :   if (ifexp_bcp && ifexp == truthvalue_true_node)
    6990              :     {
    6991           10 :       op2_int_operands = true;
    6992           10 :       op1 = c_fully_fold (op1, require_constant_value, NULL);
    6993              :     }
    6994           59 :   if (ifexp_bcp && ifexp == truthvalue_false_node)
    6995              :     {
    6996           49 :       op1_int_operands = true;
    6997           49 :       op2 = c_fully_fold (op2, require_constant_value, NULL);
    6998              :     }
    6999       904653 :   int_const = int_operands = (ifexp_int_operands
    7000       403758 :                               && op1_int_operands
    7001       403758 :                               && op2_int_operands);
    7002        97137 :   if (int_operands)
    7003              :     {
    7004        97137 :       int_const = ((ifexp == truthvalue_true_node
    7005        58791 :                     && TREE_CODE (orig_op1) == INTEGER_CST
    7006        58777 :                     && !TREE_OVERFLOW (orig_op1))
    7007        97151 :                    || (ifexp == truthvalue_false_node
    7008        38300 :                        && TREE_CODE (orig_op2) == INTEGER_CST
    7009        38284 :                        && !TREE_OVERFLOW (orig_op2)));
    7010              :     }
    7011              : 
    7012              :   /* Need to convert condition operand into a vector mask.  */
    7013       403758 :   if (VECTOR_TYPE_P (TREE_TYPE (ifexp)))
    7014              :     {
    7015            0 :       tree vectype = TREE_TYPE (ifexp);
    7016            0 :       tree elem_type = TREE_TYPE (vectype);
    7017            0 :       tree zero = build_int_cst (elem_type, 0);
    7018            0 :       tree zero_vec = build_vector_from_val (vectype, zero);
    7019            0 :       tree cmp_type = truth_type_for (vectype);
    7020            0 :       ifexp = build2 (NE_EXPR, cmp_type, ifexp, zero_vec);
    7021              :     }
    7022              : 
    7023       403758 :   if (int_const || (ifexp_bcp && TREE_CODE (ifexp) == INTEGER_CST))
    7024        97093 :     ret = fold_build3_loc (colon_loc, COND_EXPR, result_type, ifexp, op1, op2);
    7025              :   else
    7026              :     {
    7027       306665 :       if (int_operands)
    7028              :         {
    7029              :           /* Use c_fully_fold here, since C_MAYBE_CONST_EXPR might be
    7030              :              nested inside of the expression.  */
    7031           76 :           op1 = c_fully_fold (op1, false, NULL);
    7032           76 :           op2 = c_fully_fold (op2, false, NULL);
    7033              :         }
    7034       306665 :       ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
    7035       306665 :       if (int_operands)
    7036           76 :         ret = note_integer_operands (ret);
    7037              :     }
    7038       403758 :   if (semantic_result_type)
    7039         4635 :     ret = build1 (EXCESS_PRECISION_EXPR, semantic_result_type, ret);
    7040              : 
    7041       403758 :   protected_set_expr_location (ret, colon_loc);
    7042              : 
    7043              :   /* If the OP1 and OP2 are the same and don't have side-effects,
    7044              :      warn here, because the COND_EXPR will be turned into OP1.  */
    7045       403758 :   if (warn_duplicated_branches
    7046           34 :       && TREE_CODE (ret) == COND_EXPR
    7047       403792 :       && (op1 == op2 || operand_equal_p (op1, op2, OEP_ADDRESS_OF_SAME_FIELD)))
    7048           13 :     warning_at (EXPR_LOCATION (ret), OPT_Wduplicated_branches,
    7049              :                 "this condition has identical branches");
    7050              : 
    7051              :   return ret;
    7052              : }
    7053              : 
    7054              : /* EXPR is an expression, location LOC, whose result is discarded.
    7055              :    Warn if it is a call to a nodiscard function (or a COMPOUND_EXPR
    7056              :    whose right-hand operand is such a call, possibly recursively).  */
    7057              : 
    7058              : static void
    7059      6485955 : maybe_warn_nodiscard (location_t loc, tree expr)
    7060              : {
    7061      6485955 :   if (VOID_TYPE_P (TREE_TYPE (expr)))
    7062              :     return;
    7063      3966541 :   while (TREE_CODE (expr) == COMPOUND_EXPR)
    7064              :     {
    7065        49456 :       expr = TREE_OPERAND (expr, 1);
    7066        49456 :       if (EXPR_HAS_LOCATION (expr))
    7067        32355 :         loc = EXPR_LOCATION (expr);
    7068              :     }
    7069      3917085 :   if (TREE_CODE (expr) != CALL_EXPR)
    7070              :     return;
    7071       347211 :   tree fn = CALL_EXPR_FN (expr);
    7072       347211 :   if (!fn)
    7073              :     return;
    7074       347195 :   tree attr;
    7075       347195 :   if (TREE_CODE (fn) == ADDR_EXPR
    7076       346528 :       && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
    7077       693723 :       && (attr = lookup_attribute ("nodiscard",
    7078       346528 :                                    DECL_ATTRIBUTES (TREE_OPERAND (fn, 0)))))
    7079              :     {
    7080            3 :       fn = TREE_OPERAND (fn, 0);
    7081            3 :       tree args = TREE_VALUE (attr);
    7082            3 :       if (args)
    7083            1 :         args = TREE_VALUE (args);
    7084            3 :       auto_diagnostic_group d;
    7085            3 :       auto_urlify_attributes sentinel;
    7086            3 :       int warned;
    7087            3 :       if (args)
    7088            1 :         warned = warning_at (loc, OPT_Wunused_result,
    7089              :                              "ignoring return value of %qD, declared with "
    7090              :                              "attribute %<nodiscard%>: %E", fn, args);
    7091              :       else
    7092            2 :         warned = warning_at (loc, OPT_Wunused_result,
    7093              :                              "ignoring return value of %qD, declared with "
    7094              :                              "attribute %<nodiscard%>", fn);
    7095            3 :       if (warned)
    7096            3 :         inform (DECL_SOURCE_LOCATION (fn), "declared here");
    7097            3 :     }
    7098              :   else
    7099              :     {
    7100       347192 :       tree rettype = TREE_TYPE (TREE_TYPE (TREE_TYPE (fn)));
    7101       347192 :       attr = lookup_attribute ("nodiscard", TYPE_ATTRIBUTES (rettype));
    7102       347192 :       if (!attr)
    7103       347180 :         return;
    7104           12 :       tree args = TREE_VALUE (attr);
    7105           12 :       if (args)
    7106            5 :         args = TREE_VALUE (args);
    7107           12 :       auto_diagnostic_group d;
    7108           12 :       auto_urlify_attributes sentinel;
    7109           12 :       int warned;
    7110           12 :       if (args)
    7111            5 :         warned = warning_at (loc, OPT_Wunused_result,
    7112              :                              "ignoring return value of type %qT, declared "
    7113              :                              "with attribute %<nodiscard%>: %E",
    7114              :                              rettype, args);
    7115              :       else
    7116            7 :         warned = warning_at (loc, OPT_Wunused_result,
    7117              :                              "ignoring return value of type %qT, declared "
    7118              :                              "with attribute %<nodiscard%>", rettype);
    7119           12 :       if (warned)
    7120              :         {
    7121           12 :           if (TREE_CODE (fn) == ADDR_EXPR)
    7122              :             {
    7123           11 :               fn = TREE_OPERAND (fn, 0);
    7124           11 :               if (TREE_CODE (fn) == FUNCTION_DECL)
    7125           11 :                 inform (DECL_SOURCE_LOCATION (fn),
    7126              :                         "in call to %qD, declared here", fn);
    7127              :             }
    7128              :         }
    7129           12 :     }
    7130              : }
    7131              : 
    7132              : /* Return a compound expression that performs two expressions and
    7133              :    returns the value of the second of them.
    7134              : 
    7135              :    LOC is the location of the COMPOUND_EXPR.  */
    7136              : 
    7137              : tree
    7138       111820 : build_compound_expr (location_t loc, tree expr1, tree expr2)
    7139              : {
    7140       111820 :   bool expr1_int_operands, expr2_int_operands;
    7141       111820 :   tree eptype = NULL_TREE;
    7142       111820 :   tree ret;
    7143              : 
    7144       111820 :   expr1_int_operands = EXPR_INT_CONST_OPERANDS (expr1);
    7145          326 :   if (expr1_int_operands)
    7146          326 :     expr1 = remove_c_maybe_const_expr (expr1);
    7147       111820 :   expr2_int_operands = EXPR_INT_CONST_OPERANDS (expr2);
    7148        66109 :   if (expr2_int_operands)
    7149        66109 :     expr2 = remove_c_maybe_const_expr (expr2);
    7150              : 
    7151       111820 :   if (TREE_CODE (expr1) == EXCESS_PRECISION_EXPR)
    7152            0 :     expr1 = TREE_OPERAND (expr1, 0);
    7153       111820 :   if (TREE_CODE (expr2) == EXCESS_PRECISION_EXPR)
    7154              :     {
    7155            1 :       eptype = TREE_TYPE (expr2);
    7156            1 :       expr2 = TREE_OPERAND (expr2, 0);
    7157              :     }
    7158              : 
    7159       111820 :   if (!TREE_SIDE_EFFECTS (expr1))
    7160              :     {
    7161              :       /* The left-hand operand of a comma expression is like an expression
    7162              :          statement: with -Wunused, we should warn if it doesn't have
    7163              :          any side-effects, unless it was explicitly cast to (void).  */
    7164         8426 :       if (warn_unused_value)
    7165              :         {
    7166         1277 :           if (VOID_TYPE_P (TREE_TYPE (expr1))
    7167         1277 :               && CONVERT_EXPR_P (expr1))
    7168              :             ; /* (void) a, b */
    7169           14 :           else if (VOID_TYPE_P (TREE_TYPE (expr1))
    7170            4 :                    && TREE_CODE (expr1) == COMPOUND_EXPR
    7171           17 :                    && CONVERT_EXPR_P (TREE_OPERAND (expr1, 1)))
    7172              :             ; /* (void) a, (void) b, c */
    7173              :           else
    7174           11 :             warning_at (loc, OPT_Wunused_value,
    7175              :                         "left-hand operand of comma expression has no effect");
    7176              :         }
    7177              :     }
    7178       103394 :   else if (TREE_CODE (expr1) == COMPOUND_EXPR
    7179        13111 :            && warn_unused_value)
    7180              :     {
    7181              :       tree r = expr1;
    7182              :       location_t cloc = loc;
    7183         4833 :       while (TREE_CODE (r) == COMPOUND_EXPR)
    7184              :         {
    7185         2417 :           if (EXPR_HAS_LOCATION (r))
    7186         2417 :             cloc = EXPR_LOCATION (r);
    7187         2417 :           r = TREE_OPERAND (r, 1);
    7188              :         }
    7189         2416 :       if (!TREE_SIDE_EFFECTS (r)
    7190            4 :           && !VOID_TYPE_P (TREE_TYPE (r))
    7191         2420 :           && !CONVERT_EXPR_P (r))
    7192            4 :         warning_at (cloc, OPT_Wunused_value,
    7193              :                     "right-hand operand of comma expression has no effect");
    7194              :     }
    7195              : 
    7196              :   /* With -Wunused, we should also warn if the left-hand operand does have
    7197              :      side-effects, but computes a value which is not used.  For example, in
    7198              :      `foo() + bar(), baz()' the result of the `+' operator is not used,
    7199              :      so we should issue a warning.  */
    7200       100978 :   else if (warn_unused_value)
    7201        35403 :     warn_if_unused_value (expr1, loc);
    7202              : 
    7203       111820 :   maybe_warn_nodiscard (loc, expr1);
    7204              : 
    7205       111820 :   if (expr2 == error_mark_node)
    7206              :     return error_mark_node;
    7207              : 
    7208       111807 :   ret = build2 (COMPOUND_EXPR, TREE_TYPE (expr2), expr1, expr2);
    7209              : 
    7210       111807 :   if (flag_isoc99
    7211              :       && expr1_int_operands
    7212       111351 :       && expr2_int_operands)
    7213          153 :     ret = note_integer_operands (ret);
    7214              : 
    7215       111807 :   if (eptype)
    7216            1 :     ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
    7217              : 
    7218       111807 :   protected_set_expr_location (ret, loc);
    7219       111807 :   return ret;
    7220              : }
    7221              : 
    7222              : /* Issue -Wcast-qual warnings when appropriate.  TYPE is the type to
    7223              :    which we are casting.  OTYPE is the type of the expression being
    7224              :    cast.  Both TYPE and OTYPE are pointer types.  LOC is the location
    7225              :    of the cast.  -Wcast-qual appeared on the command line.  Named
    7226              :    address space qualifiers are not handled here, because they result
    7227              :    in different warnings.  */
    7228              : 
    7229              : static void
    7230        13581 : handle_warn_cast_qual (location_t loc, tree type, tree otype)
    7231              : {
    7232        13581 :   tree in_type = type;
    7233        13581 :   tree in_otype = otype;
    7234        13581 :   int added = 0;
    7235        13581 :   int discarded = 0;
    7236        13751 :   bool is_const;
    7237              : 
    7238              :   /* Check that the qualifiers on IN_TYPE are a superset of the
    7239              :      qualifiers of IN_OTYPE.  The outermost level of POINTER_TYPE
    7240              :      nodes is uninteresting and we stop as soon as we hit a
    7241              :      non-POINTER_TYPE node on either type.  */
    7242        13751 :   do
    7243              :     {
    7244        13751 :       in_otype = TREE_TYPE (in_otype);
    7245        13751 :       in_type = TREE_TYPE (in_type);
    7246              : 
    7247              :       /* GNU C allows cv-qualified function types.  'const' means the
    7248              :          function is very pure, 'volatile' means it can't return.  We
    7249              :          need to warn when such qualifiers are added, not when they're
    7250              :          taken away.  */
    7251        13751 :       if (TREE_CODE (in_otype) == FUNCTION_TYPE
    7252           26 :           && TREE_CODE (in_type) == FUNCTION_TYPE)
    7253           18 :         added |= (TYPE_QUALS_NO_ADDR_SPACE (in_type)
    7254           18 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (in_otype));
    7255              :       else
    7256        13733 :         discarded |= (TYPE_QUALS_NO_ADDR_SPACE (in_otype)
    7257        13733 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (in_type));
    7258              :     }
    7259        13751 :   while (TREE_CODE (in_type) == POINTER_TYPE
    7260        13751 :          && TREE_CODE (in_otype) == POINTER_TYPE);
    7261              : 
    7262        13581 :   if (added)
    7263            2 :     warning_at (loc, OPT_Wcast_qual,
    7264              :                 "cast adds %q#v qualifier to function type", added);
    7265              : 
    7266        13581 :   if (discarded)
    7267              :     /* There are qualifiers present in IN_OTYPE that are not present
    7268              :        in IN_TYPE.  */
    7269         1117 :     warning_at (loc, OPT_Wcast_qual,
    7270              :                 "cast discards %qv qualifier from pointer target type",
    7271              :                 discarded);
    7272              : 
    7273        13581 :   if (added || discarded)
    7274              :     return;
    7275              : 
    7276              :   /* A cast from **T to const **T is unsafe, because it can cause a
    7277              :      const value to be changed with no additional warning.  We only
    7278              :      issue this warning if T is the same on both sides, and we only
    7279              :      issue the warning if there are the same number of pointers on
    7280              :      both sides, as otherwise the cast is clearly unsafe anyhow.  A
    7281              :      cast is unsafe when a qualifier is added at one level and const
    7282              :      is not present at all outer levels.
    7283              : 
    7284              :      To issue this warning, we check at each level whether the cast
    7285              :      adds new qualifiers not already seen.  We don't need to special
    7286              :      case function types, as they won't have the same
    7287              :      TYPE_MAIN_VARIANT.  */
    7288              : 
    7289        12462 :   if (TYPE_MAIN_VARIANT (in_type) != TYPE_MAIN_VARIANT (in_otype))
    7290              :     return;
    7291          227 :   if (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE)
    7292              :     return;
    7293              : 
    7294           48 :   in_type = type;
    7295           48 :   in_otype = otype;
    7296           48 :   is_const = TYPE_READONLY (TREE_TYPE (in_type));
    7297          130 :   do
    7298              :     {
    7299          130 :       in_type = TREE_TYPE (in_type);
    7300          130 :       in_otype = TREE_TYPE (in_otype);
    7301          130 :       if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0
    7302          130 :           && !is_const)
    7303              :         {
    7304           27 :           warning_at (loc, OPT_Wcast_qual,
    7305              :                       "to be safe all intermediate pointers in cast from "
    7306              :                       "%qT to %qT must be %<const%> qualified",
    7307              :                       otype, type);
    7308           27 :           break;
    7309              :         }
    7310          103 :       if (is_const)
    7311           72 :         is_const = TYPE_READONLY (in_type);
    7312              :     }
    7313          103 :   while (TREE_CODE (in_type) == POINTER_TYPE);
    7314              : }
    7315              : 
    7316              : /* Heuristic check if two parameter types can be considered ABI-equivalent.  */
    7317              : 
    7318              : static bool
    7319         1312 : c_safe_arg_type_equiv_p (tree t1, tree t2)
    7320              : {
    7321         1312 :   if (error_operand_p (t1) || error_operand_p (t2))
    7322              :     return true;
    7323              : 
    7324         1311 :   t1 = TYPE_MAIN_VARIANT (t1);
    7325         1311 :   t2 = TYPE_MAIN_VARIANT (t2);
    7326              : 
    7327         1311 :   if (TREE_CODE (t1) == POINTER_TYPE
    7328          229 :       && TREE_CODE (t2) == POINTER_TYPE)
    7329              :     return true;
    7330              : 
    7331              :   /* Only the precision of the parameter matters.  This check should
    7332              :      make sure that the callee does not see undefined values in argument
    7333              :      registers.  */
    7334         1103 :   if (INTEGRAL_TYPE_P (t1)
    7335          913 :       && INTEGRAL_TYPE_P (t2)
    7336         1448 :       && TYPE_PRECISION (t1) == TYPE_PRECISION (t2))
    7337              :     return true;
    7338              : 
    7339          938 :   return comptypes (t1, t2);
    7340              : }
    7341              : 
    7342              : /* Check if a type cast between two function types can be considered safe.  */
    7343              : 
    7344              : static bool
    7345         7559 : c_safe_function_type_cast_p (tree t1, tree t2)
    7346              : {
    7347         7559 :   if (TREE_TYPE (t1) == void_type_node &&
    7348         5561 :       TYPE_ARG_TYPES (t1) == void_list_node)
    7349              :     return true;
    7350              : 
    7351         3722 :   if (TREE_TYPE (t2) == void_type_node &&
    7352         2889 :       TYPE_ARG_TYPES (t2) == void_list_node)
    7353              :     return true;
    7354              : 
    7355          892 :   if (!c_safe_arg_type_equiv_p (TREE_TYPE (t1), TREE_TYPE (t2)))
    7356              :     return false;
    7357              : 
    7358          197 :   for (t1 = TYPE_ARG_TYPES (t1), t2 = TYPE_ARG_TYPES (t2);
    7359          513 :        t1 && t2;
    7360          316 :        t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
    7361          420 :     if (!c_safe_arg_type_equiv_p (TREE_VALUE (t1), TREE_VALUE (t2)))
    7362              :       return false;
    7363              : 
    7364              :   return true;
    7365              : }
    7366              : 
    7367              : /* Build an expression representing a cast to type TYPE of expression EXPR.
    7368              :    LOC is the location of the cast-- typically the open paren of the cast.  */
    7369              : 
    7370              : tree
    7371    120278418 : build_c_cast (location_t loc, tree type, tree expr)
    7372              : {
    7373    120278418 :   tree value;
    7374              : 
    7375    120278418 :   bool int_operands = EXPR_INT_CONST_OPERANDS (expr);
    7376              : 
    7377    120278418 :   if (TREE_CODE (expr) == EXCESS_PRECISION_EXPR)
    7378           66 :     expr = TREE_OPERAND (expr, 0);
    7379              : 
    7380    120278418 :   value = expr;
    7381    120278418 :   if (int_operands)
    7382      6874554 :     value = remove_c_maybe_const_expr (value);
    7383              : 
    7384    120278418 :   if (type == error_mark_node || expr == error_mark_node)
    7385              :     return error_mark_node;
    7386              : 
    7387              :   /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
    7388              :      only in <protocol> qualifications.  But when constructing cast expressions,
    7389              :      the protocols do matter and must be kept around.  */
    7390    120277398 :   if (objc_is_object_ptr (type) && objc_is_object_ptr (TREE_TYPE (expr)))
    7391            0 :     return build1 (NOP_EXPR, type, expr);
    7392              : 
    7393    120277398 :   type = TYPE_MAIN_VARIANT (type);
    7394              : 
    7395    120277398 :   if (TREE_CODE (type) == ARRAY_TYPE)
    7396              :     {
    7397           13 :       error_at (loc, "cast specifies array type");
    7398           13 :       return error_mark_node;
    7399              :     }
    7400              : 
    7401    120277385 :   if (TREE_CODE (type) == FUNCTION_TYPE)
    7402              :     {
    7403            6 :       error_at (loc, "cast specifies function type");
    7404            6 :       return error_mark_node;
    7405              :     }
    7406              : 
    7407    120277379 :   if (!VOID_TYPE_P (type))
    7408              :     {
    7409    120232849 :       value = require_complete_type (loc, value);
    7410    120232849 :       if (value == error_mark_node)
    7411              :         return error_mark_node;
    7412              :     }
    7413              : 
    7414    120277378 :   if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
    7415              :     {
    7416     18124979 :       if (RECORD_OR_UNION_TYPE_P (type)
    7417     18124979 :           && pedwarn (loc, OPT_Wpedantic,
    7418              :                       "ISO C forbids casting nonscalar to the same type"))
    7419              :               ;
    7420     18124975 :       else if (warn_useless_cast && c_inhibit_evaluation_warnings == 0)
    7421            8 :         warning_at (loc, OPT_Wuseless_cast,
    7422              :                     "useless cast to type %qT", type);
    7423              : 
    7424              :       /* Convert to remove any qualifiers from VALUE's type.  */
    7425     18124979 :       value = convert (type, value);
    7426              :     }
    7427    102152399 :   else if (TREE_CODE (type) == UNION_TYPE)
    7428              :     {
    7429          137 :       tree field;
    7430              : 
    7431          192 :       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    7432          185 :         if (TREE_TYPE (field) != error_mark_node
    7433          369 :             && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
    7434          184 :                           TYPE_MAIN_VARIANT (TREE_TYPE (value))))
    7435              :           break;
    7436              : 
    7437          137 :       if (field)
    7438              :         {
    7439          130 :           tree t;
    7440          130 :           bool maybe_const = true;
    7441              : 
    7442          130 :           pedwarn (loc, OPT_Wpedantic, "ISO C forbids casts to union type");
    7443          130 :           t = c_fully_fold (value, false, &maybe_const);
    7444          130 :           t = build_constructor_single (type, field, t);
    7445          130 :           if (!maybe_const)
    7446           15 :             t = c_wrap_maybe_const (t, true);
    7447          130 :           t = digest_init (loc, field, type, t,
    7448              :                            NULL_TREE, false, false, false, true, false, false);
    7449          130 :           TREE_CONSTANT (t) = TREE_CONSTANT (value);
    7450          130 :           return t;
    7451              :         }
    7452            7 :       error_at (loc, "cast to union type from type not present in union");
    7453            7 :       return error_mark_node;
    7454              :     }
    7455              :   else
    7456              :     {
    7457    102152262 :       tree otype, ovalue;
    7458              : 
    7459    102152262 :       if (type == void_type_node)
    7460              :         {
    7461        18560 :           tree t = build1 (CONVERT_EXPR, type, value);
    7462        18560 :           SET_EXPR_LOCATION (t, loc);
    7463        18560 :           return t;
    7464              :         }
    7465              : 
    7466    102133702 :       otype = TREE_TYPE (value);
    7467              : 
    7468              :       /* Optionally warn about potentially worrisome casts.  */
    7469    102133702 :       if (warn_cast_qual
    7470       179871 :           && TREE_CODE (type) == POINTER_TYPE
    7471        26837 :           && TREE_CODE (otype) == POINTER_TYPE)
    7472        13581 :         handle_warn_cast_qual (loc, type, otype);
    7473              : 
    7474              :       /* Warn about conversions between pointers to disjoint
    7475              :          address spaces.  */
    7476    102133702 :       if (TREE_CODE (type) == POINTER_TYPE
    7477      3335103 :           && TREE_CODE (otype) == POINTER_TYPE
    7478    105122508 :           && !null_pointer_constant_p (value))
    7479              :         {
    7480      2934957 :           addr_space_t as_to = TYPE_ADDR_SPACE (TREE_TYPE (type));
    7481      2934957 :           addr_space_t as_from = TYPE_ADDR_SPACE (TREE_TYPE (otype));
    7482      2934957 :           addr_space_t as_common;
    7483              : 
    7484      2934957 :           if (!addr_space_superset (as_to, as_from, &as_common))
    7485              :             {
    7486            0 :               if (ADDR_SPACE_GENERIC_P (as_from))
    7487            0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    7488              :                             "from disjoint generic address space pointer",
    7489              :                             c_addr_space_name (as_to));
    7490              : 
    7491            0 :               else if (ADDR_SPACE_GENERIC_P (as_to))
    7492            0 :                 warning_at (loc, 0, "cast to generic address space pointer "
    7493              :                             "from disjoint %qs address space pointer",
    7494              :                             c_addr_space_name (as_from));
    7495              : 
    7496              :               else
    7497            0 :                 warning_at (loc, 0, "cast to %qs address space pointer "
    7498              :                             "from disjoint %qs address space pointer",
    7499              :                             c_addr_space_name (as_to),
    7500              :                             c_addr_space_name (as_from));
    7501              :             }
    7502              : 
    7503              :           /* Warn of new allocations that are not big enough for the target
    7504              :              type.  */
    7505      2934957 :           if (warn_alloc_size && TREE_CODE (value) == CALL_EXPR)
    7506         1069 :             if (tree fndecl = get_callee_fndecl (value))
    7507         1065 :               if (DECL_IS_MALLOC (fndecl))
    7508              :                 {
    7509          573 :                   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    7510          573 :                   tree alloc_size = lookup_attribute ("alloc_size", attrs);
    7511          573 :                   if (alloc_size)
    7512          215 :                     warn_for_alloc_size (loc, TREE_TYPE (type), value,
    7513              :                                          alloc_size);
    7514              :                 }
    7515              :         }
    7516              : 
    7517              :       /* Warn about possible alignment problems.  */
    7518    102133702 :       if ((STRICT_ALIGNMENT || warn_cast_align == 2)
    7519            7 :           && TREE_CODE (type) == POINTER_TYPE
    7520            7 :           && TREE_CODE (otype) == POINTER_TYPE
    7521            7 :           && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
    7522            7 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    7523              :           /* Don't warn about opaque types, where the actual alignment
    7524              :              restriction is unknown.  */
    7525           12 :           && !(RECORD_OR_UNION_TYPE_P (TREE_TYPE (otype))
    7526            5 :                && TYPE_MODE (TREE_TYPE (otype)) == VOIDmode)
    7527    102133716 :           && min_align_of_type (TREE_TYPE (type))
    7528            7 :              > min_align_of_type (TREE_TYPE (otype)))
    7529            5 :         warning_at (loc, OPT_Wcast_align,
    7530              :                     "cast increases required alignment of target type");
    7531              : 
    7532    102133702 :       if ((TREE_CODE (type) == INTEGER_TYPE
    7533    102133702 :            || TREE_CODE (type) == BITINT_TYPE)
    7534      7089827 :           && TREE_CODE (otype) == POINTER_TYPE
    7535    102158980 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
    7536              :       /* Unlike conversion of integers to pointers, where the
    7537              :          warning is disabled for converting constants because
    7538              :          of cases such as SIG_*, warn about converting constant
    7539              :          pointers to integers. In some cases it may cause unwanted
    7540              :          sign extension, and a warning is appropriate.  */
    7541         1450 :         warning_at (loc, OPT_Wpointer_to_int_cast,
    7542              :                     "cast from pointer to integer of different size");
    7543              : 
    7544    102133702 :       if ((TREE_CODE (value) == CALL_EXPR
    7545     34675245 :            && !is_access_with_size_p (value))
    7546    136808945 :           && TREE_CODE (type) != TREE_CODE (otype))
    7547         2306 :         warning_at (loc, OPT_Wbad_function_cast,
    7548              :                     "cast from function call of type %qT "
    7549              :                     "to non-matching type %qT", otype, type);
    7550              : 
    7551    102133702 :       if (TREE_CODE (type) == POINTER_TYPE
    7552      3335103 :           && (TREE_CODE (otype) == INTEGER_TYPE
    7553      3335103 :               || TREE_CODE (otype) == BITINT_TYPE)
    7554       346211 :           && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
    7555              :           /* Don't warn about converting any constant.  */
    7556    102442199 :           && !TREE_CONSTANT (value))
    7557          407 :         warning_at (loc,
    7558          407 :                     OPT_Wint_to_pointer_cast, "cast to pointer from integer "
    7559              :                     "of different size");
    7560              : 
    7561    102133702 :       if (warn_strict_aliasing <= 2)
    7562     93598124 :         strict_aliasing_warning (EXPR_LOCATION (value), type, expr);
    7563              : 
    7564              :       /* If pedantic, warn for conversions between function and object
    7565              :          pointer types, except for converting a null pointer constant
    7566              :          to function pointer type.  */
    7567    102133702 :       if (pedantic
    7568       238453 :           && TREE_CODE (type) == POINTER_TYPE
    7569       143951 :           && TREE_CODE (otype) == POINTER_TYPE
    7570         2620 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    7571    102133723 :           && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)
    7572           18 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    7573              :                  "conversion of function pointer to object pointer type");
    7574              : 
    7575    102133702 :       if (pedantic
    7576       238453 :           && TREE_CODE (type) == POINTER_TYPE
    7577       143951 :           && TREE_CODE (otype) == POINTER_TYPE
    7578         2620 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    7579           13 :           && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
    7580    102133712 :           && !null_pointer_constant_p (value))
    7581            4 :         pedwarn (loc, OPT_Wpedantic, "ISO C forbids "
    7582              :                  "conversion of object pointer to function pointer type");
    7583              : 
    7584    102133702 :       if (TREE_CODE (type) == POINTER_TYPE
    7585      3335103 :           && TREE_CODE (otype) == POINTER_TYPE
    7586      2988806 :           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
    7587         8680 :           && TREE_CODE (TREE_TYPE (otype)) == FUNCTION_TYPE
    7588    102141261 :           && !c_safe_function_type_cast_p (TREE_TYPE (type),
    7589         7559 :                                            TREE_TYPE (otype)))
    7590          799 :         warning_at (loc, OPT_Wcast_function_type,
    7591              :                     "cast between incompatible function types"
    7592              :                     " from %qT to %qT", otype, type);
    7593              : 
    7594    102133702 :       ovalue = value;
    7595              :       /* If converting to boolean a value with integer operands that
    7596              :          is not itself represented as an INTEGER_CST, the call below
    7597              :          to note_integer_operands may insert a C_MAYBE_CONST_EXPR, but
    7598              :          build_binary_op as called by c_common_truthvalue_conversion
    7599              :          may also insert a C_MAYBE_CONST_EXPR to indicate that a
    7600              :          subexpression has been fully folded.  To avoid nested
    7601              :          C_MAYBE_CONST_EXPR, ensure that
    7602              :          c_objc_common_truthvalue_conversion receives an argument
    7603              :          properly marked as having integer operands in that case.  */
    7604    102133702 :       if (int_operands
    7605      6684242 :           && TREE_CODE (value) != INTEGER_CST
    7606    102133744 :           && (TREE_CODE (type) == BOOLEAN_TYPE
    7607           28 :               || (TREE_CODE (type) == ENUMERAL_TYPE
    7608           14 :                   && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
    7609           14 :                   && TREE_CODE (ENUM_UNDERLYING_TYPE (type)) == BOOLEAN_TYPE)))
    7610           28 :         value = note_integer_operands (value);
    7611    102133702 :       value = convert (type, value);
    7612              : 
    7613              :       /* Ignore any integer overflow caused by the cast.  */
    7614    102133702 :       if (TREE_CODE (value) == INTEGER_CST && !FLOAT_TYPE_P (otype))
    7615              :         {
    7616      6630886 :           if (TREE_OVERFLOW_P (ovalue))
    7617              :             {
    7618            9 :               if (!TREE_OVERFLOW (value))
    7619              :                 {
    7620              :                   /* Avoid clobbering a shared constant.  */
    7621            0 :                   value = copy_node (value);
    7622            0 :                   TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
    7623              :                 }
    7624              :             }
    7625      6630877 :           else if (TREE_OVERFLOW (value))
    7626              :             /* Reset VALUE's overflow flags, ensuring constant sharing.  */
    7627         3085 :             value = wide_int_to_tree (TREE_TYPE (value), wi::to_wide (value));
    7628              :         }
    7629              :     }
    7630              : 
    7631              :   /* Don't let a cast be an lvalue.  */
    7632    120258681 :   if (lvalue_p (value))
    7633        90693 :     value = non_lvalue_loc (loc, value);
    7634              : 
    7635              :   /* Don't allow the results of casting to floating-point or complex
    7636              :      types be confused with actual constants, or casts involving
    7637              :      integer and pointer types other than direct integer-to-integer
    7638              :      and integer-to-pointer be confused with integer constant
    7639              :      expressions and null pointer constants.  */
    7640    120258681 :   if (TREE_CODE (value) == REAL_CST
    7641    120208738 :       || TREE_CODE (value) == COMPLEX_CST
    7642    240444796 :       || (TREE_CODE (value) == INTEGER_CST
    7643      6879904 :           && !((TREE_CODE (expr) == INTEGER_CST
    7644      6806315 :                 && INTEGRAL_TYPE_P (TREE_TYPE (expr)))
    7645        66186 :                || TREE_CODE (expr) == REAL_CST
    7646              :                || TREE_CODE (expr) == COMPLEX_CST)))
    7647       134385 :       value = build1 (NOP_EXPR, type, value);
    7648              : 
    7649              :   /* If the expression has integer operands and so can occur in an
    7650              :      unevaluated part of an integer constant expression, ensure the
    7651              :      return value reflects this.  */
    7652    120258681 :   if (int_operands
    7653      6860610 :       && INTEGRAL_TYPE_P (type)
    7654      6414712 :       && value != error_mark_node
    7655    126673392 :       && !EXPR_INT_CONST_OPERANDS (value))
    7656           11 :     value = note_integer_operands (value);
    7657              : 
    7658    120258681 :   protected_set_expr_location (value, loc);
    7659    120258681 :   return value;
    7660              : }
    7661              : 
    7662              : /* Interpret a cast of expression EXPR to type TYPE.  LOC is the
    7663              :    location of the open paren of the cast, or the position of the cast
    7664              :    expr.  */
    7665              : tree
    7666    120277922 : c_cast_expr (location_t loc, struct c_type_name *type_name, tree expr)
    7667              : {
    7668    120277922 :   tree type;
    7669    120277922 :   tree type_expr = NULL_TREE;
    7670    120277922 :   bool type_expr_const = true;
    7671    120277922 :   tree ret;
    7672    120277922 :   int saved_wsp = warn_strict_prototypes;
    7673              : 
    7674              :   /* This avoids warnings about unprototyped casts on
    7675              :      integers.  E.g. "#define SIG_DFL (void(*)())0".  */
    7676    120277922 :   if (TREE_CODE (expr) == INTEGER_CST)
    7677      6928514 :     warn_strict_prototypes = 0;
    7678    120277922 :   type = groktypename (type_name, &type_expr, &type_expr_const);
    7679    120277922 :   warn_strict_prototypes = saved_wsp;
    7680              : 
    7681       765020 :   if (TREE_CODE (expr) == ADDR_EXPR && !VOID_TYPE_P (type)
    7682    121042687 :       && reject_gcc_builtin (expr))
    7683            2 :     return error_mark_node;
    7684              : 
    7685    120277920 :   ret = build_c_cast (loc, type, expr);
    7686    120277920 :   if (ret == error_mark_node)
    7687              :     return error_mark_node;
    7688              : 
    7689    120276760 :   if (type_expr)
    7690              :     {
    7691          250 :       bool inner_expr_const = true;
    7692          250 :       ret = c_fully_fold (ret, require_constant_value, &inner_expr_const);
    7693          250 :       ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (ret), type_expr, ret);
    7694          500 :       C_MAYBE_CONST_EXPR_NON_CONST (ret) = !(type_expr_const
    7695          145 :                                              && inner_expr_const);
    7696          250 :       SET_EXPR_LOCATION (ret, loc);
    7697              :     }
    7698              : 
    7699    120276760 :   if (!EXPR_HAS_LOCATION (ret))
    7700      6806860 :     protected_set_expr_location (ret, loc);
    7701              : 
    7702              :   /* C++ does not permits types to be defined in a cast, but it
    7703              :      allows references to incomplete types.  */
    7704    120276760 :   if (warn_cxx_compat && type_name->specs->typespec_kind == ctsk_tagdef)
    7705            1 :     warning_at (loc, OPT_Wc___compat,
    7706              :                 "defining a type in a cast is invalid in C++");
    7707              : 
    7708              :   return ret;
    7709              : }
    7710              : 
    7711              : /* Build an assignment expression of lvalue LHS from value RHS.
    7712              :    If LHS_ORIGTYPE is not NULL, it is the original type of LHS, which
    7713              :    may differ from TREE_TYPE (LHS) for an enum bitfield.
    7714              :    MODIFYCODE is the code for a binary operator that we use
    7715              :    to combine the old value of LHS with RHS to get the new value.
    7716              :    Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.
    7717              :    If RHS_ORIGTYPE is not NULL_TREE, it is the original type of RHS,
    7718              :    which may differ from TREE_TYPE (RHS) for an enum value.
    7719              : 
    7720              :    LOCATION is the location of the MODIFYCODE operator.
    7721              :    RHS_LOC is the location of the RHS.  */
    7722              : 
    7723              : tree
    7724      2905712 : build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
    7725              :                    enum tree_code modifycode,
    7726              :                    location_t rhs_loc, tree rhs, tree rhs_origtype)
    7727              : {
    7728      2905712 :   tree result;
    7729      2905712 :   tree newrhs;
    7730      2905712 :   tree rhseval = NULL_TREE;
    7731      2905712 :   tree lhstype = TREE_TYPE (lhs);
    7732      2905712 :   tree olhstype = lhstype;
    7733      2905712 :   bool npc;
    7734      2905712 :   bool is_atomic_op;
    7735              : 
    7736              :   /* Types that aren't fully specified cannot be used in assignments.  */
    7737      2905712 :   lhs = require_complete_type (location, lhs);
    7738      2905712 :   rhs = require_complete_type (location, rhs);
    7739              : 
    7740              :   /* Avoid duplicate error messages from operands that had errors.  */
    7741      2905712 :   if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
    7742          473 :     return error_mark_node;
    7743              : 
    7744              :   /* Ensure an error for assigning a non-lvalue array to an array in
    7745              :      C90.  */
    7746      2905239 :   if (TREE_CODE (lhstype) == ARRAY_TYPE)
    7747              :     {
    7748            1 :       error_at (location, "assignment to expression with array type");
    7749            1 :       return error_mark_node;
    7750              :     }
    7751              : 
    7752              :   /* For ObjC properties, defer this check.  */
    7753      2905238 :   if (!objc_is_property_ref (lhs) && !lvalue_or_else (location, lhs, lv_assign))
    7754           32 :     return error_mark_node;
    7755              : 
    7756      2905206 :   is_atomic_op = really_atomic_lvalue (lhs);
    7757              : 
    7758      2905206 :   newrhs = rhs;
    7759              : 
    7760      2905206 :   if (TREE_CODE (lhs) == C_MAYBE_CONST_EXPR)
    7761              :     {
    7762            2 :       tree inner = build_modify_expr (location, C_MAYBE_CONST_EXPR_EXPR (lhs),
    7763              :                                       lhs_origtype, modifycode, rhs_loc, rhs,
    7764              :                                       rhs_origtype);
    7765            2 :       if (inner == error_mark_node)
    7766              :         return error_mark_node;
    7767            4 :       result = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner),
    7768            2 :                        C_MAYBE_CONST_EXPR_PRE (lhs), inner);
    7769            2 :       gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (lhs));
    7770            2 :       C_MAYBE_CONST_EXPR_NON_CONST (result) = 1;
    7771            2 :       protected_set_expr_location (result, location);
    7772            2 :       return result;
    7773              :     }
    7774              : 
    7775              :   /* If a binary op has been requested, combine the old LHS value with the RHS
    7776              :      producing the value we should actually store into the LHS.  */
    7777              : 
    7778      2905204 :   if (modifycode != NOP_EXPR)
    7779              :     {
    7780       215598 :       lhs = c_fully_fold (lhs, false, NULL, true);
    7781       215598 :       lhs = stabilize_reference (lhs);
    7782              : 
    7783              :       /* Construct the RHS for any non-atomic compound assignment. */
    7784       215598 :       if (!is_atomic_op)
    7785              :         {
    7786              :           /* If in LHS op= RHS the RHS has side-effects, ensure they
    7787              :              are preevaluated before the rest of the assignment expression's
    7788              :              side-effects, because RHS could contain e.g. function calls
    7789              :              that modify LHS.  */
    7790       200113 :           if (TREE_SIDE_EFFECTS (rhs))
    7791              :             {
    7792         8816 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7793           28 :                 newrhs = save_expr (TREE_OPERAND (rhs, 0));
    7794              :               else
    7795         8788 :                 newrhs = save_expr (rhs);
    7796         8816 :               rhseval = newrhs;
    7797         8816 :               if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    7798           28 :                 newrhs = build1 (EXCESS_PRECISION_EXPR, TREE_TYPE (rhs),
    7799              :                                  newrhs);
    7800              :             }
    7801       200113 :           bool clear_decl_read = false;
    7802        88515 :           if ((VAR_P (lhs) || TREE_CODE (lhs) == PARM_DECL)
    7803       153754 :               && !DECL_READ_P (lhs)
    7804       252477 :               && (VAR_P (lhs) ? warn_unused_but_set_variable
    7805              :                               : warn_unused_but_set_parameter) > 2)
    7806              :             {
    7807        21582 :               mark_exp_read (newrhs);
    7808        21582 :               if (!DECL_READ_P (lhs))
    7809       200113 :                 clear_decl_read = true;
    7810              :             }
    7811              : 
    7812       200113 :           newrhs = build_binary_op (location, modifycode,
    7813              :                                     convert_lvalue_to_rvalue (location, lhs,
    7814              :                                                               true, true),
    7815              :                                     newrhs, true);
    7816       200113 :           if (clear_decl_read)
    7817        21582 :             DECL_READ_P (lhs) = 0;
    7818              : 
    7819              :           /* The original type of the right hand side is no longer
    7820              :              meaningful.  */
    7821              :           rhs_origtype = NULL_TREE;
    7822              :         }
    7823              :     }
    7824              : 
    7825      2905204 :   if (c_dialect_objc ())
    7826              :     {
    7827              :       /* Check if we are modifying an Objective-C property reference;
    7828              :          if so, we need to generate setter calls.  */
    7829            0 :       if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    7830            0 :         result = objc_maybe_build_modify_expr (lhs, TREE_OPERAND (newrhs, 0));
    7831              :       else
    7832            0 :         result = objc_maybe_build_modify_expr (lhs, newrhs);
    7833            0 :       if (result)
    7834            0 :         goto return_result;
    7835              : 
    7836              :       /* Else, do the check that we postponed for Objective-C.  */
    7837            0 :       if (!lvalue_or_else (location, lhs, lv_assign))
    7838            0 :         return error_mark_node;
    7839              :     }
    7840              : 
    7841              :   /* Give an error for storing in something that is 'const'.  */
    7842              : 
    7843      2905204 :   if (TYPE_READONLY (lhstype)
    7844      2905204 :       || (RECORD_OR_UNION_TYPE_P (lhstype)
    7845        25783 :           && C_TYPE_FIELDS_READONLY (lhstype)))
    7846              :     {
    7847           88 :       readonly_error (location, lhs, lv_assign);
    7848           88 :       return error_mark_node;
    7849              :     }
    7850      2905116 :   else if (TREE_READONLY (lhs))
    7851            1 :     readonly_warning (lhs, lv_assign);
    7852              : 
    7853              :   /* If storing into a structure or union member,
    7854              :      it has probably been given type `int'.
    7855              :      Compute the type that would go with
    7856              :      the actual amount of storage the member occupies.  */
    7857              : 
    7858      2905116 :   if (TREE_CODE (lhs) == COMPONENT_REF
    7859       249648 :       && (TREE_CODE (lhstype) == INTEGER_TYPE
    7860       249648 :           || TREE_CODE (lhstype) == BOOLEAN_TYPE
    7861       110012 :           || SCALAR_FLOAT_TYPE_P (lhstype)
    7862        86618 :           || TREE_CODE (lhstype) == ENUMERAL_TYPE))
    7863       170026 :     lhstype = TREE_TYPE (get_unwidened (lhs, 0));
    7864              : 
    7865              :   /* If storing in a field that is in actuality a short or narrower than one,
    7866              :      we must store in the field in its actual type.  */
    7867              : 
    7868      2905116 :   if (lhstype != TREE_TYPE (lhs))
    7869              :     {
    7870            0 :       lhs = copy_node (lhs);
    7871            0 :       TREE_TYPE (lhs) = lhstype;
    7872              :     }
    7873              : 
    7874              :   /* Issue -Wc++-compat warnings about an assignment to an enum type
    7875              :      when LHS does not have its original type.  This happens for,
    7876              :      e.g., an enum bitfield in a struct.  */
    7877      2905116 :   if (warn_cxx_compat
    7878         3196 :       && lhs_origtype != NULL_TREE
    7879         3196 :       && lhs_origtype != lhstype
    7880            7 :       && TREE_CODE (lhs_origtype) == ENUMERAL_TYPE)
    7881              :     {
    7882            4 :       tree checktype = (rhs_origtype != NULL_TREE
    7883            4 :                         ? rhs_origtype
    7884            0 :                         : TREE_TYPE (rhs));
    7885            4 :       if (checktype != error_mark_node
    7886            4 :           && (TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (lhs_origtype)
    7887            2 :               || (is_atomic_op && modifycode != NOP_EXPR)))
    7888            2 :         warning_at (location, OPT_Wc___compat,
    7889              :                     "enum conversion in assignment is invalid in C++");
    7890              :     }
    7891              : 
    7892              :   /* Remove qualifiers.  */
    7893      2905116 :   lhstype = c_build_qualified_type (lhstype, TYPE_UNQUALIFIED);
    7894      2905116 :   olhstype = c_build_qualified_type (olhstype, TYPE_UNQUALIFIED);
    7895              : 
    7896              :   /* Convert new value to destination type.  Fold it first, then
    7897              :      restore any excess precision information, for the sake of
    7898              :      conversion warnings.  */
    7899              : 
    7900      2905116 :   if (!(is_atomic_op && modifycode != NOP_EXPR))
    7901              :     {
    7902      2889631 :       tree rhs_semantic_type = NULL_TREE;
    7903      2889631 :       if (!c_in_omp_for)
    7904              :         {
    7905      2873310 :           if (TREE_CODE (newrhs) == EXCESS_PRECISION_EXPR)
    7906              :             {
    7907         5077 :               rhs_semantic_type = TREE_TYPE (newrhs);
    7908         5077 :               newrhs = TREE_OPERAND (newrhs, 0);
    7909              :             }
    7910      2873310 :           npc = null_pointer_constant_p (newrhs);
    7911      2873310 :           newrhs = c_fully_fold (newrhs, false, NULL);
    7912      2873310 :           if (rhs_semantic_type)
    7913         5077 :             newrhs = build1 (EXCESS_PRECISION_EXPR, rhs_semantic_type, newrhs);
    7914              :         }
    7915              :       else
    7916        16321 :         npc = null_pointer_constant_p (newrhs);
    7917      2889631 :       newrhs = convert_for_assignment (location, rhs_loc, lhstype, newrhs,
    7918              :                                        rhs_origtype, ic_assign, npc,
    7919              :                                        NULL_TREE, NULL_TREE, 0);
    7920      2889631 :       if (TREE_CODE (newrhs) == ERROR_MARK)
    7921          127 :         return error_mark_node;
    7922              :     }
    7923              : 
    7924              :   /* Emit ObjC write barrier, if necessary.  */
    7925      2904989 :   if (c_dialect_objc () && flag_objc_gc)
    7926              :     {
    7927            0 :       result = objc_generate_write_barrier (lhs, modifycode, newrhs);
    7928            0 :       if (result)
    7929              :         {
    7930            0 :           protected_set_expr_location (result, location);
    7931            0 :           goto return_result;
    7932              :         }
    7933              :     }
    7934              : 
    7935              :   /* Scan operands.  */
    7936              : 
    7937      2904989 :   if (is_atomic_op)
    7938        25964 :     result = build_atomic_assign (location, lhs, modifycode, newrhs, false);
    7939              :   else
    7940              :     {
    7941      2879025 :       result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);
    7942      2879025 :       TREE_SIDE_EFFECTS (result) = 1;
    7943      2879025 :       protected_set_expr_location (result, location);
    7944              :     }
    7945              : 
    7946              :   /* If we got the LHS in a different type for storing in,
    7947              :      convert the result back to the nominal type of LHS
    7948              :      so that the value we return always has the same type
    7949              :      as the LHS argument.  */
    7950              : 
    7951      2904989 :   if (olhstype == TREE_TYPE (result))
    7952      2904989 :     goto return_result;
    7953              : 
    7954            0 :   result = convert_for_assignment (location, rhs_loc, olhstype, result,
    7955              :                                    rhs_origtype, ic_assign, false, NULL_TREE,
    7956              :                                    NULL_TREE, 0);
    7957            0 :   protected_set_expr_location (result, location);
    7958              : 
    7959      2904989 : return_result:
    7960      2904989 :   if (rhseval)
    7961         8816 :     result = build2 (COMPOUND_EXPR, TREE_TYPE (result), rhseval, result);
    7962              :   return result;
    7963              : }
    7964              : 
    7965              : /* Return whether STRUCT_TYPE has an anonymous field with type TYPE.
    7966              :    This is used to implement -fplan9-extensions.  */
    7967              : 
    7968              : static bool
    7969           26 : find_anonymous_field_with_type (tree struct_type, tree type)
    7970              : {
    7971           26 :   tree field;
    7972           26 :   bool found;
    7973              : 
    7974           26 :   gcc_assert (RECORD_OR_UNION_TYPE_P (struct_type));
    7975           26 :   found = false;
    7976           26 :   for (field = TYPE_FIELDS (struct_type);
    7977           68 :        field != NULL_TREE;
    7978           42 :        field = TREE_CHAIN (field))
    7979              :     {
    7980           42 :       tree fieldtype = remove_qualifiers (TREE_TYPE (field));
    7981           42 :       if (DECL_NAME (field) == NULL
    7982           42 :           && comptypes (type, fieldtype))
    7983              :         {
    7984            4 :           if (found)
    7985              :             return false;
    7986              :           found = true;
    7987              :         }
    7988           38 :       else if (DECL_NAME (field) == NULL
    7989            2 :                && RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
    7990           40 :                && find_anonymous_field_with_type (TREE_TYPE (field), type))
    7991              :         {
    7992            0 :           if (found)
    7993              :             return false;
    7994              :           found = true;
    7995              :         }
    7996              :     }
    7997              :   return found;
    7998              : }
    7999              : 
    8000              : /* RHS is an expression whose type is pointer to struct.  If there is
    8001              :    an anonymous field in RHS with type TYPE, then return a pointer to
    8002              :    that field in RHS.  This is used with -fplan9-extensions.  This
    8003              :    returns NULL if no conversion could be found.  */
    8004              : 
    8005              : static tree
    8006           28 : convert_to_anonymous_field (location_t location, tree type, tree rhs)
    8007              : {
    8008           28 :   tree rhs_struct_type, lhs_main_type;
    8009           28 :   tree field, found_field;
    8010           28 :   bool found_sub_field;
    8011           28 :   tree ret;
    8012              : 
    8013           28 :   gcc_assert (POINTER_TYPE_P (TREE_TYPE (rhs)));
    8014           28 :   rhs_struct_type = TREE_TYPE (TREE_TYPE (rhs));
    8015           28 :   gcc_assert (RECORD_OR_UNION_TYPE_P (rhs_struct_type));
    8016              : 
    8017           28 :   gcc_assert (POINTER_TYPE_P (type));
    8018           28 :   lhs_main_type = remove_qualifiers (TREE_TYPE (type));
    8019              : 
    8020           28 :   found_field = NULL_TREE;
    8021           28 :   found_sub_field = false;
    8022           28 :   for (field = TYPE_FIELDS (rhs_struct_type);
    8023          172 :        field != NULL_TREE;
    8024          144 :        field = TREE_CHAIN (field))
    8025              :     {
    8026          148 :       if (DECL_NAME (field) != NULL_TREE
    8027          148 :           || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (field)))
    8028           96 :         continue;
    8029           52 :       tree fieldtype = remove_qualifiers (TREE_TYPE (field));
    8030           52 :       if (comptypes (lhs_main_type, fieldtype))
    8031              :         {
    8032           28 :           if (found_field != NULL_TREE)
    8033              :             return NULL_TREE;
    8034              :           found_field = field;
    8035              :         }
    8036           24 :       else if (find_anonymous_field_with_type (TREE_TYPE (field),
    8037              :                                                lhs_main_type))
    8038              :         {
    8039            4 :           if (found_field != NULL_TREE)
    8040              :             return NULL_TREE;
    8041              :           found_field = field;
    8042              :           found_sub_field = true;
    8043              :         }
    8044              :     }
    8045              : 
    8046           24 :   if (found_field == NULL_TREE)
    8047              :     return NULL_TREE;
    8048              : 
    8049           24 :   ret = fold_build3_loc (location, COMPONENT_REF, TREE_TYPE (found_field),
    8050              :                          build_fold_indirect_ref (rhs), found_field,
    8051              :                          NULL_TREE);
    8052           24 :   ret = build_fold_addr_expr_loc (location, ret);
    8053              : 
    8054           24 :   if (found_sub_field)
    8055              :     {
    8056            2 :       ret = convert_to_anonymous_field (location, type, ret);
    8057            2 :       gcc_assert (ret != NULL_TREE);
    8058              :     }
    8059              : 
    8060              :   return ret;
    8061              : }
    8062              : 
    8063              : /* Issue an error message for a bad initializer component.
    8064              :    GMSGID identifies the message.
    8065              :    The component name is taken from the spelling stack.  */
    8066              : 
    8067              : static void ATTRIBUTE_GCC_DIAG (2,0)
    8068          944 : error_init (location_t loc, const char *gmsgid, ...)
    8069              : {
    8070          944 :   char *ofwhat;
    8071              : 
    8072          944 :   auto_diagnostic_group d;
    8073              : 
    8074              :   /* The gmsgid may be a format string with %< and %>. */
    8075          944 :   va_list ap;
    8076          944 :   va_start (ap, gmsgid);
    8077          944 :   bool warned = emit_diagnostic_valist (diagnostics::kind::error,
    8078          944 :                                         loc, -1, gmsgid, &ap);
    8079          944 :   va_end (ap);
    8080              : 
    8081          944 :   ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    8082          944 :   if (*ofwhat && warned)
    8083          220 :     inform (loc, "(near initialization for %qs)", ofwhat);
    8084          944 : }
    8085              : 
    8086              : /* Used to implement pedwarn_init and permerror_init.  */
    8087              : 
    8088              : static bool ATTRIBUTE_GCC_DIAG (3,0)
    8089         2538 : pedwarn_permerror_init (location_t loc, int opt, const char *gmsgid,
    8090              :                         va_list *ap, enum diagnostics::kind kind)
    8091              : {
    8092              :   /* Use the location where a macro was expanded rather than where
    8093              :      it was defined to make sure macros defined in system headers
    8094              :      but used incorrectly elsewhere are diagnosed.  */
    8095         2538 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    8096         2538 :   auto_diagnostic_group d;
    8097         2538 :   bool warned = emit_diagnostic_valist (kind, exploc, opt, gmsgid, ap);
    8098         2538 :   if (warned)
    8099              :     {
    8100         1815 :       char *ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    8101         1815 :       if (*ofwhat)
    8102         1494 :         inform (exploc, "(near initialization for %qs)", ofwhat);
    8103              :     }
    8104         5076 :   return warned;
    8105         2538 : }
    8106              : 
    8107              : /* Issue a pedantic warning for a bad initializer component.  OPT is
    8108              :    the option OPT_* (from options.h) controlling this warning or 0 if
    8109              :    it is unconditionally given.  GMSGID identifies the message.  The
    8110              :    component name is taken from the spelling stack.  */
    8111              : 
    8112              : static bool ATTRIBUTE_GCC_DIAG (3,0)
    8113         2187 : pedwarn_init (location_t loc, int opt, const char *gmsgid, ...)
    8114              : {
    8115         2187 :   va_list ap;
    8116         2187 :   va_start (ap, gmsgid);
    8117         2187 :   bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap,
    8118              :                                         diagnostics::kind::pedwarn);
    8119         2187 :   va_end (ap);
    8120         2187 :   return warned;
    8121              : }
    8122              : 
    8123              : /* Like pedwarn_init, but issue a permerror.  */
    8124              : 
    8125              : static bool ATTRIBUTE_GCC_DIAG (3,0)
    8126          351 : permerror_init (location_t loc, int opt, const char *gmsgid, ...)
    8127              : {
    8128          351 :   va_list ap;
    8129          351 :   va_start (ap, gmsgid);
    8130          351 :   bool warned = pedwarn_permerror_init (loc, opt, gmsgid, &ap,
    8131              :                                         diagnostics::kind::permerror);
    8132          351 :   va_end (ap);
    8133          351 :   return warned;
    8134              : }
    8135              : 
    8136              : /* Issue a warning for a bad initializer component.
    8137              : 
    8138              :    OPT is the OPT_W* value corresponding to the warning option that
    8139              :    controls this warning.  GMSGID identifies the message.  The
    8140              :    component name is taken from the spelling stack.  */
    8141              : 
    8142              : static void
    8143          146 : warning_init (location_t loc, int opt, const char *gmsgid)
    8144              : {
    8145          146 :   char *ofwhat;
    8146          146 :   bool warned;
    8147              : 
    8148          146 :   auto_diagnostic_group d;
    8149              : 
    8150              :   /* Use the location where a macro was expanded rather than where
    8151              :      it was defined to make sure macros defined in system headers
    8152              :      but used incorrectly elsewhere are diagnosed.  */
    8153          146 :   location_t exploc = expansion_point_location_if_in_system_header (loc);
    8154              : 
    8155              :   /* The gmsgid may be a format string with %< and %>. */
    8156          146 :   warned = warning_at (exploc, opt, gmsgid);
    8157          146 :   if (warned)
    8158              :     {
    8159          133 :       ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
    8160          133 :       if (*ofwhat)
    8161          133 :         inform (exploc, "(near initialization for %qs)", ofwhat);
    8162              :     }
    8163          146 : }
    8164              : 
    8165              : /* If TYPE is an array type and EXPR is a parenthesized string
    8166              :    constant, warn if pedantic that EXPR is being used to initialize an
    8167              :    object of type TYPE.  */
    8168              : 
    8169              : void
    8170      7284565 : maybe_warn_string_init (location_t loc, tree type, struct c_expr expr)
    8171              : {
    8172      7284565 :   if (pedantic
    8173        80536 :       && TREE_CODE (type) == ARRAY_TYPE
    8174         1193 :       && TREE_CODE (expr.value) == STRING_CST
    8175          472 :       && expr.original_code != STRING_CST)
    8176           13 :     pedwarn_init (loc, OPT_Wpedantic,
    8177              :                   "array initialized from parenthesized string constant");
    8178      7284565 : }
    8179              : 
    8180              : /* Attempt to locate the parameter with the given index within FNDECL,
    8181              :    returning DECL_SOURCE_LOCATION (FNDECL) if it can't be found.  */
    8182              : 
    8183              : static location_t
    8184          937 : get_fndecl_argument_location (tree fndecl, int argnum)
    8185              : {
    8186          937 :   int i;
    8187          937 :   tree param;
    8188              : 
    8189              :   /* Locate param by index within DECL_ARGUMENTS (fndecl).  */
    8190          937 :   for (i = 0, param = DECL_ARGUMENTS (fndecl);
    8191         1016 :        i < argnum && param;
    8192           79 :        i++, param = TREE_CHAIN (param))
    8193              :     ;
    8194              : 
    8195              :   /* If something went wrong (e.g. if we have a builtin and thus no arguments),
    8196              :      return DECL_SOURCE_LOCATION (FNDECL).  */
    8197          937 :   if (param == NULL)
    8198          653 :     return DECL_SOURCE_LOCATION (fndecl);
    8199              : 
    8200          284 :   return DECL_SOURCE_LOCATION (param);
    8201              : }
    8202              : 
    8203              : /* Issue a note about a mismatching argument for parameter PARMNUM
    8204              :    to FUNDECL, for types EXPECTED_TYPE and ACTUAL_TYPE.
    8205              :    Attempt to issue the note at the pertinent parameter of the decl;
    8206              :    failing that issue it at the location of FUNDECL; failing that
    8207              :    issue it at PLOC.
    8208              :    Use highlight_colors::actual for the ACTUAL_TYPE
    8209              :    and highlight_colors::expected for EXPECTED_TYPE and the
    8210              :    parameter of FUNDECL*/
    8211              : 
    8212              : static void
    8213         1061 : inform_for_arg (tree fundecl, location_t ploc, int parmnum,
    8214              :                 tree expected_type, tree actual_type)
    8215              : {
    8216         1061 :   location_t loc;
    8217         1061 :   if (fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    8218          937 :     loc = get_fndecl_argument_location (fundecl, parmnum - 1);
    8219              :   else
    8220              :     loc = ploc;
    8221              : 
    8222         1061 :   gcc_rich_location richloc (loc, nullptr, highlight_colors::expected);
    8223              : 
    8224         1061 :   pp_markup::element_expected_type elem_expected_type (expected_type);
    8225         1061 :   pp_markup::element_actual_type elem_actual_type (actual_type);
    8226         1061 :   inform (&richloc,
    8227              :           "expected %e but argument is of type %e",
    8228              :           &elem_expected_type, &elem_actual_type);
    8229         1061 : }
    8230              : 
    8231              : /* Issue a warning when an argument of ARGTYPE is passed to a built-in
    8232              :    function FUNDECL declared without prototype to parameter PARMNUM of
    8233              :    PARMTYPE when ARGTYPE does not promote to PARMTYPE.  */
    8234              : 
    8235              : static void
    8236          418 : maybe_warn_builtin_no_proto_arg (location_t loc, tree fundecl, int parmnum,
    8237              :                                  tree parmtype, tree argtype)
    8238              : {
    8239          418 :   tree_code parmcode = TREE_CODE (parmtype);
    8240          418 :   tree_code argcode = TREE_CODE (argtype);
    8241          418 :   tree promoted = c_type_promotes_to (argtype);
    8242              : 
    8243              :   /* Avoid warning for enum arguments that promote to an integer type
    8244              :      of the same size/mode.  */
    8245          418 :   if (parmcode == INTEGER_TYPE
    8246          418 :       && argcode == ENUMERAL_TYPE
    8247          418 :       && TYPE_MODE (parmtype) == TYPE_MODE (argtype))
    8248              :     return;
    8249              : 
    8250          417 :   if ((parmcode == argcode
    8251          222 :        || (parmcode == INTEGER_TYPE
    8252              :            && argcode == ENUMERAL_TYPE))
    8253          418 :       && TYPE_MAIN_VARIANT (parmtype) == TYPE_MAIN_VARIANT (promoted))
    8254              :     return;
    8255              : 
    8256              :   /* This diagnoses even signed/unsigned mismatches.  Those might be
    8257              :      safe in many cases but GCC may emit suboptimal code for them so
    8258              :      warning on those cases drives efficiency improvements.  */
    8259          398 :   if (warning_at (loc, OPT_Wbuiltin_declaration_mismatch,
    8260          398 :                   TYPE_MAIN_VARIANT (promoted) == argtype
    8261              :                   ? G_("%qD argument %d type is %qT where %qT is expected "
    8262              :                        "in a call to built-in function declared without "
    8263              :                        "prototype")
    8264              :                   : G_("%qD argument %d promotes to %qT where %qT is expected "
    8265              :                        "in a call to built-in function declared without "
    8266              :                        "prototype"),
    8267              :                   fundecl, parmnum, promoted, parmtype))
    8268          150 :     inform (DECL_SOURCE_LOCATION (fundecl),
    8269              :             "built-in %qD declared here",
    8270              :             fundecl);
    8271              : }
    8272              : 
    8273              : /* Print a declaration in quotes, with the given highlight_color.
    8274              :    Analogous to handler for %qD, but with a specific highlight color.  */
    8275              : 
    8276          199 : class pp_element_quoted_decl : public pp_element
    8277              : {
    8278              : public:
    8279          199 :   pp_element_quoted_decl (tree decl, const char *highlight_color)
    8280          199 :   : m_decl (decl),
    8281          199 :     m_highlight_color (highlight_color)
    8282              :   {
    8283              :   }
    8284              : 
    8285          199 :   void add_to_phase_2 (pp_markup::context &ctxt) override
    8286              :   {
    8287          199 :     ctxt.begin_quote ();
    8288          199 :     ctxt.begin_highlight_color (m_highlight_color);
    8289              : 
    8290          199 :     print_decl (ctxt);
    8291              : 
    8292          199 :     ctxt.end_highlight_color ();
    8293          199 :     ctxt.end_quote ();
    8294          199 :   }
    8295              : 
    8296          199 :   void print_decl (pp_markup::context &ctxt)
    8297              :   {
    8298          199 :     pretty_printer *const pp = &ctxt.m_pp;
    8299          199 :     pp->set_padding (pp_none);
    8300          199 :     if (DECL_NAME (m_decl))
    8301          199 :       pp_identifier (pp, lang_hooks.decl_printable_name (m_decl, 2));
    8302              :     else
    8303            0 :       pp_string (pp, _("({anonymous})"));
    8304          199 :   }
    8305              : 
    8306              : private:
    8307              :   tree m_decl;
    8308              :   const char *m_highlight_color;
    8309              : };
    8310              : 
    8311              : /* If TYPE is from a typedef, issue a note showing the location
    8312              :    to the user.
    8313              :    Use HIGHLIGHT_COLOR as the highlight color.  */
    8314              : 
    8315              : static void
    8316         1178 : maybe_inform_typedef_location (tree type, const char *highlight_color)
    8317              : {
    8318         1178 :   if (!typedef_variant_p (type))
    8319         1144 :     return;
    8320              : 
    8321           34 :   tree typedef_decl = TYPE_NAME (type);
    8322           34 :   gcc_assert (TREE_CODE (typedef_decl) == TYPE_DECL);
    8323           34 :   gcc_rich_location richloc (DECL_SOURCE_LOCATION (typedef_decl),
    8324           34 :                              nullptr, highlight_color);
    8325           34 :   pp_element_quoted_decl e_typedef_decl (typedef_decl, highlight_color);
    8326           34 :   inform (&richloc, "%e declared here", &e_typedef_decl);
    8327           34 : }
    8328              : 
    8329              : /* Convert value RHS to type TYPE as preparation for an assignment to
    8330              :    an lvalue of type TYPE.  If ORIGTYPE is not NULL_TREE, it is the
    8331              :    original type of RHS; this differs from TREE_TYPE (RHS) for enum
    8332              :    types.  NULL_POINTER_CONSTANT says whether RHS was a null pointer
    8333              :    constant before any folding.
    8334              :    The real work of conversion is done by `convert'.
    8335              :    The purpose of this function is to generate error messages
    8336              :    for assignments that are not allowed in C.
    8337              :    ERRTYPE says whether it is argument passing, assignment,
    8338              :    initialization or return.
    8339              : 
    8340              :    In the following example, '~' denotes where EXPR_LOC and '^' where
    8341              :    LOCATION point to:
    8342              : 
    8343              :      f (var);      [ic_argpass]
    8344              :      ^  ~~~
    8345              :      x = var;      [ic_assign]
    8346              :        ^ ~~~;
    8347              :      int x = var;  [ic_init]
    8348              :              ^^^
    8349              :      return x;     [ic_return]
    8350              :             ^
    8351              : 
    8352              :    FUNCTION is a tree for the function being called.
    8353              :    PARMNUM is the number of the argument, for printing in error messages.
    8354              :    WARNOPT may be set to a warning option to issue the corresponding warning
    8355              :    rather than an error for invalid conversions.  Used for calls to built-in
    8356              :    functions declared without a prototype.  */
    8357              : 
    8358              : static tree
    8359    167106694 : convert_for_assignment (location_t location, location_t expr_loc, tree type,
    8360              :                         tree rhs, tree origtype, enum impl_conv errtype,
    8361              :                         bool null_pointer_constant, tree fundecl,
    8362              :                         tree function, int parmnum, int warnopt /* = 0 */)
    8363              : {
    8364    167106694 :   enum tree_code codel = TREE_CODE (type);
    8365    167106694 :   tree orig_rhs = rhs;
    8366    167106694 :   tree rhstype;
    8367    167106694 :   enum tree_code coder;
    8368    167106694 :   tree rname = NULL_TREE;
    8369    167106694 :   bool objc_ok = false;
    8370              : 
    8371              :   /* Use the expansion point location to handle cases such as user's
    8372              :      function returning a wrong-type macro defined in a system header.  */
    8373    167106694 :   location = expansion_point_location_if_in_system_header (location);
    8374              : 
    8375    167106694 :   if (errtype == ic_argpass)
    8376              :     {
    8377    125647888 :       tree selector;
    8378              :       /* Change pointer to function to the function itself for
    8379              :          diagnostics.  */
    8380    125647888 :       if (TREE_CODE (function) == ADDR_EXPR
    8381    125647888 :           && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    8382            0 :         function = TREE_OPERAND (function, 0);
    8383              : 
    8384              :       /* Handle an ObjC selector specially for diagnostics.  */
    8385    125647888 :       selector = objc_message_selector ();
    8386    125647888 :       rname = function;
    8387    125647888 :       if (selector && parmnum > 2)
    8388              :         {
    8389            0 :           rname = selector;
    8390            0 :           parmnum -= 2;
    8391              :         }
    8392              :     }
    8393              : 
    8394              :   /* This macro is used to emit diagnostics to ensure that all format
    8395              :      strings are complete sentences, visible to gettext and checked at
    8396              :      compile time.  */
    8397              : #define PEDWARN_FOR_ASSIGNMENT(LOCATION, PLOC, OPT, AR, AS, IN, RE)      \
    8398              :   do {                                                                   \
    8399              :     switch (errtype)                                                     \
    8400              :       {                                                                  \
    8401              :       case ic_argpass:                                                   \
    8402              :         {                                                               \
    8403              :           auto_diagnostic_group d;                                              \
    8404              :           if (pedwarn (PLOC, OPT, AR, parmnum, rname))          \
    8405              :             inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype); \
    8406              :         }                                                               \
    8407              :         break;                                                           \
    8408              :       case ic_assign:                                                    \
    8409              :         pedwarn (LOCATION, OPT, AS);                                     \
    8410              :         break;                                                           \
    8411              :       case ic_init:                                                      \
    8412              :       case ic_init_const:                                                \
    8413              :         pedwarn_init (LOCATION, OPT, IN);                                \
    8414              :         break;                                                           \
    8415              :       case ic_return:                                                    \
    8416              :         pedwarn (LOCATION, OPT, RE);                                     \
    8417              :         break;                                                           \
    8418              :       default:                                                           \
    8419              :         gcc_unreachable ();                                              \
    8420              :       }                                                                  \
    8421              :   } while (0)
    8422              : 
    8423              :   /* This macro is used to emit diagnostics to ensure that all format
    8424              :      strings are complete sentences, visible to gettext and checked at
    8425              :      compile time.  It can be called with 'pedwarn' or 'warning_at'.  */
    8426              : #define WARNING_FOR_QUALIFIERS(PEDWARN, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    8427              :   do {                                                                   \
    8428              :     switch (errtype)                                                     \
    8429              :       {                                                                  \
    8430              :       case ic_argpass:                                                   \
    8431              :         {                                                                \
    8432              :           auto_diagnostic_group d;                                       \
    8433              :           if (PEDWARN) {                                                 \
    8434              :             if (pedwarn (PLOC, OPT, AR, parmnum, rname, QUALS))          \
    8435              :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    8436              :           } else {                                                       \
    8437              :             if (warning_at (PLOC, OPT, AR, parmnum, rname, QUALS))       \
    8438              :               inform_for_arg (fundecl, (PLOC), parmnum, type, rhstype);  \
    8439              :           }                                                              \
    8440              :         }                                                                \
    8441              :         break;                                                           \
    8442              :       case ic_assign:                                                    \
    8443              :         if (PEDWARN)                                                     \
    8444              :           pedwarn (LOCATION, OPT, AS, QUALS);                            \
    8445              :         else                                                             \
    8446              :           warning_at (LOCATION, OPT, AS, QUALS);                         \
    8447              :         break;                                                           \
    8448              :       case ic_init:                                                      \
    8449              :       case ic_init_const:                                                \
    8450              :         if (PEDWARN)                                                     \
    8451              :           pedwarn (LOCATION, OPT, IN, QUALS);                            \
    8452              :         else                                                             \
    8453              :           warning_at (LOCATION, OPT, IN, QUALS);                         \
    8454              :         break;                                                           \
    8455              :       case ic_return:                                                    \
    8456              :         if (PEDWARN)                                                     \
    8457              :           pedwarn (LOCATION, OPT, RE, QUALS);                            \
    8458              :         else                                                             \
    8459              :           warning_at (LOCATION, OPT, RE, QUALS);                         \
    8460              :         break;                                                           \
    8461              :       default:                                                           \
    8462              :         gcc_unreachable ();                                              \
    8463              :       }                                                                  \
    8464              :   } while (0)
    8465              : 
    8466              :   /* This macro is used to emit diagnostics to ensure that all format
    8467              :      strings are complete sentences, visible to gettext and checked at
    8468              :      compile time.  It is the same as PEDWARN_FOR_ASSIGNMENT but with an
    8469              :      extra parameter to enumerate qualifiers.  */
    8470              : #define PEDWARN_FOR_QUALIFIERS(LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS) \
    8471              :    WARNING_FOR_QUALIFIERS (true, LOCATION, PLOC, OPT, AR, AS, IN, RE, QUALS)
    8472              : 
    8473              : 
    8474    167106694 :   if (TREE_CODE (rhs) == EXCESS_PRECISION_EXPR)
    8475         5985 :     rhs = TREE_OPERAND (rhs, 0);
    8476              : 
    8477    167106694 :   rhstype = TREE_TYPE (rhs);
    8478    167106694 :   coder = TREE_CODE (rhstype);
    8479              : 
    8480    167106694 :   if (coder == ERROR_MARK)
    8481          347 :     return error_mark_node;
    8482              : 
    8483    167106347 :   if (c_dialect_objc ())
    8484              :     {
    8485            0 :       int parmno;
    8486              : 
    8487            0 :       switch (errtype)
    8488              :         {
    8489              :         case ic_return:
    8490              :           parmno = 0;
    8491              :           break;
    8492              : 
    8493              :         case ic_assign:
    8494              :           parmno = -1;
    8495              :           break;
    8496              : 
    8497              :         case ic_init:
    8498              :         case ic_init_const:
    8499              :           parmno = -2;
    8500              :           break;
    8501              : 
    8502              :         default:
    8503            0 :           parmno = parmnum;
    8504              :           break;
    8505              :         }
    8506              : 
    8507            0 :       objc_ok = objc_compare_types (type, rhstype, parmno, rname);
    8508              :     }
    8509              : 
    8510    167106347 :   if (warn_cxx_compat)
    8511              :     {
    8512        29011 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    8513        29011 :       if (checktype != error_mark_node
    8514        29011 :           && TREE_CODE (type) == ENUMERAL_TYPE
    8515        29117 :           && TYPE_MAIN_VARIANT (checktype) != TYPE_MAIN_VARIANT (type))
    8516           45 :         switch (errtype)
    8517              :           {
    8518            8 :           case ic_argpass:
    8519            8 :             if (pedwarn (expr_loc, OPT_Wc___compat, "enum conversion when "
    8520              :                          "passing argument %d of %qE is invalid in C++",
    8521              :                          parmnum, rname))
    8522           16 :               inform ((fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl))
    8523            8 :                       ? DECL_SOURCE_LOCATION (fundecl) : expr_loc,
    8524              :                       "expected %qT but argument is of type %qT",
    8525              :                       type, rhstype);
    8526              :             break;
    8527           10 :           case ic_assign:
    8528           10 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    8529              :                      "%qT in assignment is invalid in C++", rhstype, type);
    8530           10 :             break;
    8531           18 :           case ic_init:
    8532           18 :           case ic_init_const:
    8533           18 :             pedwarn_init (location, OPT_Wc___compat, "enum conversion from "
    8534              :                           "%qT to %qT in initialization is invalid in C++",
    8535              :                           rhstype, type);
    8536           18 :             break;
    8537            9 :           case ic_return:
    8538            9 :             pedwarn (location, OPT_Wc___compat, "enum conversion from %qT to "
    8539              :                      "%qT in return is invalid in C++", rhstype, type);
    8540            9 :             break;
    8541            0 :           default:
    8542            0 :             gcc_unreachable ();
    8543              :           }
    8544              :     }
    8545              : 
    8546    167106347 :   if (warn_enum_conversion)
    8547              :     {
    8548     14600677 :       tree checktype = origtype != NULL_TREE ? origtype : rhstype;
    8549     14600677 :       if (checktype != error_mark_node
    8550     14600677 :           && TREE_CODE (checktype) == ENUMERAL_TYPE
    8551        12835 :           && TREE_CODE (type) == ENUMERAL_TYPE
    8552     14608973 :           && !comptypes (TYPE_MAIN_VARIANT (checktype), TYPE_MAIN_VARIANT (type)))
    8553              :        {
    8554            7 :           gcc_rich_location loc (location);
    8555            7 :           warning_at (&loc, OPT_Wenum_conversion,
    8556              :                       "implicit conversion from %qT to %qT",
    8557              :                       checktype, type);
    8558            7 :        }
    8559              :     }
    8560              : 
    8561    167106347 :   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
    8562              :     {
    8563    147990234 :       warn_for_address_of_packed_member (type, orig_rhs);
    8564    147990234 :       if (type != rhstype)
    8565              :         /* Convert RHS to TYPE in order to not lose TYPE in diagnostics.  */
    8566     36871290 :         rhs = convert (type, rhs);
    8567    147990234 :       return rhs;
    8568              :     }
    8569              : 
    8570     19116113 :   if (coder == VOID_TYPE)
    8571              :     {
    8572              :       /* Except for passing an argument to an unprototyped function,
    8573              :          this is a constraint violation.  When passing an argument to
    8574              :          an unprototyped function, it is compile-time undefined;
    8575              :          making it a constraint in that case was rejected in
    8576              :          DR#252.  */
    8577            8 :       const char msg[] = "void value not ignored as it ought to be";
    8578            8 :       if (warnopt)
    8579            0 :         warning_at (location, warnopt, msg);
    8580              :       else
    8581            8 :         error_at (location, msg);
    8582            8 :       return error_mark_node;
    8583              :     }
    8584     19116105 :   rhs = require_complete_type (location, rhs);
    8585     19116105 :   if (rhs == error_mark_node)
    8586              :     return error_mark_node;
    8587              : 
    8588     19116105 :   if (coder == POINTER_TYPE && reject_gcc_builtin (rhs))
    8589            6 :     return error_mark_node;
    8590              : 
    8591              :   /* A non-reference type can convert to a reference.  This handles
    8592              :      va_start, va_copy and possibly port built-ins.  */
    8593     19116099 :   if (codel == REFERENCE_TYPE && coder != REFERENCE_TYPE)
    8594              :     {
    8595          286 :       if (!lvalue_p (rhs))
    8596              :         {
    8597            0 :           const char msg[] = "cannot pass rvalue to reference parameter";
    8598            0 :           if (warnopt)
    8599            0 :             warning_at (location, warnopt, msg);
    8600              :           else
    8601            0 :             error_at (location, msg);
    8602            0 :           return error_mark_node;
    8603              :         }
    8604          286 :       if (!c_mark_addressable (rhs))
    8605            0 :         return error_mark_node;
    8606          286 :       rhs = build1 (ADDR_EXPR, c_build_pointer_type (TREE_TYPE (rhs)), rhs);
    8607          286 :       SET_EXPR_LOCATION (rhs, location);
    8608              : 
    8609          286 :       rhs = convert_for_assignment (location, expr_loc,
    8610          286 :                                     c_build_pointer_type (TREE_TYPE (type)),
    8611              :                                     rhs, origtype, errtype,
    8612              :                                     null_pointer_constant, fundecl, function,
    8613              :                                     parmnum, warnopt);
    8614          286 :       if (rhs == error_mark_node)
    8615              :         return error_mark_node;
    8616              : 
    8617          286 :       rhs = build1 (NOP_EXPR, type, rhs);
    8618          286 :       SET_EXPR_LOCATION (rhs, location);
    8619          286 :       return rhs;
    8620              :     }
    8621              :   /* Some types can interconvert without explicit casts.  */
    8622     19115813 :   else if (codel == VECTOR_TYPE && coder == VECTOR_TYPE
    8623     19115813 :            && vector_types_convertible_p (type, TREE_TYPE (rhs), true))
    8624      9288989 :     return convert (type, rhs);
    8625              :   /* Arithmetic types all interconvert, and enum is treated like int.  */
    8626      9826824 :   else if ((codel == INTEGER_TYPE || codel == REAL_TYPE
    8627      2287360 :             || codel == FIXED_POINT_TYPE
    8628      2287360 :             || codel == ENUMERAL_TYPE || codel == COMPLEX_TYPE
    8629      2200972 :             || codel == BOOLEAN_TYPE || codel == BITINT_TYPE)
    8630      7724915 :            && (coder == INTEGER_TYPE || coder == REAL_TYPE
    8631        83540 :                || coder == FIXED_POINT_TYPE
    8632        83540 :                || coder == ENUMERAL_TYPE || coder == COMPLEX_TYPE
    8633        40461 :                || coder == BOOLEAN_TYPE || coder == BITINT_TYPE))
    8634              :     {
    8635      7723548 :       if (warnopt && errtype == ic_argpass)
    8636          418 :         maybe_warn_builtin_no_proto_arg (expr_loc, fundecl, parmnum, type,
    8637              :                                          rhstype);
    8638              : 
    8639      7723548 :       bool save = in_late_binary_op;
    8640      7687604 :       if (C_BOOLEAN_TYPE_P (type) || codel == COMPLEX_TYPE
    8641     15354003 :           || (coder == REAL_TYPE
    8642       276192 :               && (codel == INTEGER_TYPE || codel == ENUMERAL_TYPE)
    8643        24196 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
    8644        99837 :         in_late_binary_op = true;
    8645     11104348 :       tree ret = convert_and_check (expr_loc != UNKNOWN_LOCATION
    8646              :                                     ? expr_loc : location, type, orig_rhs,
    8647              :                                     errtype == ic_init_const);
    8648      7723548 :       in_late_binary_op = save;
    8649      7723548 :       return ret;
    8650              :     }
    8651              : 
    8652              :   /* Aggregates in different TUs might need conversion.  */
    8653      2103276 :   if ((codel == RECORD_TYPE || codel == UNION_TYPE)
    8654          105 :       && codel == coder
    8655      2103298 :       && comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (rhstype)))
    8656            9 :     return convert_and_check (expr_loc != UNKNOWN_LOCATION
    8657            9 :                               ? expr_loc : location, type, rhs);
    8658              : 
    8659              :   /* Conversion to a transparent union or record from its member types.
    8660              :      This applies only to function arguments.  */
    8661      2103267 :   if (((codel == UNION_TYPE || codel == RECORD_TYPE)
    8662           96 :       && TYPE_TRANSPARENT_AGGR (type))
    8663      2103306 :       && errtype == ic_argpass)
    8664              :     {
    8665           39 :       tree memb, marginal_memb = NULL_TREE;
    8666              : 
    8667           50 :       for (memb = TYPE_FIELDS (type); memb ; memb = DECL_CHAIN (memb))
    8668              :         {
    8669           50 :           tree memb_type = TREE_TYPE (memb);
    8670              : 
    8671           50 :           if (comptypes (TYPE_MAIN_VARIANT (memb_type),
    8672           50 :                          TYPE_MAIN_VARIANT (rhstype)))
    8673              :             break;
    8674              : 
    8675           27 :           if (TREE_CODE (memb_type) != POINTER_TYPE)
    8676            1 :             continue;
    8677              : 
    8678           26 :           if (coder == POINTER_TYPE)
    8679              :             {
    8680           26 :               tree ttl = TREE_TYPE (memb_type);
    8681           26 :               tree ttr = TREE_TYPE (rhstype);
    8682              : 
    8683              :               /* Any non-function converts to a [const][volatile] void *
    8684              :                  and vice versa; otherwise, targets must be the same.
    8685              :                  Meanwhile, the lhs target must have all the qualifiers of
    8686              :                  the rhs.  */
    8687            0 :               if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    8688           26 :                   || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    8689           45 :                   || comp_target_types (location, memb_type, rhstype))
    8690              :                 {
    8691           16 :                   int lquals = TYPE_QUALS (ttl) & ~TYPE_QUAL_ATOMIC;
    8692           16 :                   int rquals = TYPE_QUALS (ttr) & ~TYPE_QUAL_ATOMIC;
    8693              :                   /* If this type won't generate any warnings, use it.  */
    8694           16 :                   if (lquals == rquals
    8695           16 :                       || ((TREE_CODE (ttr) == FUNCTION_TYPE
    8696            0 :                            && TREE_CODE (ttl) == FUNCTION_TYPE)
    8697            0 :                           ? ((lquals | rquals) == rquals)
    8698           16 :                           : ((lquals | rquals) == lquals)))
    8699              :                     break;
    8700              : 
    8701              :                   /* Keep looking for a better type, but remember this one.  */
    8702            0 :                   if (!marginal_memb)
    8703           10 :                     marginal_memb = memb;
    8704              :                 }
    8705              :             }
    8706              : 
    8707              :           /* Can convert integer zero to any pointer type.  */
    8708           10 :           if (null_pointer_constant)
    8709              :             {
    8710            0 :               rhs = null_pointer_node;
    8711            0 :               break;
    8712              :             }
    8713              :         }
    8714              : 
    8715           39 :       if (memb || marginal_memb)
    8716              :         {
    8717           39 :           if (!memb)
    8718              :             {
    8719              :               /* We have only a marginally acceptable member type;
    8720              :                  it needs a warning.  */
    8721            0 :               tree ttl = TREE_TYPE (TREE_TYPE (marginal_memb));
    8722            0 :               tree ttr = TREE_TYPE (rhstype);
    8723              : 
    8724              :               /* Const and volatile mean something different for function
    8725              :                  types, so the usual warnings are not appropriate.  */
    8726            0 :               if (TREE_CODE (ttr) == FUNCTION_TYPE
    8727            0 :                   && TREE_CODE (ttl) == FUNCTION_TYPE)
    8728              :                 {
    8729              :                   /* Because const and volatile on functions are
    8730              :                      restrictions that say the function will not do
    8731              :                      certain things, it is okay to use a const or volatile
    8732              :                      function where an ordinary one is wanted, but not
    8733              :                      vice-versa.  */
    8734            0 :                   if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    8735            0 :                       & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    8736            0 :                     PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8737              :                                             OPT_Wdiscarded_qualifiers,
    8738              :                                             G_("passing argument %d of %qE "
    8739              :                                                "makes %q#v qualified function "
    8740              :                                                "pointer from unqualified"),
    8741              :                                             G_("assignment makes %q#v qualified "
    8742              :                                                "function pointer from "
    8743              :                                                "unqualified"),
    8744              :                                             G_("initialization makes %q#v qualified "
    8745              :                                                "function pointer from "
    8746              :                                                "unqualified"),
    8747              :                                             G_("return makes %q#v qualified function "
    8748              :                                                "pointer from unqualified"),
    8749              :                                             TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    8750              :                 }
    8751            0 :               else if (TYPE_QUALS_NO_ADDR_SPACE (ttr)
    8752            0 :                        & ~TYPE_QUALS_NO_ADDR_SPACE (ttl))
    8753            0 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    8754              :                                         OPT_Wdiscarded_qualifiers,
    8755              :                                         G_("passing argument %d of %qE discards "
    8756              :                                            "%qv qualifier from pointer target type"),
    8757              :                                         G_("assignment discards %qv qualifier "
    8758              :                                            "from pointer target type"),
    8759              :                                         G_("initialization discards %qv qualifier "
    8760              :                                            "from pointer target type"),
    8761              :                                         G_("return discards %qv qualifier from "
    8762              :                                            "pointer target type"),
    8763              :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    8764              : 
    8765              :               memb = marginal_memb;
    8766              :             }
    8767              : 
    8768           39 :           if (!fundecl || !DECL_IN_SYSTEM_HEADER (fundecl))
    8769           31 :             pedwarn (location, OPT_Wpedantic,
    8770              :                      "ISO C prohibits argument conversion to union type");
    8771              : 
    8772           39 :           rhs = fold_convert_loc (location, TREE_TYPE (memb), rhs);
    8773           39 :           return build_constructor_single (type, memb, rhs);
    8774              :         }
    8775              :     }
    8776              : 
    8777              :   /* Conversions among pointers */
    8778      2103228 :   else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
    8779      2101705 :            && (coder == codel))
    8780              :     {
    8781              :       /* If RHS refers to a built-in declared without a prototype
    8782              :          BLTIN is the declaration of the built-in with a prototype
    8783              :          and RHSTYPE is set to the actual type of the built-in.  */
    8784      2023314 :       tree bltin;
    8785      2023314 :       rhstype = type_or_builtin_type (rhs, &bltin);
    8786              : 
    8787      2023314 :       tree ttl = TREE_TYPE (type);
    8788      2023314 :       tree ttr = TREE_TYPE (rhstype);
    8789      2023314 :       bool is_opaque_pointer;
    8790      2023314 :       bool target_cmp = false;   /* Cache comp_target_types () result.  */
    8791      2023314 :       addr_space_t asl;
    8792      2023314 :       addr_space_t asr;
    8793              : 
    8794      2023314 :       tree mvl = remove_qualifiers (ttl);
    8795      2023314 :       tree mvr = remove_qualifiers (ttr);
    8796              : 
    8797              :       /* Opaque pointers are treated like void pointers.  */
    8798      2023314 :       is_opaque_pointer = vector_targets_convertible_p (ttl, ttr);
    8799              : 
    8800              :       /* The Plan 9 compiler permits a pointer to a struct to be
    8801              :          automatically converted into a pointer to an anonymous field
    8802              :          within the struct.  */
    8803      2023314 :       if (flag_plan9_extensions
    8804           50 :           && RECORD_OR_UNION_TYPE_P (mvl)
    8805           26 :           && RECORD_OR_UNION_TYPE_P (mvr)
    8806           26 :           && mvl != mvr)
    8807              :         {
    8808           26 :           tree new_rhs = convert_to_anonymous_field (location, type, rhs);
    8809           26 :           if (new_rhs != NULL_TREE)
    8810              :             {
    8811           22 :               rhs = new_rhs;
    8812           22 :               rhstype = TREE_TYPE (rhs);
    8813           22 :               coder = TREE_CODE (rhstype);
    8814           22 :               ttr = TREE_TYPE (rhstype);
    8815           22 :               mvr = TYPE_MAIN_VARIANT (ttr);
    8816              :             }
    8817              :         }
    8818              : 
    8819              :       /* C++ does not allow the implicit conversion void* -> T*.  However,
    8820              :          for the purpose of reducing the number of false positives, we
    8821              :          tolerate the special case of
    8822              : 
    8823              :                 int *p = NULL;
    8824              : 
    8825              :          where NULL is typically defined in C to be '(void *) 0'.  */
    8826      2023314 :       if (VOID_TYPE_P (ttr) && rhs != null_pointer_node && !VOID_TYPE_P (ttl))
    8827        27006 :         warning_at (errtype == ic_argpass ? expr_loc : location,
    8828        14325 :                     OPT_Wc___compat,
    8829              :                     "request for implicit conversion "
    8830              :                     "from %qT to %qT not permitted in C++", rhstype, type);
    8831              : 
    8832              :       /* Warn of new allocations that are not big enough for the target
    8833              :          type.  */
    8834      2023314 :       if (warn_alloc_size && TREE_CODE (rhs) == CALL_EXPR)
    8835         5457 :         if (tree fndecl = get_callee_fndecl (rhs))
    8836         5457 :           if (DECL_IS_MALLOC (fndecl))
    8837              :             {
    8838         4609 :               tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
    8839         4609 :               tree alloc_size = lookup_attribute ("alloc_size", attrs);
    8840         4609 :               if (alloc_size)
    8841          451 :                 warn_for_alloc_size (location, ttl, rhs, alloc_size);
    8842              :             }
    8843              : 
    8844              :       /* See if the pointers point to incompatible address spaces.  */
    8845      2023314 :       asl = TYPE_ADDR_SPACE (ttl);
    8846      2023314 :       asr = TYPE_ADDR_SPACE (ttr);
    8847      2023314 :       if (!null_pointer_constant_p (rhs)
    8848      2023314 :           && asr != asl && !targetm.addr_space.subset_p (asr, asl))
    8849              :         {
    8850            3 :           auto_diagnostic_group d;
    8851            3 :           bool diagnosed = true;
    8852            3 :           switch (errtype)
    8853              :             {
    8854            1 :             case ic_argpass:
    8855            1 :               {
    8856            1 :                 const char msg[] = G_("passing argument %d of %qE from "
    8857              :                                       "pointer to non-enclosed address space");
    8858            1 :                 if (warnopt)
    8859            0 :                   diagnosed
    8860            0 :                     = warning_at (expr_loc, warnopt, msg, parmnum, rname);
    8861              :                 else
    8862            1 :                   error_at (expr_loc, msg, parmnum, rname);
    8863            0 :               break;
    8864              :               }
    8865            0 :             case ic_assign:
    8866            0 :               {
    8867            0 :                 const char msg[] = G_("assignment from pointer to "
    8868              :                                       "non-enclosed address space");
    8869            0 :                 if (warnopt)
    8870            0 :                   diagnosed = warning_at (location, warnopt, msg);
    8871              :                 else
    8872            0 :                   error_at (location, msg);
    8873            0 :                 break;
    8874              :               }
    8875            0 :             case ic_init:
    8876            0 :             case ic_init_const:
    8877            0 :               {
    8878            0 :                 const char msg[] = G_("initialization from pointer to "
    8879              :                                       "non-enclosed address space");
    8880            0 :                 if (warnopt)
    8881            0 :                   diagnosed = warning_at (location, warnopt, msg);
    8882              :                 else
    8883            0 :                   error_at (location, msg);
    8884            0 :                 break;
    8885              :               }
    8886            2 :             case ic_return:
    8887            2 :               {
    8888            2 :                 const char msg[] = G_("return from pointer to "
    8889              :                                       "non-enclosed address space");
    8890            2 :                 if (warnopt)
    8891            0 :                   diagnosed = warning_at (location, warnopt, msg);
    8892              :                 else
    8893            2 :                   error_at (location, msg);
    8894            0 :                 break;
    8895              :               }
    8896            0 :             default:
    8897            0 :               gcc_unreachable ();
    8898              :             }
    8899            3 :           if (diagnosed)
    8900              :             {
    8901            3 :               if (errtype == ic_argpass)
    8902            1 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    8903              :               else
    8904            2 :                 inform (location, "expected %qT but pointer is of type %qT",
    8905              :                         type, rhstype);
    8906              :             }
    8907            3 :           return error_mark_node;
    8908            3 :         }
    8909              : 
    8910              :       /* Check if the right-hand side has a format attribute but the
    8911              :          left-hand side doesn't.  */
    8912      2023311 :       if (warn_suggest_attribute_format
    8913      2023311 :           && check_missing_format_attribute (type, rhstype))
    8914              :         {
    8915           16 :           switch (errtype)
    8916              :           {
    8917            4 :           case ic_argpass:
    8918            4 :             warning_at (expr_loc, OPT_Wsuggest_attribute_format,
    8919              :                         "argument %d of %qE might be "
    8920              :                         "a candidate for a format attribute",
    8921              :                         parmnum, rname);
    8922            4 :             break;
    8923            4 :           case ic_assign:
    8924            4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8925              :                         "assignment left-hand side might be "
    8926              :                         "a candidate for a format attribute");
    8927            4 :             break;
    8928            4 :           case ic_init:
    8929            4 :           case ic_init_const:
    8930            4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8931              :                         "initialization left-hand side might be "
    8932              :                         "a candidate for a format attribute");
    8933            4 :             break;
    8934            4 :           case ic_return:
    8935            4 :             warning_at (location, OPT_Wsuggest_attribute_format,
    8936              :                         "return type might be "
    8937              :                         "a candidate for a format attribute");
    8938            4 :             break;
    8939            0 :           default:
    8940            0 :             gcc_unreachable ();
    8941              :           }
    8942              :         }
    8943              : 
    8944              :       /* See if the pointers point to incompatible scalar storage orders.  */
    8945      2023311 :       if (warn_scalar_storage_order
    8946      2020395 :           && !null_pointer_constant_p (rhs)
    8947      5995919 :           && (AGGREGATE_TYPE_P (ttl) && TYPE_REVERSE_STORAGE_ORDER (ttl))
    8948      1986304 :              != (AGGREGATE_TYPE_P (ttr) && TYPE_REVERSE_STORAGE_ORDER (ttr)))
    8949              :         {
    8950           18 :           tree t;
    8951              : 
    8952           18 :           switch (errtype)
    8953              :           {
    8954           11 :           case ic_argpass:
    8955              :             /* Do not warn for built-in functions, for example memcpy, since we
    8956              :                control how they behave and they can be useful in this area.  */
    8957           11 :             if (TREE_CODE (rname) != FUNCTION_DECL
    8958           11 :                 || !fndecl_built_in_p (rname))
    8959            1 :               warning_at (location, OPT_Wscalar_storage_order,
    8960              :                           "passing argument %d of %qE from incompatible "
    8961              :                           "scalar storage order", parmnum, rname);
    8962              :             break;
    8963            3 :           case ic_assign:
    8964              :             /* Do not warn if the RHS is a call to a function that returns a
    8965              :                pointer that is not an alias.  */
    8966            3 :             if (TREE_CODE (rhs) != CALL_EXPR
    8967            2 :                 || (t = get_callee_fndecl (rhs)) == NULL_TREE
    8968            5 :                 || !DECL_IS_MALLOC (t))
    8969            1 :               warning_at (location, OPT_Wscalar_storage_order,
    8970              :                           "assignment to %qT from pointer type %qT with "
    8971              :                           "incompatible scalar storage order", type, rhstype);
    8972              :             break;
    8973            3 :           case ic_init:
    8974            3 :           case ic_init_const:
    8975              :             /* Likewise.  */
    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              :                           "initialization of %qT from pointer type %qT with "
    8981              :                           "incompatible scalar storage order", type, rhstype);
    8982              :             break;
    8983            1 :           case ic_return:
    8984            1 :             warning_at (location, OPT_Wscalar_storage_order,
    8985              :                         "returning %qT from pointer type with incompatible "
    8986              :                         "scalar storage order %qT", rhstype, type);
    8987            1 :             break;
    8988            0 :           default:
    8989            0 :             gcc_unreachable ();
    8990              :           }
    8991              :         }
    8992              : 
    8993              :       /* Any non-function converts to a [const][volatile] void *
    8994              :          and vice versa; otherwise, targets must be the same.
    8995              :          Meanwhile, the lhs target must have all the qualifiers of the rhs.  */
    8996       424251 :       if ((VOID_TYPE_P (ttl) && !TYPE_ATOMIC (ttl))
    8997      1599061 :           || (VOID_TYPE_P (ttr) && !TYPE_ATOMIC (ttr))
    8998      1550784 :           || (target_cmp = comp_target_types (location, type, rhstype))
    8999         2448 :           || is_opaque_pointer
    9000      2028207 :           || ((c_common_unsigned_type (mvl)
    9001         2448 :                == c_common_unsigned_type (mvr))
    9002         3344 :               && (c_common_signed_type (mvl)
    9003         1672 :                   == c_common_signed_type (mvr))
    9004         1657 :               && TYPE_ATOMIC (mvl) == TYPE_ATOMIC (mvr)))
    9005              :         {
    9006              :           /* Warn about loss of qualifers from pointers to arrays with
    9007              :              qualifiers on the element type. */
    9008      2022512 :           if (TREE_CODE (ttr) == ARRAY_TYPE)
    9009              :             {
    9010         2131 :               ttr = strip_array_types (ttr);
    9011         2131 :               ttl = strip_array_types (ttl);
    9012              : 
    9013         2131 :               if (TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    9014         2131 :                   & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl))
    9015          115 :                 WARNING_FOR_QUALIFIERS (flag_isoc23,
    9016              :                                         location, expr_loc,
    9017              :                                         OPT_Wdiscarded_array_qualifiers,
    9018              :                                         G_("passing argument %d of %qE discards "
    9019              :                                            "%qv qualifier from pointer target type"),
    9020              :                                         G_("assignment discards %qv qualifier "
    9021              :                                            "from pointer target type"),
    9022              :                                         G_("initialization discards %qv qualifier "
    9023              :                                            "from pointer target type"),
    9024              :                                         G_("return discards %qv qualifier from "
    9025              :                                            "pointer target type"),
    9026              :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    9027              :             }
    9028      2020381 :           else if (pedantic
    9029       146269 :               && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
    9030       146249 :                   ||
    9031              :                   (VOID_TYPE_P (ttr)
    9032         2917 :                    && !null_pointer_constant
    9033          178 :                    && TREE_CODE (ttl) == FUNCTION_TYPE)))
    9034           34 :             PEDWARN_FOR_ASSIGNMENT (location, expr_loc, OPT_Wpedantic,
    9035              :                                     G_("ISO C forbids passing argument %d of "
    9036              :                                        "%qE between function pointer "
    9037              :                                        "and %<void *%>"),
    9038              :                                     G_("ISO C forbids assignment between "
    9039              :                                        "function pointer and %<void *%>"),
    9040              :                                     G_("ISO C forbids initialization between "
    9041              :                                        "function pointer and %<void *%>"),
    9042              :                                     G_("ISO C forbids return between function "
    9043              :                                        "pointer and %<void *%>"));
    9044              :           /* Const and volatile mean something different for function types,
    9045              :              so the usual warnings are not appropriate.  */
    9046      2020347 :           else if (TREE_CODE (ttr) != FUNCTION_TYPE
    9047      1987924 :                    && TREE_CODE (ttl) != FUNCTION_TYPE)
    9048              :             {
    9049              :                /* Assignments between atomic and non-atomic objects are OK.  */
    9050      1987211 :                bool warn_quals_ped = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    9051      1987211 :                                      & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl);
    9052      1987211 :                bool warn_quals = TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
    9053      1987211 :                                  & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (strip_array_types (ttl));
    9054              : 
    9055              :               /* Don't warn about loss of qualifier for conversions from
    9056              :                  qualified void* to pointers to arrays with corresponding
    9057              :                  qualifier on the element type (except for pedantic before C23). */
    9058      1987211 :               if (warn_quals || (warn_quals_ped && pedantic && !flag_isoc23))
    9059          697 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    9060              :                                         OPT_Wdiscarded_qualifiers,
    9061              :                                         G_("passing argument %d of %qE discards "
    9062              :                                            "%qv qualifier from pointer target type"),
    9063              :                                         G_("assignment discards %qv qualifier "
    9064              :                                            "from pointer target type"),
    9065              :                                         G_("initialization discards %qv qualifier "
    9066              :                                            "from pointer target type"),
    9067              :                                         G_("return discards %qv qualifier from "
    9068              :                                            "pointer target type"),
    9069              :                                         TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
    9070           11 :               else if (warn_quals_ped)
    9071           11 :                 pedwarn_c11 (location, OPT_Wc11_c23_compat,
    9072              :                              "array with qualifier on the element is not qualified before C23");
    9073              : 
    9074              :               /* If this is not a case of ignoring a mismatch in signedness,
    9075              :                  no warning.  */
    9076      1986503 :               else if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
    9077      1545861 :                        || target_cmp)
    9078              :                 ;
    9079              :               /* If there is a mismatch, do warn.  */
    9080         1649 :               else if (warn_pointer_sign)
    9081           82 :                 switch (errtype)
    9082              :                   {
    9083           33 :                   case ic_argpass:
    9084           33 :                     {
    9085           33 :                       auto_diagnostic_group d;
    9086           33 :                       range_label_for_type_mismatch rhs_label (rhstype, type);
    9087           33 :                       gcc_rich_location richloc (expr_loc, &rhs_label,
    9088           33 :                                                  highlight_colors::actual);
    9089           33 :                       if (pedwarn (&richloc, OPT_Wpointer_sign,
    9090              :                                    "pointer targets in passing argument %d of "
    9091              :                                    "%qE differ in signedness", parmnum, rname))
    9092           33 :                         inform_for_arg (fundecl, expr_loc, parmnum, type,
    9093              :                                         rhstype);
    9094           33 :                     }
    9095           33 :                     break;
    9096           21 :                   case ic_assign:
    9097           21 :                     pedwarn (location, OPT_Wpointer_sign,
    9098              :                              "pointer targets in assignment from %qT to %qT "
    9099              :                              "differ in signedness", rhstype, type);
    9100           21 :                     break;
    9101           14 :                   case ic_init:
    9102           14 :                   case ic_init_const:
    9103           14 :                     pedwarn_init (location, OPT_Wpointer_sign,
    9104              :                                   "pointer targets in initialization of %qT "
    9105              :                                   "from %qT differ in signedness", type,
    9106              :                                   rhstype);
    9107           14 :                     break;
    9108           14 :                   case ic_return:
    9109           14 :                     pedwarn (location, OPT_Wpointer_sign, "pointer targets in "
    9110              :                              "returning %qT from a function with return type "
    9111              :                              "%qT differ in signedness", rhstype, type);
    9112           14 :                     break;
    9113            0 :                   default:
    9114            0 :                     gcc_unreachable ();
    9115              :                   }
    9116              :             }
    9117        33136 :           else if (TREE_CODE (ttl) == FUNCTION_TYPE
    9118         4166 :                    && TREE_CODE (ttr) == FUNCTION_TYPE)
    9119              :             {
    9120              :               /* Because const and volatile on functions are restrictions
    9121              :                  that say the function will not do certain things,
    9122              :                  it is okay to use a const or volatile function
    9123              :                  where an ordinary one is wanted, but not vice-versa.  */
    9124         3453 :               if (TYPE_QUALS_NO_ADDR_SPACE (ttl)
    9125         3453 :                   & ~TYPE_QUALS_NO_ADDR_SPACE (ttr))
    9126           18 :                 PEDWARN_FOR_QUALIFIERS (location, expr_loc,
    9127              :                                         OPT_Wdiscarded_qualifiers,
    9128              :                                         G_("passing argument %d of %qE makes "
    9129              :                                            "%q#v qualified function pointer "
    9130              :                                            "from unqualified"),
    9131              :                                         G_("assignment makes %q#v qualified function "
    9132              :                                            "pointer from unqualified"),
    9133              :                                         G_("initialization makes %q#v qualified "
    9134              :                                            "function pointer from unqualified"),
    9135              :                                         G_("return makes %q#v qualified function "
    9136              :                                            "pointer from unqualified"),
    9137              :                                         TYPE_QUALS (ttl) & ~TYPE_QUALS (ttr));
    9138              :             }
    9139              :         }
    9140              :       /* Avoid warning about the volatile ObjC EH puts on decls.  */
    9141          799 :       else if (!objc_ok)
    9142              :         {
    9143          799 :           auto_diagnostic_group d;
    9144          799 :           bool warned = false;
    9145          799 :           pp_markup::element_expected_type e_type (type);
    9146          799 :           pp_markup::element_actual_type e_rhstype (rhstype);
    9147          799 :           switch (errtype)
    9148              :             {
    9149          306 :             case ic_argpass:
    9150          306 :               {
    9151          306 :                 range_label_for_type_mismatch rhs_label (rhstype, type);
    9152          306 :                 gcc_rich_location richloc (expr_loc, &rhs_label,
    9153          306 :                                            highlight_colors::actual);
    9154          306 :                 warned
    9155          306 :                   = permerror_opt (&richloc, OPT_Wincompatible_pointer_types,
    9156              :                                    "passing argument %d of %qE from "
    9157              :                                    "incompatible pointer type",
    9158              :                                    parmnum, rname);
    9159          306 :                 if (warned)
    9160          174 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    9161          306 :               }
    9162          306 :               break;
    9163          267 :             case ic_assign:
    9164          267 :               if (bltin)
    9165           11 :                 warned
    9166           11 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    9167              :                                    "assignment to %e from pointer to "
    9168              :                                    "%qD with incompatible type %e",
    9169              :                                    &e_type, bltin, &e_rhstype);
    9170              :               else
    9171          256 :                 warned
    9172          256 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    9173              :                                    "assignment to %e from incompatible "
    9174              :                                    "pointer type %e",
    9175              :                                    &e_type, &e_rhstype);
    9176              :               break;
    9177          167 :             case ic_init:
    9178          167 :             case ic_init_const:
    9179          167 :               if (bltin)
    9180           13 :                 warned
    9181           13 :                   = permerror_init (location, OPT_Wincompatible_pointer_types,
    9182              :                                     "initialization of %e from pointer to "
    9183              :                                     "%qD with incompatible type %e",
    9184              :                                     &e_type, bltin, &e_rhstype);
    9185              :               else
    9186          154 :                 warned
    9187          154 :                   = permerror_init (location, OPT_Wincompatible_pointer_types,
    9188              :                                     "initialization of %e from incompatible "
    9189              :                                     "pointer type %e",
    9190              :                                     &e_type, &e_rhstype);
    9191              :               break;
    9192           59 :             case ic_return:
    9193           59 :               if (bltin)
    9194           11 :                 warned
    9195           11 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    9196              :                                    "returning pointer to %qD of type %e from "
    9197              :                                    "a function with incompatible type %e",
    9198              :                                    bltin, &e_rhstype, &e_type);
    9199              :               else
    9200           48 :                 warned
    9201           48 :                   = permerror_opt (location, OPT_Wincompatible_pointer_types,
    9202              :                                    "returning %e from a function with "
    9203              :                                    "incompatible return type %e",
    9204              :                                    &e_rhstype, &e_type);
    9205              :               break;
    9206            0 :             default:
    9207            0 :               gcc_unreachable ();
    9208              :             }
    9209          799 :           if (warned)
    9210              :             {
    9211              :               /* If the mismatching function type is a pointer to a function,
    9212              :                  try to show the decl of the function.  */
    9213          589 :               if (TREE_CODE (rhs) == ADDR_EXPR
    9214          589 :                   && TREE_CODE (TREE_OPERAND (rhs, 0)) == FUNCTION_DECL)
    9215              :                 {
    9216          191 :                   tree rhs_fndecl = TREE_OPERAND (rhs, 0);
    9217          191 :                   if (!DECL_IS_UNDECLARED_BUILTIN (rhs_fndecl))
    9218              :                     {
    9219          165 :                       gcc_rich_location richloc
    9220          165 :                         (DECL_SOURCE_LOCATION (rhs_fndecl), nullptr,
    9221          165 :                          highlight_colors::actual);
    9222          165 :                       pp_element_quoted_decl e_rhs_fndecl
    9223          165 :                         (rhs_fndecl, highlight_colors::actual);
    9224          165 :                       inform (&richloc,
    9225              :                               "%e declared here", &e_rhs_fndecl);
    9226          165 :                     }
    9227              :                 }
    9228              :               /* If either/both of the types are typedefs, show the decl.  */
    9229          589 :               maybe_inform_typedef_location (type,
    9230              :                                              highlight_colors::expected);
    9231          589 :               maybe_inform_typedef_location (rhstype,
    9232              :                                              highlight_colors::actual);
    9233              :             }
    9234          799 :         }
    9235              : 
    9236              :       /* If RHS isn't an address, check pointer or array of packed
    9237              :          struct or union.  */
    9238      2023311 :       warn_for_address_of_packed_member (type, orig_rhs);
    9239              : 
    9240      2023311 :       return convert (type, rhs);
    9241              :     }
    9242        79914 :   else if (codel == POINTER_TYPE && coder == ARRAY_TYPE)
    9243              :     {
    9244              :       /* ??? This should not be an error when inlining calls to
    9245              :          unprototyped functions.  */
    9246            4 :       const char msg[] = "invalid use of non-lvalue array";
    9247            4 :       if (warnopt)
    9248            0 :         warning_at (location, warnopt, msg);
    9249              :       else
    9250            4 :         error_at (location, msg);
    9251            4 :       return error_mark_node;
    9252              :     }
    9253        79910 :   else if (codel == POINTER_TYPE
    9254        78387 :            && (coder == INTEGER_TYPE
    9255        78387 :                || coder == ENUMERAL_TYPE
    9256          616 :                || coder == BOOLEAN_TYPE
    9257          616 :                || coder == NULLPTR_TYPE
    9258           27 :                || coder == BITINT_TYPE))
    9259              :     {
    9260        78374 :       if (null_pointer_constant && c_inhibit_evaluation_warnings == 0
    9261        77376 :           && coder != NULLPTR_TYPE)
    9262        76816 :         warning_at (location, OPT_Wzero_as_null_pointer_constant,
    9263              :                     "zero as null pointer constant");
    9264              :       /* A NULLPTR type is just a nullptr always.  */
    9265        77814 :       if (coder == NULLPTR_TYPE)
    9266          575 :         return omit_one_operand_loc (expr_loc, type, nullptr_node, rhs);
    9267              :       /* An explicit constant 0 or type nullptr_t can convert to a pointer,
    9268              :          or one that results from arithmetic, even including a cast to
    9269              :          integer type.  */
    9270        77799 :       else if (!null_pointer_constant)
    9271          972 :         switch (errtype)
    9272              :           {
    9273          800 :           case ic_argpass:
    9274          800 :             {
    9275          800 :               auto_diagnostic_group d;
    9276          800 :               range_label_for_type_mismatch rhs_label (rhstype, type);
    9277          800 :               gcc_rich_location richloc (expr_loc, &rhs_label,
    9278          800 :                                          highlight_colors::actual);
    9279          800 :               if (permerror_opt (&richloc, OPT_Wint_conversion,
    9280              :                                  "passing argument %d of %qE makes pointer "
    9281              :                                  "from integer without a cast", parmnum, rname))
    9282              :                 {
    9283          439 :                   maybe_emit_indirection_note (expr_loc, rhs, type);
    9284          439 :                   inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    9285              :                 }
    9286          800 :             }
    9287          800 :             break;
    9288           93 :           case ic_assign:
    9289           93 :             permerror_opt (location, OPT_Wint_conversion,
    9290              :                            "assignment to %qT from %qT makes pointer from "
    9291              :                            "integer without a cast", type, rhstype);
    9292           93 :             break;
    9293           56 :           case ic_init:
    9294           56 :           case ic_init_const:
    9295           56 :             permerror_init (location, OPT_Wint_conversion,
    9296              :                             "initialization of %qT from %qT makes pointer "
    9297              :                             "from integer without a cast", type, rhstype);
    9298           56 :             break;
    9299           23 :           case ic_return:
    9300           23 :             permerror_init (location, OPT_Wint_conversion,
    9301              :                             "returning %qT from a function with return type "
    9302              :                             "%qT makes pointer from integer without a cast",
    9303              :                             rhstype, type);
    9304           23 :             break;
    9305            0 :           default:
    9306            0 :             gcc_unreachable ();
    9307              :           }
    9308              : 
    9309        77799 :       return convert (type, rhs);
    9310              :     }
    9311         1536 :   else if ((codel == INTEGER_TYPE || codel == BITINT_TYPE)
    9312          540 :            && coder == POINTER_TYPE)
    9313              :     {
    9314          514 :       switch (errtype)
    9315              :         {
    9316          344 :         case ic_argpass:
    9317          344 :           {
    9318          344 :             auto_diagnostic_group d;
    9319          344 :             range_label_for_type_mismatch rhs_label (rhstype, type);
    9320          344 :             gcc_rich_location richloc (expr_loc, &rhs_label,
    9321          344 :                                        highlight_colors::actual);
    9322          344 :             if (permerror_opt (&richloc, OPT_Wint_conversion,
    9323              :                                "passing argument %d of %qE makes integer from "
    9324              :                                "pointer without a cast", parmnum, rname))
    9325              :               {
    9326          323 :                 maybe_emit_indirection_note (expr_loc, rhs, type);
    9327          323 :                 inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    9328              :               }
    9329          344 :           }
    9330          344 :           break;
    9331           52 :         case ic_assign:
    9332           52 :           permerror_opt (location, OPT_Wint_conversion,
    9333              :                          "assignment to %qT from %qT makes integer from "
    9334              :                          "pointer without a cast", type, rhstype);
    9335           52 :           break;
    9336           83 :         case ic_init:
    9337           83 :         case ic_init_const:
    9338           83 :           permerror_init (location, OPT_Wint_conversion,
    9339              :                           "initialization of %qT from %qT makes integer "
    9340              :                           "from pointer without a cast", type, rhstype);
    9341           83 :           break;
    9342           35 :         case ic_return:
    9343           35 :           permerror_opt (location, OPT_Wint_conversion, "returning %qT from a "
    9344              :                          "function with return type %qT makes integer from "
    9345              :                          "pointer without a cast", rhstype, type);
    9346           35 :           break;
    9347            0 :         default:
    9348            0 :           gcc_unreachable ();
    9349              :         }
    9350              : 
    9351          514 :       return convert (type, rhs);
    9352              :     }
    9353          626 :   else if (C_BOOLEAN_TYPE_P (type)
    9354              :            /* The type nullptr_t may be converted to bool.  The
    9355              :               result is false.  */
    9356         1024 :            && (coder == POINTER_TYPE || coder == NULLPTR_TYPE))
    9357              :     {
    9358          398 :       tree ret;
    9359          398 :       bool save = in_late_binary_op;
    9360          398 :       in_late_binary_op = true;
    9361          398 :       ret = convert (type, rhs);
    9362          398 :       in_late_binary_op = save;
    9363          398 :       return ret;
    9364              :     }
    9365          624 :   else if (codel == NULLPTR_TYPE && null_pointer_constant)
    9366            6 :     return convert (type, rhs);
    9367              : 
    9368          618 :   switch (errtype)
    9369              :     {
    9370           35 :     case ic_argpass:
    9371           35 :       {
    9372           35 :         auto_diagnostic_group d;
    9373           35 :         range_label_for_type_mismatch rhs_label (rhstype, type);
    9374           35 :         gcc_rich_location richloc (expr_loc, &rhs_label,
    9375           35 :                                    highlight_colors::actual);
    9376           35 :         const char msg[] = G_("incompatible type for argument %d of %qE");
    9377           35 :         if (warnopt)
    9378            8 :           warning_at (expr_loc, warnopt, msg, parmnum, rname);
    9379              :         else
    9380           27 :           error_at (&richloc, msg, parmnum, rname);
    9381           35 :         inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype);
    9382           35 :       }
    9383           35 :       break;
    9384          108 :     case ic_assign:
    9385          108 :       {
    9386          108 :         const char msg[]
    9387              :           = G_("incompatible types when assigning to type %qT from type %qT");
    9388          108 :         if (warnopt)
    9389            0 :           warning_at (expr_loc, 0, msg, type, rhstype);
    9390              :         else
    9391          108 :           error_at (expr_loc, msg, type, rhstype);
    9392          108 :         break;
    9393              :       }
    9394          460 :     case ic_init:
    9395          460 :     case ic_init_const:
    9396          460 :       {
    9397          460 :         const char msg[]
    9398              :           = G_("incompatible types when initializing type %qT using type %qT");
    9399          460 :         if (warnopt)
    9400            0 :           warning_at (location, 0, msg, type, rhstype);
    9401              :         else
    9402          460 :           error_at (location, msg, type, rhstype);
    9403          460 :         break;
    9404              :       }
    9405           15 :     case ic_return:
    9406           15 :       {
    9407           15 :         const char msg[]
    9408              :           = G_("incompatible types when returning type %qT but %qT was expected");
    9409           15 :         if (warnopt)
    9410            0 :           warning_at (location, 0, msg, rhstype, type);
    9411              :         else
    9412           15 :           error_at (location, msg, rhstype, type);
    9413           15 :         break;
    9414              :       }
    9415            0 :     default:
    9416            0 :       gcc_unreachable ();
    9417              :     }
    9418              : 
    9419          618 :   return error_mark_node;
    9420              : }
    9421              : 
    9422              : /* If VALUE is a compound expr all of whose expressions are constant, then
    9423              :    return its value.  Otherwise, return error_mark_node.
    9424              : 
    9425              :    This is for handling COMPOUND_EXPRs as initializer elements
    9426              :    which is allowed with a warning when -pedantic is specified.  */
    9427              : 
    9428              : static tree
    9429            2 : valid_compound_expr_initializer (tree value, tree endtype)
    9430              : {
    9431            2 :   if (TREE_CODE (value) == COMPOUND_EXPR)
    9432              :     {
    9433            1 :       if (valid_compound_expr_initializer (TREE_OPERAND (value, 0), endtype)
    9434            1 :           == error_mark_node)
    9435              :         return error_mark_node;
    9436            0 :       return valid_compound_expr_initializer (TREE_OPERAND (value, 1),
    9437            0 :                                               endtype);
    9438              :     }
    9439            1 :   else if (!initializer_constant_valid_p (value, endtype))
    9440            1 :     return error_mark_node;
    9441              :   else
    9442              :     return value;
    9443              : }
    9444              : 
    9445              : /* Perform appropriate conversions on the initial value of a variable,
    9446              :    store it in the declaration DECL,
    9447              :    and print any error messages that are appropriate.
    9448              :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    9449              :    If the init is invalid, store an ERROR_MARK.
    9450              : 
    9451              :    INIT_LOC is the location of the initial value.  */
    9452              : 
    9453              : void
    9454      7275664 : store_init_value (location_t init_loc, tree decl, tree init, tree origtype)
    9455              : {
    9456      7275664 :   tree value, type;
    9457      7275664 :   bool npc = false;
    9458      7275664 :   bool int_const_expr = false;
    9459      7275664 :   bool arith_const_expr = false;
    9460              : 
    9461              :   /* If variable's type was invalidly declared, just ignore it.  */
    9462              : 
    9463      7275664 :   type = TREE_TYPE (decl);
    9464      7275664 :   if (TREE_CODE (type) == ERROR_MARK)
    9465              :     return;
    9466              : 
    9467              :   /* Digest the specified initializer into an expression.  */
    9468              : 
    9469      7275656 :   if (init)
    9470              :     {
    9471      7275653 :       npc = null_pointer_constant_p (init);
    9472      7275653 :       int_const_expr = (TREE_CODE (init) == INTEGER_CST
    9473       420722 :                         && !TREE_OVERFLOW (init)
    9474      7696339 :                         && INTEGRAL_TYPE_P (TREE_TYPE (init)));
    9475              :       /* Not fully determined before folding.  */
    9476              :       arith_const_expr = true;
    9477              :     }
    9478      7275656 :   bool constexpr_p = (VAR_P (decl)
    9479      7275656 :                       && C_DECL_DECLARED_CONSTEXPR (decl));
    9480      7275656 :   value = digest_init (init_loc, decl, type, init, origtype, npc,
    9481              :                        int_const_expr, arith_const_expr, true,
    9482      7275656 :                        TREE_STATIC (decl) || constexpr_p, constexpr_p);
    9483              : 
    9484              :   /* Store the expression if valid; else report error.  */
    9485              : 
    9486      7275656 :   if (!in_system_header_at (input_location)
    9487      7275656 :       && AGGREGATE_TYPE_P (TREE_TYPE (decl)) && !TREE_STATIC (decl))
    9488        28976 :     warning (OPT_Wtraditional, "traditional C rejects automatic "
    9489              :              "aggregate initialization");
    9490              : 
    9491      7275656 :   if (value != error_mark_node || TREE_CODE (decl) != FUNCTION_DECL)
    9492      7275655 :     DECL_INITIAL (decl) = value;
    9493              : 
    9494              :   /* ANSI wants warnings about out-of-range constant initializers.  */
    9495      7275667 :   STRIP_TYPE_NOPS (value);
    9496      7275656 :   if (TREE_STATIC (decl))
    9497       180736 :     constant_expression_warning (value);
    9498              : 
    9499              :   /* Check if we need to set array size from compound literal size.  */
    9500      7275656 :   if (TREE_CODE (type) == ARRAY_TYPE
    9501        26606 :       && TYPE_DOMAIN (type) == NULL_TREE
    9502      7288228 :       && value != error_mark_node)
    9503              :     {
    9504              :       tree inside_init = init;
    9505              : 
    9506        11700 :       STRIP_TYPE_NOPS (inside_init);
    9507        11700 :       inside_init = fold (inside_init);
    9508              : 
    9509        11700 :       if (TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
    9510              :         {
    9511           13 :           tree cldecl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
    9512              : 
    9513           13 :           if (TYPE_DOMAIN (TREE_TYPE (cldecl)))
    9514              :             {
    9515              :               /* For int foo[] = (int [3]){1}; we need to set array size
    9516              :                  now since later on array initializer will be just the
    9517              :                  brace enclosed list of the compound literal.  */
    9518           13 :               tree etype = strip_array_types (TREE_TYPE (decl));
    9519           13 :               type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    9520           13 :               TYPE_DOMAIN (type) = TYPE_DOMAIN (TREE_TYPE (cldecl));
    9521           13 :               layout_type (type);
    9522           13 :               layout_decl (cldecl, 0);
    9523           13 :               TREE_TYPE (decl)
    9524           26 :                 = c_build_qualified_type (type, TYPE_QUALS (etype));
    9525              :             }
    9526              :         }
    9527              :     }
    9528              : }
    9529              : 
    9530              : /* Methods for storing and printing names for error messages.  */
    9531              : 
    9532              : /* Implement a spelling stack that allows components of a name to be pushed
    9533              :    and popped.  Each element on the stack is this structure.  */
    9534              : 
    9535              : struct spelling
    9536              : {
    9537              :   int kind;
    9538              :   union
    9539              :     {
    9540              :       unsigned HOST_WIDE_INT i;
    9541              :       const char *s;
    9542              :     } u;
    9543              : };
    9544              : 
    9545              : #define SPELLING_STRING 1
    9546              : #define SPELLING_MEMBER 2
    9547              : #define SPELLING_BOUNDS 3
    9548              : 
    9549              : static struct spelling *spelling;       /* Next stack element (unused).  */
    9550              : static struct spelling *spelling_base;  /* Spelling stack base.  */
    9551              : static int spelling_size;               /* Size of the spelling stack.  */
    9552              : 
    9553              : /* Macros to save and restore the spelling stack around push_... functions.
    9554              :    Alternative to SAVE_SPELLING_STACK.  */
    9555              : 
    9556              : #define SPELLING_DEPTH() (spelling - spelling_base)
    9557              : #define RESTORE_SPELLING_DEPTH(DEPTH) (spelling = spelling_base + (DEPTH))
    9558              : 
    9559              : /* Push an element on the spelling stack with type KIND and assign VALUE
    9560              :    to MEMBER.  */
    9561              : 
    9562              : #define PUSH_SPELLING(KIND, VALUE, MEMBER)                              \
    9563              : {                                                                       \
    9564              :   int depth = SPELLING_DEPTH ();                                        \
    9565              :                                                                         \
    9566              :   if (depth >= spelling_size)                                                \
    9567              :     {                                                                   \
    9568              :       spelling_size += 10;                                              \
    9569              :       spelling_base = XRESIZEVEC (struct spelling, spelling_base,       \
    9570              :                                   spelling_size);                       \
    9571              :       RESTORE_SPELLING_DEPTH (depth);                                   \
    9572              :     }                                                                   \
    9573              :                                                                         \
    9574              :   spelling->kind = (KIND);                                           \
    9575              :   spelling->MEMBER = (VALUE);                                                \
    9576              :   spelling++;                                                           \
    9577              : }
    9578              : 
    9579              : /* Push STRING on the stack.  Printed literally.  */
    9580              : 
    9581              : static void
    9582      7272883 : push_string (const char *string)
    9583              : {
    9584      7272883 :   PUSH_SPELLING (SPELLING_STRING, string, u.s);
    9585      7272883 : }
    9586              : 
    9587              : /* Push a member name on the stack.  Printed as '.' STRING.  */
    9588              : 
    9589              : static void
    9590      1230931 : push_member_name (tree decl)
    9591              : {
    9592      1230931 :   const char *const string
    9593      1230931 :     = (DECL_NAME (decl)
    9594      1230931 :        ? identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)))
    9595          210 :        : _("<anonymous>"));
    9596      1230931 :   PUSH_SPELLING (SPELLING_MEMBER, string, u.s);
    9597      1230931 : }
    9598              : 
    9599              : /* Push an array bounds on the stack.  Printed as [BOUNDS].  */
    9600              : 
    9601              : static void
    9602      2603837 : push_array_bounds (unsigned HOST_WIDE_INT bounds)
    9603              : {
    9604      2603837 :   PUSH_SPELLING (SPELLING_BOUNDS, bounds, u.i);
    9605      2603837 : }
    9606              : 
    9607              : /* Compute the maximum size in bytes of the printed spelling.  */
    9608              : 
    9609              : static int
    9610         2892 : spelling_length (void)
    9611              : {
    9612         2892 :   int size = 0;
    9613         2892 :   struct spelling *p;
    9614              : 
    9615         6416 :   for (p = spelling_base; p < spelling; p++)
    9616              :     {
    9617         3524 :       if (p->kind == SPELLING_BOUNDS)
    9618         1479 :         size += 25;
    9619              :       else
    9620         2045 :         size += strlen (p->u.s) + 1;
    9621              :     }
    9622              : 
    9623         2892 :   return size;
    9624              : }
    9625              : 
    9626              : /* Print the spelling to BUFFER and return it.  */
    9627              : 
    9628              : static char *
    9629         2892 : print_spelling (char *buffer)
    9630              : {
    9631         2892 :   char *d = buffer;
    9632         2892 :   struct spelling *p;
    9633              : 
    9634         6416 :   for (p = spelling_base; p < spelling; p++)
    9635         3524 :     if (p->kind == SPELLING_BOUNDS)
    9636              :       {
    9637         1479 :         sprintf (d, "[" HOST_WIDE_INT_PRINT_UNSIGNED "]", p->u.i);
    9638         1479 :         d += strlen (d);
    9639              :       }
    9640              :     else
    9641              :       {
    9642         2045 :         const char *s;
    9643         2045 :         if (p->kind == SPELLING_MEMBER)
    9644          198 :           *d++ = '.';
    9645        16715 :         for (s = p->u.s; (*d = *s++); d++)
    9646              :           ;
    9647              :       }
    9648         2892 :   *d++ = '\0';
    9649         2892 :   return buffer;
    9650              : }
    9651              : 
    9652              : /* Check whether INIT, a floating or integer constant, is
    9653              :    representable in TYPE, a real floating type with the same radix or
    9654              :    a decimal floating type initialized with a binary floating
    9655              :    constant.  Return true if OK, false if not.  */
    9656              : static bool
    9657          362 : constexpr_init_fits_real_type (tree type, tree init)
    9658              : {
    9659          362 :   gcc_assert (SCALAR_FLOAT_TYPE_P (type));
    9660          362 :   gcc_assert (TREE_CODE (init) == INTEGER_CST || TREE_CODE (init) == REAL_CST);
    9661          362 :   if (TREE_CODE (init) == REAL_CST
    9662          362 :       && TYPE_MODE (TREE_TYPE (init)) == TYPE_MODE (type))
    9663              :     {
    9664              :       /* Same mode, no conversion required except for the case of
    9665              :          signaling NaNs if the types are incompatible (e.g. double and
    9666              :          long double with the same mode).  */
    9667          177 :       if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init))
    9668          195 :           && !comptypes (TYPE_MAIN_VARIANT (type),
    9669           18 :                          TYPE_MAIN_VARIANT (TREE_TYPE (init))))
    9670              :         return false;
    9671          177 :       return true;
    9672              :     }
    9673          185 :   if (TREE_CODE (init) == INTEGER_CST)
    9674              :     {
    9675           54 :       tree converted = build_real_from_int_cst (type, init);
    9676           54 :       bool fail = false;
    9677          108 :       wide_int w = real_to_integer (&TREE_REAL_CST (converted), &fail,
    9678           54 :                                     TYPE_PRECISION (TREE_TYPE (init)));
    9679           68 :       return !fail && wi::eq_p (w, wi::to_wide (init));
    9680           54 :     }
    9681          131 :   if (REAL_VALUE_ISSIGNALING_NAN (TREE_REAL_CST (init)))
    9682              :     return false;
    9683          114 :   if ((REAL_VALUE_ISINF (TREE_REAL_CST (init))
    9684           34 :        && MODE_HAS_INFINITIES (TYPE_MODE (type)))
    9685          218 :       || (REAL_VALUE_ISNAN (TREE_REAL_CST (init))
    9686           34 :           && MODE_HAS_NANS (TYPE_MODE (type))))
    9687           20 :     return true;
    9688           94 :   if (DECIMAL_FLOAT_TYPE_P (type)
    9689          134 :       && !DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init)))
    9690              :     {
    9691              :       /* This is valid if the real number represented by the
    9692              :          initializer can be exactly represented in the decimal
    9693              :          type.  Compare the values using MPFR.  */
    9694            8 :       REAL_VALUE_TYPE t;
    9695            8 :       real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    9696            8 :       mpfr_t bin_val, dec_val;
    9697            8 :       mpfr_init2 (bin_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    9698            8 :       mpfr_init2 (dec_val, REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (init)))->p);
    9699            8 :       mpfr_from_real (bin_val, &TREE_REAL_CST (init), MPFR_RNDN);
    9700            8 :       char string[256];
    9701            8 :       real_to_decimal (string, &t, sizeof string, 0, 1);
    9702            8 :       bool res = (mpfr_strtofr (dec_val, string, NULL, 10, MPFR_RNDN) == 0
    9703            8 :                   && mpfr_equal_p (bin_val, dec_val));
    9704            8 :       mpfr_clear (bin_val);
    9705            8 :       mpfr_clear (dec_val);
    9706            8 :       return res;
    9707              :     }
    9708              :   /* exact_real_truncate is not quite right here, since it doesn't
    9709              :      allow even an exact conversion to subnormal values.  */
    9710           86 :   REAL_VALUE_TYPE t;
    9711           86 :   real_convert (&t, TYPE_MODE (type), &TREE_REAL_CST (init));
    9712           86 :   return real_identical (&t, &TREE_REAL_CST (init));
    9713              : }
    9714              : 
    9715              : /* Check whether INIT (location LOC) is valid as a 'constexpr'
    9716              :    initializer for type TYPE, and give an error if not.  INIT has
    9717              :    already been folded and verified to be constant.  INT_CONST_EXPR
    9718              :    and ARITH_CONST_EXPR say whether it is an integer constant
    9719              :    expression or arithmetic constant expression, respectively.  If
    9720              :    TYPE is not a scalar type, this function does nothing.  */
    9721              : 
    9722              : static void
    9723          912 : check_constexpr_init (location_t loc, tree type, tree init,
    9724              :                       bool int_const_expr, bool arith_const_expr)
    9725              : {
    9726          912 :   if (POINTER_TYPE_P (type))
    9727              :     {
    9728              :       /* The initializer must be null.  */
    9729           86 :       if (TREE_CODE (init) != INTEGER_CST || !integer_zerop (init))
    9730            8 :         error_at (loc, "%<constexpr%> pointer initializer is not null");
    9731           86 :       return;
    9732              :     }
    9733          826 :   if (INTEGRAL_TYPE_P (type))
    9734              :     {
    9735              :       /* The initializer must be an integer constant expression,
    9736              :          representable in the target type.  */
    9737          316 :       if (!int_const_expr)
    9738              :         {
    9739           13 :           if (TREE_CODE (init) == RAW_DATA_CST
    9740           13 :               && TYPE_PRECISION (type) == CHAR_BIT)
    9741              :             {
    9742            4 :               if (!TYPE_UNSIGNED (type))
    9743          137 :                 for (unsigned int i = 0;
    9744          140 :                      i < (unsigned) RAW_DATA_LENGTH (init); ++i)
    9745          138 :                   if (RAW_DATA_SCHAR_ELT (init, i) < 0)
    9746              :                     {
    9747            1 :                       error_at (loc, "%<constexpr%> initializer not "
    9748              :                                 "representable in type of object");
    9749            1 :                       break;
    9750              :                     }
    9751              :             }
    9752              :           else
    9753            9 :             error_at (loc, "%<constexpr%> integer initializer is not an "
    9754              :                       "integer constant expression");
    9755              :         }
    9756          303 :       else if (!int_fits_type_p (init, type))
    9757            6 :         error_at (loc, "%<constexpr%> initializer not representable in "
    9758              :                   "type of object");
    9759          316 :       return;
    9760              :     }
    9761              :   /* We don't apply any extra checks to extension types such as vector
    9762              :      or fixed-point types.  */
    9763          510 :   if (TREE_CODE (type) != REAL_TYPE && TREE_CODE (type) != COMPLEX_TYPE)
    9764              :     return;
    9765          353 :   if (!arith_const_expr)
    9766              :     {
    9767            5 :       error_at (loc, "%<constexpr%> initializer is not an arithmetic "
    9768              :                 "constant expression");
    9769            5 :       return;
    9770              :     }
    9771              :   /* We don't apply any extra checks to complex integers.  */
    9772          348 :   if (TREE_CODE (type) == COMPLEX_TYPE
    9773          348 :       && TREE_CODE (TREE_TYPE (type)) != REAL_TYPE)
    9774              :     return;
    9775              :   /* Following N3082, a real type cannot be initialized from a complex
    9776              :      type and a binary type cannot be initialized from a decimal type
    9777              :      (but initializing a decimal type from a binary type is OK).
    9778              :      Signaling NaN initializers are OK only if the types are
    9779              :      compatible (not just the same mode); all quiet NaN and infinity
    9780              :      initializations are considered to preserve the value.  */
    9781          348 :   if (TREE_CODE (TREE_TYPE (init)) == COMPLEX_TYPE
    9782          348 :       && SCALAR_FLOAT_TYPE_P (type))
    9783              :     {
    9784            6 :       error_at (loc, "%<constexpr%> initializer for a real type is of "
    9785              :                 "complex type");
    9786            6 :       return;
    9787              :     }
    9788          342 :   if (SCALAR_FLOAT_TYPE_P (type)
    9789          300 :       && SCALAR_FLOAT_TYPE_P (TREE_TYPE (init))
    9790          250 :       && DECIMAL_FLOAT_TYPE_P (TREE_TYPE (init))
    9791          481 :       && !DECIMAL_FLOAT_TYPE_P (type))
    9792              :     {
    9793            6 :       error_at (loc, "%<constexpr%> initializer for a binary "
    9794              :                 "floating-point type is of decimal type");
    9795            6 :       return;
    9796              :     }
    9797          336 :   bool fits;
    9798          336 :   if (TREE_CODE (type) == COMPLEX_TYPE)
    9799              :     {
    9800           42 :       switch (TREE_CODE (init))
    9801              :         {
    9802           10 :         case INTEGER_CST:
    9803           10 :         case REAL_CST:
    9804           10 :           fits = constexpr_init_fits_real_type (TREE_TYPE (type), init);
    9805           10 :           break;
    9806           32 :         case COMPLEX_CST:
    9807           32 :           fits = (constexpr_init_fits_real_type (TREE_TYPE (type),
    9808           32 :                                                  TREE_REALPART (init))
    9809           58 :                   && constexpr_init_fits_real_type (TREE_TYPE (type),
    9810           26 :                                                     TREE_IMAGPART (init)));
    9811              :           break;
    9812            0 :         default:
    9813            0 :           gcc_unreachable ();
    9814              :         }
    9815              :     }
    9816              :   else
    9817          294 :     fits = constexpr_init_fits_real_type (type, init);
    9818          304 :   if (!fits)
    9819           65 :     error_at (loc, "%<constexpr%> initializer not representable in "
    9820              :               "type of object");
    9821              : }
    9822              : 
    9823              : /* Digest the parser output INIT as an initializer for type TYPE
    9824              :    initializing DECL.
    9825              :    Return a C expression of type TYPE to represent the initial value.
    9826              : 
    9827              :    If ORIGTYPE is not NULL_TREE, it is the original type of INIT.
    9828              : 
    9829              :    NULL_POINTER_CONSTANT is true if INIT is a null pointer constant,
    9830              :    INT_CONST_EXPR is true if INIT is an integer constant expression,
    9831              :    and ARITH_CONST_EXPR is true if INIT is, or might be, an arithmetic
    9832              :    constant expression, false if it has already been determined in the
    9833              :    caller that it is not (but folding may have made the value passed here
    9834              :    indistinguishable from an arithmetic constant expression).
    9835              : 
    9836              :    If INIT is a string constant, STRICT_STRING is true if it is
    9837              :    unparenthesized or we should not warn here for it being parenthesized.
    9838              :    For other types of INIT, STRICT_STRING is not used.
    9839              : 
    9840              :    INIT_LOC is the location of the INIT.
    9841              : 
    9842              :    REQUIRE_CONSTANT requests an error if non-constant initializers or
    9843              :    elements are seen.  REQUIRE_CONSTEXPR means the stricter requirements
    9844              :    on initializers for 'constexpr' objects apply.  */
    9845              : 
    9846              : static tree
    9847     16908062 : digest_init (location_t init_loc, tree decl, tree type, tree init,
    9848              :              tree origtype, bool null_pointer_constant, bool int_const_expr,
    9849              :              bool arith_const_expr, bool strict_string,
    9850              :              bool require_constant, bool require_constexpr)
    9851              : {
    9852     16908062 :   enum tree_code code = TREE_CODE (type);
    9853     16908062 :   tree inside_init = init;
    9854     16908062 :   tree semantic_type = NULL_TREE;
    9855     16908062 :   bool maybe_const = true;
    9856              : 
    9857     16908062 :   if (type == error_mark_node
    9858     16908062 :       || !init
    9859     33816121 :       || error_operand_p (init))
    9860              :     return error_mark_node;
    9861              : 
    9862     16915448 :   STRIP_TYPE_NOPS (inside_init);
    9863              : 
    9864              :   /* If require_constant is TRUE,  when the initializer is a call to
    9865              :      .ACCESS_WITH_SIZE, use the first argument as the initializer.
    9866              :      For example:
    9867              :      y = (char *) .ACCESS_WITH_SIZE ((char *) &static_annotated.c,...)
    9868              :      will be converted to
    9869              :      y = &static_annotated.c.  */
    9870              : 
    9871     16906884 :   if (require_constant
    9872      2893140 :       && TREE_CODE (inside_init) == NOP_EXPR
    9873       736243 :       && TREE_CODE (TREE_OPERAND (inside_init, 0)) == CALL_EXPR
    9874     16906886 :       && is_access_with_size_p (TREE_OPERAND (inside_init, 0)))
    9875            2 :     inside_init
    9876            2 :       = get_ref_from_access_with_size (TREE_OPERAND (inside_init, 0));
    9877              : 
    9878     16906884 :   if (!c_in_omp_for)
    9879              :     {
    9880     16902132 :       if (TREE_CODE (inside_init) == EXCESS_PRECISION_EXPR)
    9881              :         {
    9882          441 :           semantic_type = TREE_TYPE (inside_init);
    9883          441 :           inside_init = TREE_OPERAND (inside_init, 0);
    9884              :         }
    9885     16902132 :       inside_init = c_fully_fold (inside_init, require_constant, &maybe_const);
    9886              :     }
    9887              :   /* TODO: this may not detect all cases of expressions folding to
    9888              :      constants that are not arithmetic constant expressions.  */
    9889     16906884 :   if (!maybe_const)
    9890              :     arith_const_expr = false;
    9891     25231939 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (inside_init))
    9892      5660366 :            && TREE_CODE (TREE_TYPE (inside_init)) != REAL_TYPE
    9893     16841964 :            && TREE_CODE (TREE_TYPE (inside_init)) != COMPLEX_TYPE)
    9894              :     arith_const_expr = false;
    9895      8418545 :   else if (TREE_CODE (inside_init) != INTEGER_CST
    9896              :            && TREE_CODE (inside_init) != REAL_CST
    9897              :            && TREE_CODE (inside_init) != COMPLEX_CST
    9898              :            && TREE_CODE (inside_init) != RAW_DATA_CST)
    9899              :     arith_const_expr = false;
    9900      5078319 :   else if (TREE_OVERFLOW (inside_init))
    9901     11828609 :     arith_const_expr = false;
    9902              : 
    9903              :   /* Initialization of an array of chars from a string constant
    9904              :      optionally enclosed in braces.  */
    9905              : 
    9906     16906884 :   if (code == ARRAY_TYPE && inside_init
    9907       189479 :       && TREE_CODE (inside_init) == STRING_CST)
    9908              :     {
    9909        11784 :       tree typ1
    9910        11784 :         = (TYPE_ATOMIC (TREE_TYPE (type))
    9911        11784 :            ? c_build_qualified_type (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
    9912              :                                      TYPE_QUAL_ATOMIC)
    9913        11770 :            : TYPE_MAIN_VARIANT (TREE_TYPE (type)));
    9914              :       /* Note that an array could be both an array of character type
    9915              :          and an array of wchar_t if wchar_t is signed char or unsigned
    9916              :          char.  */
    9917        23568 :       bool char_array = (typ1 == char_type_node
    9918          516 :                          || typ1 == signed_char_type_node
    9919        12265 :                          || typ1 == unsigned_char_type_node);
    9920        11784 :       bool wchar_array = comptypes (typ1, wchar_type_node);
    9921        11784 :       bool char16_array = comptypes (typ1, char16_type_node);
    9922        11784 :       bool char32_array = comptypes (typ1, char32_type_node);
    9923              : 
    9924        11784 :       if (char_array || wchar_array || char16_array || char32_array)
    9925              :         {
    9926        11755 :           struct c_expr expr;
    9927        11755 :           tree typ2 = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)));
    9928        11755 :           bool incompat_string_cst = false;
    9929        11755 :           expr.value = inside_init;
    9930        11755 :           expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
    9931        11755 :           expr.original_type = NULL;
    9932        11755 :           expr.m_decimal = 0;
    9933        11755 :           maybe_warn_string_init (init_loc, type, expr);
    9934              : 
    9935        11755 :           if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
    9936           91 :             pedwarn_init (init_loc, OPT_Wpedantic,
    9937              :                           "initialization of a flexible array member");
    9938              : 
    9939        11755 :           if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
    9940        11755 :                          TYPE_MAIN_VARIANT (type)))
    9941              :             return inside_init;
    9942              : 
    9943         4186 :           if (char_array)
    9944              :             {
    9945         4075 :               if (typ2 != char_type_node && typ2 != char8_type_node)
    9946              :                 incompat_string_cst = true;
    9947              :             }
    9948          111 :           else if (!comptypes (typ1, typ2))
    9949              :             incompat_string_cst = true;
    9950              : 
    9951              :           if (incompat_string_cst)
    9952              :             {
    9953           72 :               error_init (init_loc, "cannot initialize array of %qT from "
    9954              :                           "a string literal with type array of %qT",
    9955              :                           typ1, typ2);
    9956           72 :               return error_mark_node;
    9957              :             }
    9958              : 
    9959         4114 :           if (require_constexpr
    9960         4114 :               && TYPE_UNSIGNED (typ1) != TYPE_UNSIGNED (typ2))
    9961              :             {
    9962              :               /* Check if all characters of the string can be
    9963              :                  represented in the type of the constexpr object being
    9964              :                  initialized.  */
    9965           24 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    9966           24 :               const unsigned char *p =
    9967           24 :                 (const unsigned char *) TREE_STRING_POINTER (inside_init);
    9968           24 :               gcc_assert (CHAR_TYPE_SIZE == 8 && CHAR_BIT == 8);
    9969           70 :               for (unsigned i = 0; i < len; i++)
    9970           58 :                 if (p[i] > 127)
    9971              :                   {
    9972           12 :                     error_init (init_loc, "%<constexpr%> initializer not "
    9973              :                                 "representable in type of object");
    9974           12 :                     break;
    9975              :                   }
    9976              :             }
    9977              : 
    9978         4114 :           if (TYPE_DOMAIN (type) != NULL_TREE
    9979         4020 :               && TYPE_SIZE (type) != NULL_TREE
    9980         8075 :               && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
    9981              :             {
    9982         3961 :               unsigned HOST_WIDE_INT len = TREE_STRING_LENGTH (inside_init);
    9983              : 
    9984         3961 :               if (compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0)
    9985              :                 {
    9986          397 :                   unsigned HOST_WIDE_INT avail
    9987          397 :                     = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    9988          397 :                   unsigned unit = TYPE_PRECISION (typ1) / BITS_PER_UNIT;
    9989          397 :                   const char *p = TREE_STRING_POINTER (inside_init);
    9990              : 
    9991              :                   /* Construct truncated string.  */
    9992          397 :                   inside_init = build_string (avail, p);
    9993              : 
    9994              :                   /* Subtract the size of a single (possibly wide) character
    9995              :                      because it may be ok to ignore the terminating NUL char
    9996              :                      that is counted in the length of the constant.  */
    9997          397 :                   if (len - unit > avail)
    9998           63 :                     pedwarn_init (init_loc, 0,
    9999              :                                   "initializer-string for array of %qT "
   10000              :                                   "is too long (%wu chars into %wu "
   10001              :                                   "available)", typ1, len, avail);
   10002          334 :                   else if (warn_cxx_compat)
   10003            9 :                     warning_at (init_loc, OPT_Wc___compat,
   10004              :                                 "initializer-string for array of %qT "
   10005              :                                 "is too long for C++ (%wu chars into %wu "
   10006              :                                 "available)", typ1, len, avail);
   10007          325 :                   else if (warn_unterminated_string_initialization
   10008          325 :                            && get_attr_nonstring_decl (decl) == NULL_TREE)
   10009           22 :                     warning_at (init_loc,
   10010           22 :                                 OPT_Wunterminated_string_initialization,
   10011              :                                 "initializer-string for array of %qT "
   10012              :                                 "truncates NUL terminator but destination "
   10013              :                                 "lacks %qs attribute (%wu chars into %wu "
   10014              :                                 "available)", typ1, "nonstring", len, avail);
   10015              :                 }
   10016              :             }
   10017              : 
   10018         4114 :           TREE_TYPE (inside_init) = type;
   10019         4114 :           return inside_init;
   10020              :         }
   10021           29 :       else if (INTEGRAL_TYPE_P (typ1))
   10022              :         {
   10023           29 :           error_init (init_loc, "array of inappropriate type initialized "
   10024              :                       "from string constant");
   10025           29 :           return error_mark_node;
   10026              :         }
   10027              :     }
   10028              : 
   10029              :   /* Build a VECTOR_CST from a *constant* vector constructor.  If the
   10030              :      vector constructor is not constant (e.g. {1,2,3,foo()}) then punt
   10031              :      below and handle as a constructor.  */
   10032     16895100 :   if (code == VECTOR_TYPE
   10033      6312390 :       && VECTOR_TYPE_P (TREE_TYPE (inside_init))
   10034      6312388 :       && vector_types_convertible_p (TREE_TYPE (inside_init), type, true)
   10035     23207450 :       && TREE_CONSTANT (inside_init))
   10036              :     {
   10037       633392 :       if (TREE_CODE (inside_init) == VECTOR_CST
   10038       633489 :           && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
   10039           97 :                         TYPE_MAIN_VARIANT (type)))
   10040              :         return inside_init;
   10041              : 
   10042       633295 :       if (TREE_CODE (inside_init) == CONSTRUCTOR)
   10043              :         {
   10044              :           unsigned HOST_WIDE_INT ix;
   10045              :           tree value;
   10046      4174541 :           bool constant_p = true;
   10047              : 
   10048              :           /* Iterate through elements and check if all constructor
   10049              :              elements are *_CSTs.  */
   10050      4174541 :           FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (inside_init), ix, value)
   10051      3541302 :             if (!CONSTANT_CLASS_P (value))
   10052              :               {
   10053              :                 constant_p = false;
   10054              :                 break;
   10055              :               }
   10056              : 
   10057       633295 :           if (constant_p)
   10058       633239 :             return build_vector_from_ctor (type,
   10059       633239 :                                            CONSTRUCTOR_ELTS (inside_init));
   10060              :         }
   10061              :     }
   10062              : 
   10063     16261764 :   if (warn_sequence_point)
   10064      2448959 :     verify_sequence_points (inside_init);
   10065              : 
   10066              :   /* Any type can be initialized
   10067              :      from an expression of the same type, optionally with braces.  */
   10068              : 
   10069     16261764 :   if (inside_init && TREE_TYPE (inside_init) != NULL_TREE
   10070     32523528 :       && (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
   10071     16261764 :                      TYPE_MAIN_VARIANT (type))
   10072      3134613 :           || (code == ARRAY_TYPE
   10073          477 :               && comptypes (TREE_TYPE (inside_init), type))
   10074      3134613 :           || (gnu_vector_type_p (type)
   10075          189 :               && comptypes (TREE_TYPE (inside_init), type))
   10076      3134613 :           || (code == POINTER_TYPE
   10077       112646 :               && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
   10078         9295 :               && comptypes (TREE_TYPE (TREE_TYPE (inside_init)),
   10079         9295 :                             TREE_TYPE (type)))))
   10080              :     {
   10081     13129129 :       if (code == POINTER_TYPE)
   10082              :         {
   10083       784857 :           if (TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE)
   10084              :             {
   10085         1978 :               if (TREE_CODE (inside_init) == STRING_CST
   10086           68 :                   || TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
   10087         1975 :                 inside_init = array_to_pointer_conversion
   10088         1975 :                   (init_loc, inside_init);
   10089              :               else
   10090              :                 {
   10091            3 :                   error_init (init_loc, "invalid use of non-lvalue array");
   10092            3 :                   return error_mark_node;
   10093              :                 }
   10094              :             }
   10095              :         }
   10096              : 
   10097     13129126 :       if (code == VECTOR_TYPE || c_hardbool_type_attr (type))
   10098              :         /* Although the types are compatible, we may require a
   10099              :            conversion.  */
   10100      5678998 :         inside_init = convert (type, inside_init);
   10101              : 
   10102     13129126 :       if ((code == RECORD_TYPE || code == UNION_TYPE)
   10103     13129126 :           && !comptypes (TYPE_MAIN_VARIANT (type), TYPE_MAIN_VARIANT (TREE_TYPE (inside_init))))
   10104              :         {
   10105            0 :           error_init (init_loc, "invalid initializer");
   10106            0 :           return error_mark_node;
   10107              :         }
   10108              : 
   10109     13129126 :       if (require_constant
   10110      2298029 :           && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
   10111              :         {
   10112              :           /* As an extension, allow initializing objects with static storage
   10113              :              duration with compound literals (which are then treated just as
   10114              :              the brace enclosed list they contain).  Also allow this for
   10115              :              vectors, as we can only assign them with compound literals.  */
   10116           31 :           if (flag_isoc99 && code != VECTOR_TYPE)
   10117            8 :             pedwarn_init (init_loc, OPT_Wpedantic, "initializer element "
   10118              :                           "is not constant");
   10119           31 :           tree decl = COMPOUND_LITERAL_EXPR_DECL (inside_init);
   10120           31 :           inside_init = DECL_INITIAL (decl);
   10121              :         }
   10122              : 
   10123     13129126 :       if (code == ARRAY_TYPE && TREE_CODE (inside_init) != STRING_CST
   10124       177218 :           && TREE_CODE (inside_init) != CONSTRUCTOR)
   10125              :         {
   10126            2 :           error_init (init_loc, "array initialized from non-constant array "
   10127              :                       "expression");
   10128            2 :           return error_mark_node;
   10129              :         }
   10130              : 
   10131              :       /* Compound expressions can only occur here if -Wpedantic or
   10132              :          -pedantic-errors is specified.  In the later case, we always want
   10133              :          an error.  In the former case, we simply want a warning.  */
   10134     13129124 :       if (require_constant && pedantic
   10135        20308 :           && TREE_CODE (inside_init) == COMPOUND_EXPR)
   10136              :         {
   10137            1 :           inside_init
   10138            1 :             = valid_compound_expr_initializer (inside_init,
   10139            1 :                                                TREE_TYPE (inside_init));
   10140            1 :           if (inside_init == error_mark_node)
   10141            1 :             error_init (init_loc, "initializer element is not constant");
   10142              :           else
   10143            0 :             pedwarn_init (init_loc, OPT_Wpedantic,
   10144              :                           "initializer element is not constant");
   10145            1 :           if (flag_pedantic_errors)
   10146            0 :             inside_init = error_mark_node;
   10147              :         }
   10148      2298028 :       else if (require_constant
   10149      2298028 :                && !initializer_constant_valid_p (inside_init,
   10150      2298028 :                                                  TREE_TYPE (inside_init)))
   10151              :         {
   10152           94 :           error_init (init_loc, "initializer element is not constant");
   10153           94 :           inside_init = error_mark_node;
   10154              :         }
   10155     13129029 :       else if (require_constant && !maybe_const)
   10156          219 :         pedwarn_init (init_loc, OPT_Wpedantic,
   10157              :                       "initializer element is not a constant expression");
   10158     13128810 :       else if (require_constexpr)
   10159          584 :         check_constexpr_init (init_loc, type, inside_init,
   10160              :                               int_const_expr, arith_const_expr);
   10161              : 
   10162              :       /* Added to enable additional -Wsuggest-attribute=format warnings.  */
   10163     13129124 :       if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
   10164       854039 :         inside_init = convert_for_assignment (init_loc, UNKNOWN_LOCATION,
   10165              :                                               type, inside_init, origtype,
   10166              :                                               (require_constant
   10167              :                                                ? ic_init_const
   10168              :                                                : ic_init), null_pointer_constant,
   10169              :                                               NULL_TREE, NULL_TREE, 0);
   10170     13129124 :       if (TREE_CODE (inside_init) == RAW_DATA_CST
   10171          255 :           && c_inhibit_evaluation_warnings == 0
   10172          255 :           && warn_conversion
   10173            1 :           && !TYPE_UNSIGNED (type)
   10174     13129125 :           && TYPE_PRECISION (type) == CHAR_BIT)
   10175          303 :         for (unsigned int i = 0;
   10176          304 :              i < (unsigned) RAW_DATA_LENGTH (inside_init); ++i)
   10177          303 :           if (RAW_DATA_SCHAR_ELT (inside_init, i) < 0)
   10178           10 :             warning_at (init_loc, OPT_Wconversion,
   10179              :                         "conversion from %qT to %qT changes value from "
   10180              :                         "%qd to %qd",
   10181              :                         integer_type_node, type,
   10182           10 :                         RAW_DATA_UCHAR_ELT (inside_init, i),
   10183           10 :                         RAW_DATA_SCHAR_ELT (inside_init, i));
   10184     13129124 :       return inside_init;
   10185              :     }
   10186              : 
   10187              :   /* Handle scalar types, including conversions.  */
   10188              : 
   10189      3132635 :   if (code == INTEGER_TYPE || code == REAL_TYPE || code == FIXED_POINT_TYPE
   10190       129485 :       || code == POINTER_TYPE || code == ENUMERAL_TYPE || code == BOOLEAN_TYPE
   10191        11793 :       || code == COMPLEX_TYPE || code == VECTOR_TYPE || code == NULLPTR_TYPE
   10192         9730 :       || code == BITINT_TYPE)
   10193              :     {
   10194      3132147 :       tree unconverted_init = inside_init;
   10195      3132147 :       if (TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE
   10196      3132147 :           && (TREE_CODE (init) == STRING_CST
   10197            2 :               || TREE_CODE (init) == COMPOUND_LITERAL_EXPR))
   10198         7318 :         inside_init = init = array_to_pointer_conversion (init_loc, init);
   10199      3132147 :       if (semantic_type)
   10200          436 :         inside_init = build1 (EXCESS_PRECISION_EXPR, semantic_type,
   10201              :                               inside_init);
   10202      3132147 :       inside_init
   10203      5683973 :         = convert_for_assignment (init_loc, UNKNOWN_LOCATION, type,
   10204              :                                   inside_init, origtype,
   10205              :                                   require_constant ? ic_init_const : ic_init,
   10206              :                                   null_pointer_constant, NULL_TREE, NULL_TREE,
   10207              :                                   0);
   10208              : 
   10209              :       /* Check to see if we have already given an error message.  */
   10210      3132147 :       if (inside_init == error_mark_node)
   10211              :         ;
   10212      3131687 :       else if (require_constant && !TREE_CONSTANT (inside_init))
   10213              :         {
   10214           36 :           error_init (init_loc, "initializer element is not constant");
   10215           36 :           inside_init = error_mark_node;
   10216              :         }
   10217      3131651 :       else if (require_constant
   10218      3711544 :                && !initializer_constant_valid_p (inside_init,
   10219       579893 :                                                  TREE_TYPE (inside_init)))
   10220              :         {
   10221           10 :           error_init (init_loc, "initializer element is not computable at "
   10222              :                       "load time");
   10223           10 :           inside_init = error_mark_node;
   10224              :         }
   10225      3131641 :       else if (require_constant && !maybe_const)
   10226            5 :         pedwarn_init (init_loc, OPT_Wpedantic,
   10227              :                       "initializer element is not a constant expression");
   10228      3131636 :       else if (require_constexpr)
   10229          328 :         check_constexpr_init (init_loc, type, unconverted_init,
   10230              :                               int_const_expr, arith_const_expr);
   10231              : 
   10232      3132147 :       return inside_init;
   10233              :     }
   10234              : 
   10235              :   /* Come here only for records and arrays.  */
   10236              : 
   10237          488 :   if (COMPLETE_TYPE_P (type) && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
   10238              :     {
   10239            0 :       error_init (init_loc,
   10240              :                   "variable-sized object may not be initialized except "
   10241              :                   "with an empty initializer");
   10242            0 :       return error_mark_node;
   10243              :     }
   10244              : 
   10245          488 :   error_init (init_loc, "invalid initializer");
   10246          488 :   return error_mark_node;
   10247              : }
   10248              : 
   10249              : /* Handle initializers that use braces.  */
   10250              : 
   10251              : /* Type of object we are accumulating a constructor for.
   10252              :    This type is always a RECORD_TYPE, UNION_TYPE or ARRAY_TYPE.  */
   10253              : static tree constructor_type;
   10254              : 
   10255              : /* For a RECORD_TYPE or UNION_TYPE, this is the chain of fields
   10256              :    left to fill.  */
   10257              : static tree constructor_fields;
   10258              : 
   10259              : /* For an ARRAY_TYPE, this is the specified index
   10260              :    at which to store the next element we get.  */
   10261              : static tree constructor_index;
   10262              : 
   10263              : /* For an ARRAY_TYPE, this is the maximum index.  */
   10264              : static tree constructor_max_index;
   10265              : 
   10266              : /* For a RECORD_TYPE, this is the first field not yet written out.  */
   10267              : static tree constructor_unfilled_fields;
   10268              : 
   10269              : /* For an ARRAY_TYPE, this is the index of the first element
   10270              :    not yet written out.  */
   10271              : static tree constructor_unfilled_index;
   10272              : 
   10273              : /* In a RECORD_TYPE, the byte index of the next consecutive field.
   10274              :    This is so we can generate gaps between fields, when appropriate.  */
   10275              : static tree constructor_bit_index;
   10276              : 
   10277              : /* If we are saving up the elements rather than allocating them,
   10278              :    this is the list of elements so far (in reverse order,
   10279              :    most recent first).  */
   10280              : static vec<constructor_elt, va_gc> *constructor_elements;
   10281              : 
   10282              : /* 1 if constructor should be incrementally stored into a constructor chain,
   10283              :    0 if all the elements should be kept in AVL tree.  */
   10284              : static int constructor_incremental;
   10285              : 
   10286              : /* 1 if so far this constructor's elements are all compile-time constants.  */
   10287              : static int constructor_constant;
   10288              : 
   10289              : /* 1 if so far this constructor's elements are all valid address constants.  */
   10290              : static int constructor_simple;
   10291              : 
   10292              : /* 1 if this constructor has an element that cannot be part of a
   10293              :    constant expression.  */
   10294              : static int constructor_nonconst;
   10295              : 
   10296              : /* 1 if this constructor is erroneous so far.  */
   10297              : static int constructor_erroneous;
   10298              : 
   10299              : /* 1 if this constructor is the universal zero initializer { 0 }.  */
   10300              : static int constructor_zeroinit;
   10301              : 
   10302              : /* 1 if this constructor should have padding bits zeroed (C23 {}.  */
   10303              : static bool constructor_zero_padding_bits;
   10304              : 
   10305              : /* 1 if this constructor is a braced scalar initializer (further nested levels
   10306              :    of braces are an error).  */
   10307              : static bool constructor_braced_scalar;
   10308              : 
   10309              : /* Structure for managing pending initializer elements, organized as an
   10310              :    AVL tree.  */
   10311              : 
   10312              : struct init_node
   10313              : {
   10314              :   struct init_node *left, *right;
   10315              :   struct init_node *parent;
   10316              :   int balance;
   10317              :   tree purpose;
   10318              :   tree value;
   10319              :   tree origtype;
   10320              : };
   10321              : 
   10322              : /* Tree of pending elements at this constructor level.
   10323              :    These are elements encountered out of order
   10324              :    which belong at places we haven't reached yet in actually
   10325              :    writing the output.
   10326              :    Will never hold tree nodes across GC runs.  */
   10327              : static struct init_node *constructor_pending_elts;
   10328              : 
   10329              : /* The SPELLING_DEPTH of this constructor.  */
   10330              : static int constructor_depth;
   10331              : 
   10332              : /* DECL node for which an initializer is being read.
   10333              :    0 means we are reading a constructor expression
   10334              :    such as (struct foo) {...}.  */
   10335              : static tree constructor_decl;
   10336              : 
   10337              : /* Nonzero if there were any member designators in this initializer.  */
   10338              : static int constructor_designated;
   10339              : 
   10340              : /* Nesting depth of designator list.  */
   10341              : static int designator_depth;
   10342              : 
   10343              : /* Nonzero if there were diagnosed errors in this designator list.  */
   10344              : static int designator_erroneous;
   10345              : 
   10346              : 
   10347              : /* This stack has a level for each implicit or explicit level of
   10348              :    structuring in the initializer, including the outermost one.  It
   10349              :    saves the values of most of the variables above.  */
   10350              : 
   10351              : struct constructor_range_stack;
   10352              : 
   10353              : struct constructor_stack
   10354              : {
   10355              :   struct constructor_stack *next;
   10356              :   tree type;
   10357              :   tree fields;
   10358              :   tree index;
   10359              :   tree max_index;
   10360              :   tree unfilled_index;
   10361              :   tree unfilled_fields;
   10362              :   tree bit_index;
   10363              :   vec<constructor_elt, va_gc> *elements;
   10364              :   struct init_node *pending_elts;
   10365              :   int offset;
   10366              :   int depth;
   10367              :   /* If value nonzero, this value should replace the entire
   10368              :      constructor at this level.  */
   10369              :   struct c_expr replacement_value;
   10370              :   struct constructor_range_stack *range_stack;
   10371              :   char constant;
   10372              :   char simple;
   10373              :   char nonconst;
   10374              :   char implicit;
   10375              :   char erroneous;
   10376              :   char outer;
   10377              :   char incremental;
   10378              :   char designated;
   10379              :   bool zero_padding_bits;
   10380              :   bool braced_scalar;
   10381              :   int designator_depth;
   10382              : };
   10383              : 
   10384              : static struct constructor_stack *constructor_stack;
   10385              : 
   10386              : /* This stack represents designators from some range designator up to
   10387              :    the last designator in the list.  */
   10388              : 
   10389              : struct constructor_range_stack
   10390              : {
   10391              :   struct constructor_range_stack *next, *prev;
   10392              :   struct constructor_stack *stack;
   10393              :   tree range_start;
   10394              :   tree index;
   10395              :   tree range_end;
   10396              :   tree fields;
   10397              : };
   10398              : 
   10399              : static struct constructor_range_stack *constructor_range_stack;
   10400              : 
   10401              : /* This stack records separate initializers that are nested.
   10402              :    Nested initializers can't happen in ANSI C, but GNU C allows them
   10403              :    in cases like { ... (struct foo) { ... } ... }.  */
   10404              : 
   10405              : struct initializer_stack
   10406              : {
   10407              :   struct initializer_stack *next;
   10408              :   tree decl;
   10409              :   struct constructor_stack *constructor_stack;
   10410              :   struct constructor_range_stack *constructor_range_stack;
   10411              :   vec<constructor_elt, va_gc> *elements;
   10412              :   struct spelling *spelling;
   10413              :   struct spelling *spelling_base;
   10414              :   int spelling_size;
   10415              :   char require_constant_value;
   10416              :   char require_constant_elements;
   10417              :   char require_constexpr_value;
   10418              :   char designated;
   10419              :   rich_location *missing_brace_richloc;
   10420              : };
   10421              : 
   10422              : static struct initializer_stack *initializer_stack;
   10423              : 
   10424              : /* Prepare to parse and output the initializer for variable DECL.  */
   10425              : 
   10426              : void
   10427      7272883 : start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED,
   10428              :             bool init_require_constant, bool init_require_constexpr,
   10429              :             rich_location *richloc)
   10430              : {
   10431      7272883 :   const char *locus;
   10432      7272883 :   struct initializer_stack *p = XNEW (struct initializer_stack);
   10433              : 
   10434      7272883 :   p->decl = constructor_decl;
   10435      7272883 :   p->require_constant_value = require_constant_value;
   10436      7272883 :   p->require_constant_elements = require_constant_elements;
   10437      7272883 :   p->require_constexpr_value = require_constexpr_value;
   10438      7272883 :   p->constructor_stack = constructor_stack;
   10439      7272883 :   p->constructor_range_stack = constructor_range_stack;
   10440      7272883 :   p->elements = constructor_elements;
   10441      7272883 :   p->spelling = spelling;
   10442      7272883 :   p->spelling_base = spelling_base;
   10443      7272883 :   p->spelling_size = spelling_size;
   10444      7272883 :   p->next = initializer_stack;
   10445      7272883 :   p->missing_brace_richloc = richloc;
   10446      7272883 :   p->designated = constructor_designated;
   10447      7272883 :   initializer_stack = p;
   10448              : 
   10449      7272883 :   constructor_decl = decl;
   10450      7272883 :   constructor_designated = 0;
   10451              : 
   10452      7272883 :   require_constant_value = init_require_constant;
   10453      7272883 :   require_constexpr_value = init_require_constexpr;
   10454      7272883 :   if (decl != NULL_TREE && decl != error_mark_node)
   10455              :     {
   10456      6350988 :       require_constant_elements
   10457      6173457 :         = ((init_require_constant || (pedantic && !flag_isoc99))
   10458              :            /* For a scalar, you can always use any value to initialize,
   10459              :               even within braces.  */
   10460      6362949 :            && AGGREGATE_TYPE_P (TREE_TYPE (decl)));
   10461      6350988 :       locus = identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (decl)));
   10462              :     }
   10463              :   else
   10464              :     {
   10465       921895 :       require_constant_elements = false;
   10466       921895 :       locus = _("(anonymous)");
   10467              :     }
   10468              : 
   10469      7272883 :   constructor_stack = 0;
   10470      7272883 :   constructor_range_stack = 0;
   10471              : 
   10472      7272883 :   found_missing_braces = 0;
   10473              : 
   10474      7272883 :   spelling_base = 0;
   10475      7272883 :   spelling_size = 0;
   10476      7272883 :   RESTORE_SPELLING_DEPTH (0);
   10477              : 
   10478      7272883 :   if (locus)
   10479      7272883 :     push_string (locus);
   10480      7272883 : }
   10481              : 
   10482              : void
   10483      7272881 : finish_init (void)
   10484              : {
   10485      7272881 :   struct initializer_stack *p = initializer_stack;
   10486              : 
   10487              :   /* Free the whole constructor stack of this initializer.  */
   10488      7272881 :   while (constructor_stack)
   10489              :     {
   10490            0 :       struct constructor_stack *q = constructor_stack;
   10491            0 :       constructor_stack = q->next;
   10492            0 :       XDELETE (q);
   10493              :     }
   10494              : 
   10495      7272881 :   gcc_assert (!constructor_range_stack);
   10496              : 
   10497              :   /* Pop back to the data of the outer initializer (if any).  */
   10498      7272881 :   XDELETE (spelling_base);
   10499              : 
   10500      7272881 :   constructor_decl = p->decl;
   10501      7272881 :   require_constant_value = p->require_constant_value;
   10502      7272881 :   require_constant_elements = p->require_constant_elements;
   10503      7272881 :   require_constexpr_value = p->require_constexpr_value;
   10504      7272881 :   constructor_stack = p->constructor_stack;
   10505      7272881 :   constructor_designated = p->designated;
   10506      7272881 :   constructor_range_stack = p->constructor_range_stack;
   10507      7272881 :   constructor_elements = p->elements;
   10508      7272881 :   spelling = p->spelling;
   10509      7272881 :   spelling_base = p->spelling_base;
   10510      7272881 :   spelling_size = p->spelling_size;
   10511      7272881 :   initializer_stack = p->next;
   10512      7272881 :   XDELETE (p);
   10513      7272881 : }
   10514              : 
   10515              : /* Call here when we see the initializer is surrounded by braces.
   10516              :    This is instead of a call to push_init_level;
   10517              :    it is matched by a call to pop_init_level.
   10518              : 
   10519              :    TYPE is the type to initialize, for a constructor expression.
   10520              :    For an initializer for a decl, TYPE is zero.  */
   10521              : 
   10522              : void
   10523      1026313 : really_start_incremental_init (tree type)
   10524              : {
   10525      1026313 :   struct constructor_stack *p = XNEW (struct constructor_stack);
   10526              : 
   10527      1026313 :   if (type == NULL_TREE)
   10528       106384 :     type = TREE_TYPE (constructor_decl);
   10529              : 
   10530      1026313 :   if (VECTOR_TYPE_P (type)
   10531      1026313 :       && TYPE_VECTOR_OPAQUE (type))
   10532            0 :     error ("opaque vector types cannot be initialized");
   10533              : 
   10534      1026313 :   p->type = constructor_type;
   10535      1026313 :   p->fields = constructor_fields;
   10536      1026313 :   p->index = constructor_index;
   10537      1026313 :   p->max_index = constructor_max_index;
   10538      1026313 :   p->unfilled_index = constructor_unfilled_index;
   10539      1026313 :   p->unfilled_fields = constructor_unfilled_fields;
   10540      1026313 :   p->bit_index = constructor_bit_index;
   10541      1026313 :   p->elements = constructor_elements;
   10542      1026313 :   p->constant = constructor_constant;
   10543      1026313 :   p->simple = constructor_simple;
   10544      1026313 :   p->nonconst = constructor_nonconst;
   10545      1026313 :   p->erroneous = constructor_erroneous;
   10546      1026313 :   p->pending_elts = constructor_pending_elts;
   10547      1026313 :   p->depth = constructor_depth;
   10548      1026313 :   p->replacement_value.value = 0;
   10549      1026313 :   p->replacement_value.original_code = ERROR_MARK;
   10550      1026313 :   p->replacement_value.original_type = NULL;
   10551      1026313 :   p->implicit = 0;
   10552      1026313 :   p->range_stack = 0;
   10553      1026313 :   p->outer = 0;
   10554      1026313 :   p->incremental = constructor_incremental;
   10555      1026313 :   p->designated = constructor_designated;
   10556      1026313 :   p->zero_padding_bits = constructor_zero_padding_bits;
   10557      1026313 :   p->braced_scalar = constructor_braced_scalar;
   10558      1026313 :   p->designator_depth = designator_depth;
   10559      1026313 :   p->next = 0;
   10560      1026313 :   constructor_stack = p;
   10561              : 
   10562      1026313 :   constructor_constant = 1;
   10563      1026313 :   constructor_simple = 1;
   10564      1026313 :   constructor_nonconst = 0;
   10565      1026313 :   constructor_depth = SPELLING_DEPTH ();
   10566      1026313 :   constructor_elements = NULL;
   10567      1026313 :   constructor_pending_elts = 0;
   10568      1026313 :   constructor_type = type;
   10569      1026313 :   constructor_incremental = 1;
   10570      1026313 :   constructor_designated = 0;
   10571      1026313 :   constructor_zero_padding_bits = false;
   10572      1026313 :   constructor_zeroinit = 1;
   10573      1026313 :   constructor_braced_scalar = false;
   10574      1026313 :   designator_depth = 0;
   10575      1026313 :   designator_erroneous = 0;
   10576              : 
   10577      1026313 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10578              :     {
   10579        82159 :       constructor_fields = TYPE_FIELDS (constructor_type);
   10580              :       /* Skip any nameless bit fields at the beginning.  */
   10581        82159 :       while (constructor_fields != NULL_TREE
   10582        82187 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   10583           28 :         constructor_fields = DECL_CHAIN (constructor_fields);
   10584              : 
   10585        82159 :       constructor_unfilled_fields = constructor_fields;
   10586        82159 :       constructor_bit_index = bitsize_zero_node;
   10587              :     }
   10588       944154 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10589              :     {
   10590        18067 :       if (TYPE_DOMAIN (constructor_type))
   10591              :         {
   10592         9585 :           constructor_max_index
   10593         9585 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
   10594              : 
   10595              :           /* Detect non-empty initializations of zero-length arrays.  */
   10596         9585 :           if (constructor_max_index == NULL_TREE
   10597         9585 :               && TYPE_SIZE (constructor_type))
   10598          205 :             constructor_max_index = integer_minus_one_node;
   10599              : 
   10600              :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
   10601              :              to initialize VLAs with a nonempty initializer will cause a
   10602              :              proper error; avoid tree checking errors as well by setting a
   10603              :              safe value.  */
   10604         9585 :           if (constructor_max_index
   10605         9585 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
   10606           73 :             constructor_max_index = integer_minus_one_node;
   10607              : 
   10608         9585 :           constructor_index
   10609         9585 :             = convert (bitsizetype,
   10610         9585 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10611              :         }
   10612              :       else
   10613              :         {
   10614         8482 :           constructor_index = bitsize_zero_node;
   10615         8482 :           constructor_max_index = NULL_TREE;
   10616              :         }
   10617              : 
   10618        18067 :       constructor_unfilled_index = constructor_index;
   10619              :     }
   10620       926087 :   else if (gnu_vector_type_p (constructor_type))
   10621              :     {
   10622              :       /* Vectors are like simple fixed-size arrays.  */
   10623      1851062 :       constructor_max_index =
   10624       925531 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
   10625       925531 :       constructor_index = bitsize_zero_node;
   10626       925531 :       constructor_unfilled_index = constructor_index;
   10627              :     }
   10628              :   else
   10629              :     {
   10630              :       /* Handle the case of int x = {5}; */
   10631          556 :       constructor_fields = constructor_type;
   10632          556 :       constructor_unfilled_fields = constructor_type;
   10633          556 :       constructor_braced_scalar = true;
   10634              :     }
   10635      1026313 : }
   10636              : 
   10637              : extern location_t last_init_list_comma;
   10638              : 
   10639              : /* Called when we see an open brace for a nested initializer.  Finish
   10640              :    off any pending levels with implicit braces.  */
   10641              : void
   10642       342410 : finish_implicit_inits (location_t loc, struct obstack *braced_init_obstack)
   10643              : {
   10644       342412 :   while (constructor_stack->implicit)
   10645              :     {
   10646         1154 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
   10647          208 :           && constructor_fields == NULL_TREE)
   10648            0 :         process_init_element (input_location,
   10649              :                               pop_init_level (loc, 1, braced_init_obstack,
   10650              :                                               last_init_list_comma),
   10651              :                               true, braced_init_obstack);
   10652         1154 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE
   10653          946 :                && constructor_max_index
   10654         2100 :                && tree_int_cst_lt (constructor_max_index,
   10655              :                                    constructor_index))
   10656            2 :         process_init_element (input_location,
   10657              :                               pop_init_level (loc, 1, braced_init_obstack,
   10658              :                                               last_init_list_comma),
   10659              :                               true, braced_init_obstack);
   10660              :       else
   10661              :         break;
   10662              :     }
   10663       342410 : }
   10664              : 
   10665              : /* Push down into a subobject, for initialization.
   10666              :    If this is for an explicit set of braces, IMPLICIT is 0.
   10667              :    If it is because the next element belongs at a lower level,
   10668              :    IMPLICIT is 1 (or 2 if the push is because of designator list).  */
   10669              : 
   10670              : void
   10671      1045090 : push_init_level (location_t loc, int implicit,
   10672              :                  struct obstack *braced_init_obstack)
   10673              : {
   10674      1045090 :   struct constructor_stack *p;
   10675      1045090 :   tree value = NULL_TREE;
   10676              : 
   10677              :   /* Unless this is an explicit brace, we need to preserve previous
   10678              :      content if any.  */
   10679      1045090 :   if (implicit)
   10680              :     {
   10681       705323 :       if (RECORD_OR_UNION_TYPE_P (constructor_type) && constructor_fields)
   10682         1819 :         value = find_init_member (constructor_fields, braced_init_obstack);
   10683       703504 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10684       703504 :         value = find_init_member (constructor_index, braced_init_obstack);
   10685              :     }
   10686              : 
   10687      1045090 :   p = XNEW (struct constructor_stack);
   10688      1045090 :   p->type = constructor_type;
   10689      1045090 :   p->fields = constructor_fields;
   10690      1045090 :   p->index = constructor_index;
   10691      1045090 :   p->max_index = constructor_max_index;
   10692      1045090 :   p->unfilled_index = constructor_unfilled_index;
   10693      1045090 :   p->unfilled_fields = constructor_unfilled_fields;
   10694      1045090 :   p->bit_index = constructor_bit_index;
   10695      1045090 :   p->elements = constructor_elements;
   10696      1045090 :   p->constant = constructor_constant;
   10697      1045090 :   p->simple = constructor_simple;
   10698      1045090 :   p->nonconst = constructor_nonconst;
   10699      1045090 :   p->erroneous = constructor_erroneous;
   10700      1045090 :   p->pending_elts = constructor_pending_elts;
   10701      1045090 :   p->depth = constructor_depth;
   10702      1045090 :   p->replacement_value.value = NULL_TREE;
   10703      1045090 :   p->replacement_value.original_code = ERROR_MARK;
   10704      1045090 :   p->replacement_value.original_type = NULL;
   10705      1045090 :   p->implicit = implicit;
   10706      1045090 :   p->outer = 0;
   10707      1045090 :   p->incremental = constructor_incremental;
   10708      1045090 :   p->designated = constructor_designated;
   10709      1045090 :   p->zero_padding_bits = constructor_zero_padding_bits;
   10710      1045090 :   p->braced_scalar = constructor_braced_scalar;
   10711      1045090 :   p->designator_depth = designator_depth;
   10712      1045090 :   p->next = constructor_stack;
   10713      1045090 :   p->range_stack = 0;
   10714      1045090 :   constructor_stack = p;
   10715              : 
   10716      1045090 :   constructor_constant = 1;
   10717      1045090 :   constructor_simple = 1;
   10718      1045090 :   constructor_nonconst = 0;
   10719      1045090 :   constructor_depth = SPELLING_DEPTH ();
   10720      1045090 :   constructor_elements = NULL;
   10721      1045090 :   constructor_incremental = 1;
   10722              :   /* If the upper initializer is designated, then mark this as
   10723              :      designated too to prevent bogus warnings.  */
   10724      1045090 :   constructor_designated = p->designated;
   10725              :   /* If the upper initializer has padding bits zeroed, that includes
   10726              :      all nested initializers as well.  */
   10727      1045090 :   constructor_zero_padding_bits = p->zero_padding_bits;
   10728      1045090 :   constructor_braced_scalar = false;
   10729      1045090 :   constructor_pending_elts = 0;
   10730      1045090 :   if (!implicit)
   10731              :     {
   10732       339767 :       p->range_stack = constructor_range_stack;
   10733       339767 :       constructor_range_stack = 0;
   10734       339767 :       designator_depth = 0;
   10735       339767 :       designator_erroneous = 0;
   10736              :     }
   10737              : 
   10738              :   /* Don't die if an entire brace-pair level is superfluous
   10739              :      in the containing level.  */
   10740      1045090 :   if (constructor_type == NULL_TREE)
   10741              :     ;
   10742      1045090 :   else if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10743              :     {
   10744              :       /* Don't die if there are extra init elts at the end.  */
   10745       160057 :       if (constructor_fields == NULL_TREE)
   10746           51 :         constructor_type = NULL_TREE;
   10747              :       else
   10748              :         {
   10749       160006 :           constructor_type = TREE_TYPE (constructor_fields);
   10750       160006 :           push_member_name (constructor_fields);
   10751       160006 :           constructor_depth++;
   10752              :         }
   10753              :     }
   10754       885033 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10755              :     {
   10756       884982 :       constructor_type = TREE_TYPE (constructor_type);
   10757       884982 :       push_array_bounds (tree_to_uhwi (constructor_index));
   10758       884982 :       constructor_depth++;
   10759              :     }
   10760              : 
   10761      1045090 :   if (constructor_type == NULL_TREE)
   10762              :     {
   10763           51 :       error_init (loc, "extra brace group at end of initializer");
   10764           51 :       constructor_fields = NULL_TREE;
   10765           51 :       constructor_unfilled_fields = NULL_TREE;
   10766           51 :       return;
   10767              :     }
   10768              : 
   10769      1045039 :   if (value && TREE_CODE (value) == CONSTRUCTOR)
   10770              :     {
   10771         1686 :       constructor_constant = TREE_CONSTANT (value);
   10772         1686 :       constructor_simple = TREE_STATIC (value);
   10773         1686 :       constructor_nonconst = CONSTRUCTOR_NON_CONST (value);
   10774         1686 :       constructor_elements = CONSTRUCTOR_ELTS (value);
   10775         1686 :       constructor_zero_padding_bits |= CONSTRUCTOR_ZERO_PADDING_BITS (value);
   10776         1686 :       if (!vec_safe_is_empty (constructor_elements)
   10777         1462 :           && (TREE_CODE (constructor_type) == RECORD_TYPE
   10778         1462 :               || TREE_CODE (constructor_type) == ARRAY_TYPE))
   10779         1416 :         set_nonincremental_init (braced_init_obstack);
   10780              :     }
   10781              : 
   10782      1045039 :   if (implicit == 1)
   10783              :     {
   10784       702680 :       found_missing_braces = 1;
   10785       702680 :       if (initializer_stack->missing_brace_richloc)
   10786       702680 :         initializer_stack->missing_brace_richloc->add_fixit_insert_before
   10787       702680 :           (loc, "{");
   10788              :     }
   10789              : 
   10790      1045039 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   10791              :     {
   10792       880831 :       constructor_fields = TYPE_FIELDS (constructor_type);
   10793              :       /* Skip any nameless bit fields at the beginning.  */
   10794       880831 :       while (constructor_fields != NULL_TREE
   10795       880895 :              && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   10796           64 :         constructor_fields = DECL_CHAIN (constructor_fields);
   10797              : 
   10798       880831 :       constructor_unfilled_fields = constructor_fields;
   10799       880831 :       constructor_bit_index = bitsize_zero_node;
   10800              :     }
   10801       164208 :   else if (gnu_vector_type_p (constructor_type))
   10802              :     {
   10803              :       /* Vectors are like simple fixed-size arrays.  */
   10804         9602 :       constructor_max_index =
   10805         4801 :         bitsize_int (TYPE_VECTOR_SUBPARTS (constructor_type) - 1);
   10806         4801 :       constructor_index = bitsize_int (0);
   10807         4801 :       constructor_unfilled_index = constructor_index;
   10808              :     }
   10809       159407 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   10810              :     {
   10811       159327 :       if (TYPE_DOMAIN (constructor_type))
   10812              :         {
   10813       159327 :           constructor_max_index
   10814       159327 :             = TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type));
   10815              : 
   10816              :           /* Detect non-empty initializations of zero-length arrays.  */
   10817       159327 :           if (constructor_max_index == NULL_TREE
   10818       159327 :               && TYPE_SIZE (constructor_type))
   10819          135 :             constructor_max_index = integer_minus_one_node;
   10820              : 
   10821              :           /* constructor_max_index needs to be an INTEGER_CST.  Attempts
   10822              :              to initialize VLAs will cause a proper error; avoid tree
   10823              :              checking errors as well by setting a safe value.  */
   10824       159327 :           if (constructor_max_index
   10825       159057 :               && TREE_CODE (constructor_max_index) != INTEGER_CST)
   10826            2 :             constructor_max_index = integer_minus_one_node;
   10827              : 
   10828       159327 :           constructor_index
   10829       159327 :             = convert (bitsizetype,
   10830       159327 :                        TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   10831              :         }
   10832              :       else
   10833            0 :         constructor_index = bitsize_zero_node;
   10834              : 
   10835       159327 :       constructor_unfilled_index = constructor_index;
   10836       159327 :       if (value && TREE_CODE (value) == STRING_CST)
   10837              :         {
   10838              :           /* We need to split the char/wchar array into individual
   10839              :              characters, so that we don't have to special case it
   10840              :              everywhere.  */
   10841            7 :           set_nonincremental_init_from_string (value, braced_init_obstack);
   10842              :         }
   10843              :     }
   10844              :   else
   10845              :     {
   10846           80 :       if (constructor_type != error_mark_node)
   10847              :         {
   10848           51 :           if (p->braced_scalar)
   10849           22 :             permerror_init (input_location, 0,
   10850              :                             "braces around scalar initializer");
   10851              :           else
   10852           29 :             warning_init (input_location, 0,
   10853              :                           "braces around scalar initializer");
   10854           51 :           constructor_braced_scalar = true;
   10855              :         }
   10856           80 :       constructor_fields = constructor_type;
   10857           80 :       constructor_unfilled_fields = constructor_type;
   10858              :     }
   10859              : }
   10860              : 
   10861              : /* At the end of an implicit or explicit brace level,
   10862              :    finish up that level of constructor.  If a single expression
   10863              :    with redundant braces initialized that level, return the
   10864              :    c_expr structure for that expression.  Otherwise, the original_code
   10865              :    element is set to ERROR_MARK.
   10866              :    If we were outputting the elements as they are read, return 0 as the value
   10867              :    from inner levels (process_init_element ignores that),
   10868              :    but return error_mark_node as the value from the outermost level
   10869              :    (that's what we want to put in DECL_INITIAL).
   10870              :    Otherwise, return a CONSTRUCTOR expression as the value.  */
   10871              : 
   10872              : struct c_expr
   10873      2071403 : pop_init_level (location_t loc, int implicit,
   10874              :                 struct obstack *braced_init_obstack,
   10875              :                 location_t insert_before)
   10876              : {
   10877      2071403 :   struct constructor_stack *p;
   10878      2071403 :   struct c_expr ret;
   10879      2071403 :   ret.value = NULL_TREE;
   10880      2071403 :   ret.original_code = ERROR_MARK;
   10881      2071403 :   ret.original_type = NULL;
   10882      2071403 :   ret.m_decimal = 0;
   10883              : 
   10884      2071403 :   if (implicit == 0)
   10885              :     {
   10886              :       /* When we come to an explicit close brace,
   10887              :          pop any inner levels that didn't have explicit braces.  */
   10888      1367422 :       while (constructor_stack->implicit)
   10889         1342 :         process_init_element (input_location,
   10890              :                               pop_init_level (loc, 1, braced_init_obstack,
   10891              :                                               insert_before),
   10892              :                               true, braced_init_obstack);
   10893      1366080 :       gcc_assert (!constructor_range_stack);
   10894              :     }
   10895              :   else
   10896       705323 :     if (initializer_stack->missing_brace_richloc)
   10897       705323 :       initializer_stack->missing_brace_richloc->add_fixit_insert_before
   10898       705323 :         (insert_before, "}");
   10899              : 
   10900              :   /* Now output all pending elements.  */
   10901      2071403 :   constructor_incremental = 1;
   10902      2071403 :   output_pending_init_elements (1, braced_init_obstack);
   10903              : 
   10904      2071403 :   p = constructor_stack;
   10905              : 
   10906              :   /* Error for initializing a flexible array member, or a zero-length
   10907              :      array member in an inappropriate context.  */
   10908      2071352 :   if (constructor_type && constructor_fields
   10909       161021 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   10910       153373 :       && TYPE_DOMAIN (constructor_type)
   10911      2224768 :       && !TYPE_MAX_VALUE (TYPE_DOMAIN (constructor_type)))
   10912              :     {
   10913              :       /* Silently discard empty initializations.  The parser will
   10914              :          already have pedwarned for empty brackets for C17 and earlier.  */
   10915          300 :       if (integer_zerop (constructor_unfilled_index))
   10916           84 :         constructor_type = NULL_TREE;
   10917          300 :       if (constructor_type || flag_isoc23)
   10918              :         {
   10919          296 :           gcc_assert (!constructor_type || !TYPE_SIZE (constructor_type));
   10920              : 
   10921          296 :           if (constructor_depth <= 2)
   10922          249 :             pedwarn_init (loc, OPT_Wpedantic,
   10923              :                           "initialization of a flexible array member");
   10924           47 :           else if (constructor_type)
   10925           33 :             error_init (loc, "initialization of flexible array member "
   10926              :                              "in a nested context");
   10927              :           else
   10928           14 :             pedwarn_init (loc, OPT_Wpedantic,
   10929              :                           "initialization of flexible array member "
   10930              :                           "in a nested context");
   10931              : 
   10932              :           /* We have already issued an error message for the existence
   10933              :              of a flexible array member not at the end of the structure.
   10934              :              Discard the initializer so that we do not die later.  */
   10935          296 :           if (constructor_type
   10936          216 :               && DECL_CHAIN (constructor_fields) != NULL_TREE
   10937          302 :               && (!p->type || TREE_CODE (p->type) != UNION_TYPE))
   10938            0 :             constructor_type = NULL_TREE;
   10939              :         }
   10940              :     }
   10941              : 
   10942      2071403 :   switch (vec_safe_length (constructor_elements))
   10943              :     {
   10944         5136 :     case 0:
   10945              :       /* Initialization with { } counts as zeroinit.  */
   10946         5136 :       constructor_zeroinit = 1;
   10947         5136 :       break;
   10948       916288 :     case 1:
   10949              :       /* This might be zeroinit as well.  */
   10950       916288 :       if (integer_zerop ((*constructor_elements)[0].value))
   10951         2084 :         constructor_zeroinit = 1;
   10952              :       break;
   10953      1149979 :     default:
   10954              :       /* If the constructor has more than one element, it can't be { 0 }.  */
   10955      1149979 :       constructor_zeroinit = 0;
   10956      1149979 :       break;
   10957              :     }
   10958              : 
   10959              :   /* Warn when some structs are initialized with direct aggregation.  */
   10960      2071403 :   if (!implicit && found_missing_braces && warn_missing_braces
   10961           37 :       && !constructor_zeroinit)
   10962              :     {
   10963           18 :       gcc_assert (initializer_stack->missing_brace_richloc);
   10964           18 :       warning_at (initializer_stack->missing_brace_richloc,
   10965           18 :                   OPT_Wmissing_braces,
   10966              :                   "missing braces around initializer");
   10967              :     }
   10968              : 
   10969              :   /* Warn when some struct elements are implicitly initialized to zero.  */
   10970      2071403 :   if (warn_missing_field_initializers
   10971       425471 :       && constructor_type
   10972       425443 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   10973       193403 :       && constructor_unfilled_fields)
   10974              :     {
   10975              :         /* Do not warn for flexible array members or zero-length arrays.  */
   10976           43 :         while (constructor_unfilled_fields
   10977           43 :                && (!DECL_SIZE (constructor_unfilled_fields)
   10978           43 :                    || integer_zerop (DECL_SIZE (constructor_unfilled_fields))))
   10979            0 :           constructor_unfilled_fields = DECL_CHAIN (constructor_unfilled_fields);
   10980              : 
   10981           43 :         if (constructor_unfilled_fields
   10982              :             /* Do not warn if this level of the initializer uses member
   10983              :                designators; it is likely to be deliberate.  */
   10984           43 :             && !constructor_designated
   10985              :             /* Do not warn about initializing with { 0 } or with { }.  */
   10986           24 :             && !constructor_zeroinit)
   10987              :           {
   10988           10 :             if (warning_at (input_location, OPT_Wmissing_field_initializers,
   10989              :                             "missing initializer for field %qD of %qT",
   10990              :                             constructor_unfilled_fields,
   10991              :                             constructor_type))
   10992           10 :               inform (DECL_SOURCE_LOCATION (constructor_unfilled_fields),
   10993              :                       "%qD declared here", constructor_unfilled_fields);
   10994              :           }
   10995              :     }
   10996              : 
   10997              :   /* Pad out the end of the structure.  */
   10998      2071403 :   if (p->replacement_value.value)
   10999              :     /* If this closes a superfluous brace pair,
   11000              :        just pass out the element between them.  */
   11001          138 :     ret = p->replacement_value;
   11002      2071265 :   else if (constructor_type == NULL_TREE)
   11003              :     ;
   11004      2071138 :   else if (!RECORD_OR_UNION_TYPE_P (constructor_type)
   11005      2071138 :            && TREE_CODE (constructor_type) != ARRAY_TYPE
   11006      2071138 :            && !gnu_vector_type_p (constructor_type))
   11007              :     {
   11008              :       /* A nonincremental scalar initializer--just return
   11009              :          the element, after verifying there is just one.
   11010              :          Empty scalar initializers are supported in C23.  */
   11011          636 :       if (vec_safe_is_empty (constructor_elements))
   11012              :         {
   11013          201 :           if (constructor_erroneous || constructor_type == error_mark_node)
   11014           85 :             ret.value = error_mark_node;
   11015          116 :           else if (TREE_CODE (constructor_type) == FUNCTION_TYPE)
   11016              :             {
   11017            2 :               error_init (loc, "invalid initializer");
   11018            2 :               ret.value = error_mark_node;
   11019              :             }
   11020          114 :           else if (TREE_CODE (constructor_type) == POINTER_TYPE)
   11021              :             /* Ensure this is a null pointer constant in the case of a
   11022              :                'constexpr' object initialized with {}.  */
   11023           33 :             ret.value = build_zero_cst (ptr_type_node);
   11024              :           else
   11025           81 :             ret.value = build_zero_cst (constructor_type);
   11026              :         }
   11027          435 :       else if (vec_safe_length (constructor_elements) != 1)
   11028              :         {
   11029            0 :           error_init (loc, "extra elements in scalar initializer");
   11030            0 :           ret.value = (*constructor_elements)[0].value;
   11031              :         }
   11032              :       else
   11033          435 :         ret.value = (*constructor_elements)[0].value;
   11034              :     }
   11035              :   else
   11036              :     {
   11037      2070502 :       if (constructor_erroneous)
   11038          357 :         ret.value = error_mark_node;
   11039              :       else
   11040              :         {
   11041      2070145 :           ret.value = build_constructor (constructor_type,
   11042              :                                          constructor_elements);
   11043      2070145 :           if (constructor_constant)
   11044      1740069 :             TREE_CONSTANT (ret.value) = 1;
   11045      2070145 :           if (constructor_constant && constructor_simple)
   11046      1740030 :             TREE_STATIC (ret.value) = 1;
   11047      2070145 :           if (constructor_nonconst)
   11048          672 :             CONSTRUCTOR_NON_CONST (ret.value) = 1;
   11049      2070145 :           if (constructor_zero_padding_bits)
   11050          687 :             CONSTRUCTOR_ZERO_PADDING_BITS (ret.value) = 1;
   11051              :         }
   11052              :     }
   11053              : 
   11054      2071403 :   if (ret.value && TREE_CODE (ret.value) != CONSTRUCTOR)
   11055              :     {
   11056         1131 :       if (constructor_nonconst)
   11057           15 :         ret.original_code = C_MAYBE_CONST_EXPR;
   11058         1116 :       else if (ret.original_code == C_MAYBE_CONST_EXPR)
   11059            0 :         ret.original_code = ERROR_MARK;
   11060              :     }
   11061              : 
   11062      2071403 :   constructor_type = p->type;
   11063      2071403 :   constructor_fields = p->fields;
   11064      2071403 :   constructor_index = p->index;
   11065      2071403 :   constructor_max_index = p->max_index;
   11066      2071403 :   constructor_unfilled_index = p->unfilled_index;
   11067      2071403 :   constructor_unfilled_fields = p->unfilled_fields;
   11068      2071403 :   constructor_bit_index = p->bit_index;
   11069      2071403 :   constructor_elements = p->elements;
   11070      2071403 :   constructor_constant = p->constant;
   11071      2071403 :   constructor_simple = p->simple;
   11072      2071403 :   constructor_nonconst = p->nonconst;
   11073      2071403 :   constructor_erroneous = p->erroneous;
   11074      2071403 :   constructor_incremental = p->incremental;
   11075      2071403 :   constructor_designated = p->designated;
   11076      2071403 :   constructor_zero_padding_bits = p->zero_padding_bits;
   11077      2071403 :   constructor_braced_scalar = p->braced_scalar;
   11078      2071403 :   designator_depth = p->designator_depth;
   11079      2071403 :   constructor_pending_elts = p->pending_elts;
   11080      2071403 :   constructor_depth = p->depth;
   11081      2071403 :   if (!p->implicit)
   11082      1366080 :     constructor_range_stack = p->range_stack;
   11083      2071403 :   RESTORE_SPELLING_DEPTH (constructor_depth);
   11084              : 
   11085      2071403 :   constructor_stack = p->next;
   11086      2071403 :   XDELETE (p);
   11087              : 
   11088      2071403 :   if (ret.value == NULL_TREE && constructor_stack == 0)
   11089            0 :     ret.value = error_mark_node;
   11090      2071403 :   return ret;
   11091              : }
   11092              : 
   11093              : /* Common handling for both array range and field name designators.
   11094              :    ARRAY argument is nonzero for array ranges.  Returns false for success.  */
   11095              : 
   11096              : static bool
   11097        36947 : set_designator (location_t loc, bool array,
   11098              :                 struct obstack *braced_init_obstack)
   11099              : {
   11100        36947 :   tree subtype;
   11101        36947 :   enum tree_code subcode;
   11102              : 
   11103              :   /* Don't die if an entire brace-pair level is superfluous
   11104              :      in the containing level, or for an erroneous type.  */
   11105        36947 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   11106              :     return true;
   11107              : 
   11108              :   /* If there were errors in this designator list already, bail out
   11109              :      silently.  */
   11110        36938 :   if (designator_erroneous)
   11111              :     return true;
   11112              : 
   11113              :   /* Likewise for an initializer for a variable-size type.  Those are
   11114              :      diagnosed in the parser, except for empty initializer braces.  */
   11115        36938 :   if (COMPLETE_TYPE_P (constructor_type)
   11116        36938 :       && TREE_CODE (TYPE_SIZE (constructor_type)) != INTEGER_CST)
   11117              :     return true;
   11118              : 
   11119        36928 :   if (!designator_depth)
   11120              :     {
   11121        34609 :       gcc_assert (!constructor_range_stack);
   11122              : 
   11123              :       /* Designator list starts at the level of closest explicit
   11124              :          braces.  */
   11125        36284 :       while (constructor_stack->implicit)
   11126         1675 :         process_init_element (input_location,
   11127              :                               pop_init_level (loc, 1, braced_init_obstack,
   11128              :                                               last_init_list_comma),
   11129              :                               true, braced_init_obstack);
   11130        34609 :       constructor_designated = 1;
   11131        34609 :       return false;
   11132              :     }
   11133              : 
   11134         2319 :   switch (TREE_CODE (constructor_type))
   11135              :     {
   11136         1442 :     case  RECORD_TYPE:
   11137         1442 :     case  UNION_TYPE:
   11138         1442 :       subtype = TREE_TYPE (constructor_fields);
   11139         1442 :       if (subtype != error_mark_node)
   11140         1442 :         subtype = TYPE_MAIN_VARIANT (subtype);
   11141              :       break;
   11142          877 :     case ARRAY_TYPE:
   11143          877 :       subtype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   11144          877 :       break;
   11145            0 :     default:
   11146            0 :       gcc_unreachable ();
   11147              :     }
   11148              : 
   11149         2319 :   subcode = TREE_CODE (subtype);
   11150         2319 :   if (array && subcode != ARRAY_TYPE)
   11151              :     {
   11152            1 :       error_init (loc, "array index in non-array initializer");
   11153            1 :       return true;
   11154              :     }
   11155         2318 :   else if (!array && subcode != RECORD_TYPE && subcode != UNION_TYPE)
   11156              :     {
   11157            0 :       error_init (loc, "field name not in record or union initializer");
   11158            0 :       return true;
   11159              :     }
   11160              : 
   11161         2318 :   constructor_designated = 1;
   11162         2318 :   finish_implicit_inits (loc, braced_init_obstack);
   11163         2318 :   push_init_level (loc, 2, braced_init_obstack);
   11164         2318 :   return false;
   11165              : }
   11166              : 
   11167              : /* If there are range designators in designator list, push a new designator
   11168              :    to constructor_range_stack.  RANGE_END is end of such stack range or
   11169              :    NULL_TREE if there is no range designator at this level.  */
   11170              : 
   11171              : static void
   11172          390 : push_range_stack (tree range_end, struct obstack * braced_init_obstack)
   11173              : {
   11174          390 :   struct constructor_range_stack *p;
   11175              : 
   11176          780 :   p = (struct constructor_range_stack *)
   11177          390 :     obstack_alloc (braced_init_obstack,
   11178              :                    sizeof (struct constructor_range_stack));
   11179          390 :   p->prev = constructor_range_stack;
   11180          390 :   p->next = 0;
   11181          390 :   p->fields = constructor_fields;
   11182          390 :   p->range_start = constructor_index;
   11183          390 :   p->index = constructor_index;
   11184          390 :   p->stack = constructor_stack;
   11185          390 :   p->range_end = range_end;
   11186          390 :   if (constructor_range_stack)
   11187           19 :     constructor_range_stack->next = p;
   11188          390 :   constructor_range_stack = p;
   11189          390 : }
   11190              : 
   11191              : /* Within an array initializer, specify the next index to be initialized.
   11192              :    FIRST is that index.  If LAST is nonzero, then initialize a range
   11193              :    of indices, running from FIRST through LAST.  */
   11194              : 
   11195              : void
   11196         1931 : set_init_index (location_t loc, tree first, tree last,
   11197              :                 struct obstack *braced_init_obstack)
   11198              : {
   11199         1931 :   if (set_designator (loc, true, braced_init_obstack))
   11200              :     return;
   11201              : 
   11202         1928 :   designator_erroneous = 1;
   11203              : 
   11204         3856 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (first))
   11205         3845 :       || (last && !INTEGRAL_TYPE_P (TREE_TYPE (last))))
   11206              :     {
   11207           12 :       error_init (loc, "array index in initializer not of integer type");
   11208           12 :       return;
   11209              :     }
   11210              : 
   11211         1916 :   if (TREE_CODE (first) != INTEGER_CST)
   11212              :     {
   11213            6 :       first = c_fully_fold (first, false, NULL);
   11214            6 :       if (TREE_CODE (first) == INTEGER_CST)
   11215            5 :         pedwarn_init (loc, OPT_Wpedantic,
   11216              :                       "array index in initializer is not "
   11217              :                       "an integer constant expression");
   11218              :     }
   11219              : 
   11220         1916 :   if (last && TREE_CODE (last) != INTEGER_CST)
   11221              :     {
   11222            2 :       last = c_fully_fold (last, false, NULL);
   11223            2 :       if (TREE_CODE (last) == INTEGER_CST)
   11224            1 :         pedwarn_init (loc, OPT_Wpedantic,
   11225              :                       "array index in initializer is not "
   11226              :                       "an integer constant expression");
   11227              :     }
   11228              : 
   11229         1916 :   if (TREE_CODE (first) != INTEGER_CST)
   11230            1 :     error_init (loc, "nonconstant array index in initializer");
   11231         1915 :   else if (last != NULL_TREE && TREE_CODE (last) != INTEGER_CST)
   11232            1 :     error_init (loc, "nonconstant array index in initializer");
   11233         1914 :   else if (TREE_CODE (constructor_type) != ARRAY_TYPE)
   11234            9 :     error_init (loc, "array index in non-array initializer");
   11235         1905 :   else if (tree_int_cst_sgn (first) == -1)
   11236           15 :     error_init (loc, "array index in initializer exceeds array bounds");
   11237         1890 :   else if (constructor_max_index
   11238         1890 :            && tree_int_cst_lt (constructor_max_index, first))
   11239            7 :     error_init (loc, "array index in initializer exceeds array bounds");
   11240              :   else
   11241              :     {
   11242         1883 :       constant_expression_warning (first);
   11243         1883 :       if (last)
   11244          385 :         constant_expression_warning (last);
   11245         1883 :       constructor_index = convert (bitsizetype, first);
   11246         1883 :       if (tree_int_cst_lt (constructor_index, first))
   11247              :         {
   11248            0 :           constructor_index = copy_node (constructor_index);
   11249            0 :           TREE_OVERFLOW (constructor_index) = 1;
   11250              :         }
   11251              : 
   11252         1883 :       if (last)
   11253              :         {
   11254          385 :           if (tree_int_cst_equal (first, last))
   11255              :             last = NULL_TREE;
   11256          384 :           else if (tree_int_cst_lt (last, first))
   11257              :             {
   11258            2 :               error_init (loc, "empty index range in initializer");
   11259            2 :               last = NULL_TREE;
   11260              :             }
   11261              :           else
   11262              :             {
   11263          382 :               last = convert (bitsizetype, last);
   11264          382 :               if (constructor_max_index != NULL_TREE
   11265          382 :                   && tree_int_cst_lt (constructor_max_index, last))
   11266              :                 {
   11267            3 :                   error_init (loc, "array index range in initializer exceeds "
   11268              :                               "array bounds");
   11269            3 :                   last = NULL_TREE;
   11270              :                 }
   11271              :             }
   11272              :         }
   11273              : 
   11274         1883 :       designator_depth++;
   11275         1883 :       designator_erroneous = 0;
   11276         1883 :       if (constructor_range_stack || last)
   11277          379 :         push_range_stack (last, braced_init_obstack);
   11278              :     }
   11279              : }
   11280              : 
   11281              : /* Within a struct initializer, specify the next field to be initialized.  */
   11282              : 
   11283              : void
   11284        34970 : set_init_label (location_t loc, tree fieldname, location_t fieldname_loc,
   11285              :                 struct obstack *braced_init_obstack)
   11286              : {
   11287        34970 :   tree field;
   11288              : 
   11289        34970 :   if (set_designator (loc, false, braced_init_obstack))
   11290              :     return;
   11291              : 
   11292        34953 :   designator_erroneous = 1;
   11293              : 
   11294        34953 :   if (!RECORD_OR_UNION_TYPE_P (constructor_type))
   11295              :     {
   11296            3 :       error_init (loc, "field name not in record or union initializer");
   11297            3 :       return;
   11298              :     }
   11299              : 
   11300        34950 :   field = lookup_field (constructor_type, fieldname);
   11301              : 
   11302        34950 :   if (field == NULL_TREE)
   11303              :     {
   11304            8 :       tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname);
   11305            8 :       if (guessed_id)
   11306              :         {
   11307            4 :           gcc_rich_location rich_loc (fieldname_loc);
   11308            4 :           rich_loc.add_fixit_misspelled_id (fieldname_loc, guessed_id);
   11309            4 :           error_at (&rich_loc,
   11310              :                     "%qT has no member named %qE; did you mean %qE?",
   11311              :                     constructor_type, fieldname, guessed_id);
   11312            4 :         }
   11313              :       else
   11314            4 :         error_at (fieldname_loc, "%qT has no member named %qE",
   11315              :                   constructor_type, fieldname);
   11316              :     }
   11317              :   else
   11318        34988 :     do
   11319              :       {
   11320        34988 :         constructor_fields = TREE_VALUE (field);
   11321        34988 :         designator_depth++;
   11322        34988 :         designator_erroneous = 0;
   11323        34988 :         if (constructor_range_stack)
   11324           11 :           push_range_stack (NULL_TREE, braced_init_obstack);
   11325        34988 :         field = TREE_CHAIN (field);
   11326        34988 :         if (field)
   11327              :           {
   11328           46 :             if (set_designator (loc, false, braced_init_obstack))
   11329              :               return;
   11330              :           }
   11331              :       }
   11332        34988 :     while (field != NULL_TREE);
   11333              : }
   11334              : 
   11335              : /* Helper function for add_pending_init.  Find inorder successor of P
   11336              :    in AVL tree.  */
   11337              : static struct init_node *
   11338          129 : init_node_successor (struct init_node *p)
   11339              : {
   11340          129 :   struct init_node *r;
   11341          129 :   if (p->right)
   11342              :     {
   11343              :       r = p->right;
   11344           58 :       while (r->left)
   11345              :         r = r->left;
   11346              :       return r;
   11347              :     }
   11348           75 :   r = p->parent;
   11349          114 :   while (r && p == r->right)
   11350              :     {
   11351           39 :       p = r;
   11352           39 :       r = r->parent;
   11353              :     }
   11354              :   return r;
   11355              : }
   11356              : 
   11357              : /* Add a new initializer to the tree of pending initializers.  PURPOSE
   11358              :    identifies the initializer, either array index or field in a structure.
   11359              :    VALUE is the value of that index or field.  If ORIGTYPE is not
   11360              :    NULL_TREE, it is the original type of VALUE.
   11361              : 
   11362              :    IMPLICIT is true if value comes from pop_init_level (1),
   11363              :    the new initializer has been merged with the existing one
   11364              :    and thus no warnings should be emitted about overriding an
   11365              :    existing initializer.  */
   11366              : 
   11367              : static void
   11368         7906 : add_pending_init (location_t loc, tree purpose, tree value, tree origtype,
   11369              :                   bool implicit, struct obstack *braced_init_obstack)
   11370              : {
   11371         7906 :   struct init_node *p, **q, *r;
   11372              : 
   11373         7906 :   q = &constructor_pending_elts;
   11374         7906 :   p = 0;
   11375              : 
   11376         7906 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11377              :     {
   11378         7214 :       while (*q != 0)
   11379              :         {
   11380         4384 :           p = *q;
   11381         4384 :           if (tree_int_cst_lt (purpose, p->purpose))
   11382          419 :             q = &p->left;
   11383         3965 :           else if (tree_int_cst_lt (p->purpose, purpose))
   11384              :             {
   11385         3354 :               if (TREE_CODE (p->value) != RAW_DATA_CST
   11386         3354 :                   || (p->right
   11387          112 :                       && tree_int_cst_le (p->right->purpose, purpose)))
   11388         3224 :                 q = &p->right;
   11389              :               else
   11390              :                 {
   11391          130 :                   widest_int pp = wi::to_widest (p->purpose);
   11392          130 :                   widest_int pw = wi::to_widest (purpose);
   11393          130 :                   if (pp + RAW_DATA_LENGTH (p->value) <= pw)
   11394           98 :                     q = &p->right;
   11395              :                   else
   11396              :                     {
   11397              :                       /* Override which should split the old RAW_DATA_CST
   11398              :                          into 2 or 3 pieces.  */
   11399           32 :                       if (!implicit && warn_override_init)
   11400            9 :                         warning_init (loc, OPT_Woverride_init,
   11401              :                                       "initialized field overwritten");
   11402           32 :                       unsigned HOST_WIDE_INT start = (pw - pp).to_uhwi ();
   11403           32 :                       unsigned HOST_WIDE_INT len = 1;
   11404           32 :                       if (TREE_CODE (value) == RAW_DATA_CST)
   11405            0 :                         len = RAW_DATA_LENGTH (value);
   11406           32 :                       unsigned HOST_WIDE_INT end = 0;
   11407           32 :                       unsigned plen = RAW_DATA_LENGTH (p->value);
   11408           32 :                       gcc_checking_assert (start < plen && start);
   11409           32 :                       if (plen - start > len)
   11410           30 :                         end = plen - start - len;
   11411           32 :                       tree v = p->value;
   11412           32 :                       tree origtype = p->origtype;
   11413           32 :                       if (start == 1)
   11414            2 :                         p->value = build_int_cst (TREE_TYPE (v),
   11415            2 :                                                   RAW_DATA_UCHAR_ELT (v, 0));
   11416              :                       else
   11417              :                         {
   11418           30 :                           p->value = v;
   11419           30 :                           if (end > 1)
   11420           26 :                             v = copy_node (v);
   11421           30 :                           RAW_DATA_LENGTH (p->value) = start;
   11422              :                         }
   11423           32 :                       if (end)
   11424              :                         {
   11425           30 :                           tree epurpose
   11426           30 :                             = size_binop (PLUS_EXPR, purpose,
   11427              :                                           bitsize_int (len));
   11428           30 :                           if (end > 1)
   11429              :                             {
   11430           28 :                               RAW_DATA_LENGTH (v) -= plen - end;
   11431           28 :                               RAW_DATA_POINTER (v) += plen - end;
   11432              :                             }
   11433              :                           else
   11434            2 :                             v = build_int_cst (TREE_TYPE (v),
   11435            2 :                                                RAW_DATA_UCHAR_ELT (v, plen
   11436              :                                                                       - end));
   11437           30 :                           add_pending_init (loc, epurpose, v, origtype,
   11438              :                                             implicit, braced_init_obstack);
   11439              :                         }
   11440           32 :                       q = &constructor_pending_elts;
   11441           32 :                       continue;
   11442           32 :                     }
   11443          130 :                 }
   11444              :             }
   11445              :           else
   11446              :             {
   11447          611 :               if (TREE_CODE (p->value) == RAW_DATA_CST
   11448          621 :                   && (RAW_DATA_LENGTH (p->value)
   11449           10 :                       > (TREE_CODE (value) == RAW_DATA_CST
   11450           10 :                          ? RAW_DATA_LENGTH (value) : 1)))
   11451              :                 {
   11452              :                   /* Override which should split the old RAW_DATA_CST
   11453              :                      into 2 pieces.  */
   11454            6 :                   if (!implicit && warn_override_init)
   11455            3 :                     warning_init (loc, OPT_Woverride_init,
   11456              :                                   "initialized field overwritten");
   11457            6 :                   unsigned HOST_WIDE_INT len = 1;
   11458            6 :                   if (TREE_CODE (value) == RAW_DATA_CST)
   11459            2 :                     len = RAW_DATA_LENGTH (value);
   11460            6 :                   if ((unsigned) RAW_DATA_LENGTH (p->value) > len + 1)
   11461              :                     {
   11462            6 :                       RAW_DATA_LENGTH (p->value) -= len;
   11463            6 :                       RAW_DATA_POINTER (p->value) += len;
   11464              :                     }
   11465              :                   else
   11466              :                     {
   11467            0 :                       unsigned int l = RAW_DATA_LENGTH (p->value) - 1;
   11468            0 :                       p->value
   11469            0 :                         = build_int_cst (TREE_TYPE (p->value),
   11470            0 :                                          RAW_DATA_UCHAR_ELT (p->value, l));
   11471              :                     }
   11472            6 :                   p->purpose = size_binop (PLUS_EXPR, p->purpose,
   11473              :                                            bitsize_int (len));
   11474            6 :                   continue;
   11475            6 :                 }
   11476          605 :               if (TREE_CODE (value) == RAW_DATA_CST)
   11477              :                 {
   11478            8 :                 handle_raw_data:
   11479              :                   /* RAW_DATA_CST value might overlap various further
   11480              :                      prior initval entries.  Find out how many.  */
   11481           13 :                   unsigned cnt = 0;
   11482           13 :                   widest_int w
   11483           26 :                     = wi::to_widest (purpose) + RAW_DATA_LENGTH (value);
   11484           13 :                   struct init_node *r = p, *last = NULL;
   11485           13 :                   bool override_init = warn_override_init;
   11486           13 :                   while ((r = init_node_successor (r))
   11487           53 :                          && wi::to_widest (r->purpose) < w)
   11488              :                     {
   11489           40 :                       ++cnt;
   11490           40 :                       if (TREE_SIDE_EFFECTS (r->value))
   11491            2 :                         warning_init (loc, OPT_Woverride_init_side_effects,
   11492              :                                       "initialized field with side-effects "
   11493              :                                       "overwritten");
   11494           38 :                       else if (override_init)
   11495              :                         {
   11496            6 :                           warning_init (loc, OPT_Woverride_init,
   11497              :                                         "initialized field overwritten");
   11498            6 :                           override_init = false;
   11499              :                         }
   11500              :                       last = r;
   11501              :                     }
   11502           13 :                   if (cnt)
   11503              :                     {
   11504           26 :                       if (TREE_CODE (last->value) == RAW_DATA_CST
   11505           13 :                           && (wi::to_widest (last->purpose)
   11506           13 :                               + RAW_DATA_LENGTH (last->value) > w))
   11507              :                         {
   11508              :                           /* The last overlapping prior initval overlaps
   11509              :                              only partially.  Shrink it and decrease cnt.  */
   11510            0 :                           unsigned int l = (wi::to_widest (last->purpose)
   11511            0 :                                             + RAW_DATA_LENGTH (last->value)
   11512            0 :                                             - w).to_uhwi ();
   11513            0 :                           --cnt;
   11514            0 :                           RAW_DATA_LENGTH (last->value) -= l;
   11515            0 :                           RAW_DATA_POINTER (last->value) += l;
   11516            0 :                           if (RAW_DATA_LENGTH (last->value) == 1)
   11517            0 :                             last->value
   11518            0 :                               = build_int_cst (TREE_TYPE (last->value),
   11519            0 :                                                RAW_DATA_UCHAR_ELT (last->value,
   11520              :                                                                    0));
   11521            0 :                           last->purpose
   11522            0 :                             = size_binop (PLUS_EXPR, last->purpose,
   11523              :                                           bitsize_int (l));
   11524              :                         }
   11525              :                       /* Instead of deleting cnt nodes from the AVL tree
   11526              :                          and rebalancing, peel of last cnt bytes from the
   11527              :                          RAW_DATA_CST.  Overriding thousands of previously
   11528              :                          initialized array elements with #embed needs to work,
   11529              :                          but doesn't need to be super efficient.  */
   11530           13 :                       gcc_checking_assert ((unsigned) RAW_DATA_LENGTH (value)
   11531              :                                            > cnt);
   11532           13 :                       RAW_DATA_LENGTH (value) -= cnt;
   11533           13 :                       const unsigned char *s
   11534           13 :                         = &RAW_DATA_UCHAR_ELT (value, RAW_DATA_LENGTH (value));
   11535           13 :                       unsigned int o = RAW_DATA_LENGTH (value);
   11536           53 :                       for (r = p; cnt--; ++o, ++s)
   11537              :                         {
   11538           40 :                           r = init_node_successor (r);
   11539           40 :                           r->purpose = size_binop (PLUS_EXPR, purpose,
   11540              :                                                    bitsize_int (o));
   11541           40 :                           r->value = build_int_cst (TREE_TYPE (value), *s);
   11542           40 :                           r->origtype = origtype;
   11543              :                         }
   11544           13 :                       if (RAW_DATA_LENGTH (value) == 1)
   11545            0 :                         value = build_int_cst (TREE_TYPE (value),
   11546            0 :                                                RAW_DATA_UCHAR_ELT (value, 0));
   11547              :                     }
   11548              :                 }
   11549          610 :               if (!implicit)
   11550              :                 {
   11551           54 :                   if (TREE_SIDE_EFFECTS (p->value))
   11552            6 :                     warning_init (loc, OPT_Woverride_init_side_effects,
   11553              :                                   "initialized field with side-effects "
   11554              :                                   "overwritten");
   11555           48 :                   else if (warn_override_init)
   11556           13 :                     warning_init (loc, OPT_Woverride_init,
   11557              :                                   "initialized field overwritten");
   11558              :                 }
   11559          610 :               p->value = value;
   11560          610 :               p->origtype = origtype;
   11561          610 :               return;
   11562              :             }
   11563              :         }
   11564         2830 :       if (TREE_CODE (value) == RAW_DATA_CST && p)
   11565              :         {
   11566           61 :           struct init_node *r;
   11567           61 :           if (q == &p->left)
   11568              :             r = p;
   11569              :           else
   11570           36 :             r = init_node_successor (p);
   11571          131 :           if (r && wi::to_widest (r->purpose) < (wi::to_widest (purpose)
   11572          131 :                                                  + RAW_DATA_LENGTH (value)))
   11573              :             {
   11574              :               /* Overlap with at least one prior initval in the range but
   11575              :                  not at the start.  */
   11576            5 :               p = r;
   11577            5 :               p->purpose = purpose;
   11578            5 :               goto handle_raw_data;
   11579              :             }
   11580              :         }
   11581              :     }
   11582              :   else
   11583              :     {
   11584         4471 :       tree bitpos;
   11585              : 
   11586         4471 :       bitpos = bit_position (purpose);
   11587        12340 :       while (*q != NULL)
   11588              :         {
   11589         4641 :           p = *q;
   11590         4641 :           if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   11591           81 :             q = &p->left;
   11592         4560 :           else if (p->purpose != purpose)
   11593         3317 :             q = &p->right;
   11594              :           else
   11595              :             {
   11596         1243 :               if (!implicit)
   11597              :                 {
   11598          101 :                   if (TREE_SIDE_EFFECTS (p->value))
   11599            4 :                     warning_init (loc, OPT_Woverride_init_side_effects,
   11600              :                                   "initialized field with side-effects "
   11601              :                                   "overwritten");
   11602           97 :                   else if (warn_override_init)
   11603            6 :                     warning_init (loc, OPT_Woverride_init,
   11604              :                                   "initialized field overwritten");
   11605              :                 }
   11606         1243 :               p->value = value;
   11607         1243 :               p->origtype = origtype;
   11608         1243 :               return;
   11609              :             }
   11610              :         }
   11611              :     }
   11612              : 
   11613         6053 :   r = (struct init_node *) obstack_alloc (braced_init_obstack,
   11614              :                                           sizeof (struct init_node));
   11615         6053 :   r->purpose = purpose;
   11616         6053 :   r->value = value;
   11617         6053 :   r->origtype = origtype;
   11618              : 
   11619         6053 :   *q = r;
   11620         6053 :   r->parent = p;
   11621         6053 :   r->left = 0;
   11622         6053 :   r->right = 0;
   11623         6053 :   r->balance = 0;
   11624              : 
   11625         9761 :   while (p)
   11626              :     {
   11627         5048 :       struct init_node *s;
   11628              : 
   11629         5048 :       if (r == p->left)
   11630              :         {
   11631          343 :           if (p->balance == 0)
   11632          246 :             p->balance = -1;
   11633           97 :           else if (p->balance < 0)
   11634              :             {
   11635           45 :               if (r->balance < 0)
   11636              :                 {
   11637              :                   /* L rotation.  */
   11638           40 :                   p->left = r->right;
   11639           40 :                   if (p->left)
   11640            2 :                     p->left->parent = p;
   11641           40 :                   r->right = p;
   11642              : 
   11643           40 :                   p->balance = 0;
   11644           40 :                   r->balance = 0;
   11645              : 
   11646           40 :                   s = p->parent;
   11647           40 :                   p->parent = r;
   11648           40 :                   r->parent = s;
   11649           40 :                   if (s)
   11650              :                     {
   11651           31 :                       if (s->left == p)
   11652           10 :                         s->left = r;
   11653              :                       else
   11654           21 :                         s->right = r;
   11655              :                     }
   11656              :                   else
   11657            9 :                     constructor_pending_elts = r;
   11658              :                 }
   11659              :               else
   11660              :                 {
   11661              :                   /* LR rotation.  */
   11662            5 :                   struct init_node *t = r->right;
   11663              : 
   11664            5 :                   r->right = t->left;
   11665            5 :                   if (r->right)
   11666            0 :                     r->right->parent = r;
   11667            5 :                   t->left = r;
   11668              : 
   11669            5 :                   p->left = t->right;
   11670            5 :                   if (p->left)
   11671            0 :                     p->left->parent = p;
   11672            5 :                   t->right = p;
   11673              : 
   11674            5 :                   p->balance = t->balance < 0;
   11675            5 :                   r->balance = -(t->balance > 0);
   11676            5 :                   t->balance = 0;
   11677              : 
   11678            5 :                   s = p->parent;
   11679            5 :                   p->parent = t;
   11680            5 :                   r->parent = t;
   11681            5 :                   t->parent = s;
   11682            5 :                   if (s)
   11683              :                     {
   11684            0 :                       if (s->left == p)
   11685            0 :                         s->left = t;
   11686              :                       else
   11687            0 :                         s->right = t;
   11688              :                     }
   11689              :                   else
   11690            5 :                     constructor_pending_elts = t;
   11691              :                 }
   11692              :               break;
   11693              :             }
   11694              :           else
   11695              :             {
   11696              :               /* p->balance == +1; growth of left side balances the node.  */
   11697           52 :               p->balance = 0;
   11698           52 :               break;
   11699              :             }
   11700              :         }
   11701              :       else /* r == p->right */
   11702              :         {
   11703         4705 :           if (p->balance == 0)
   11704              :             /* Growth propagation from right side.  */
   11705         3462 :             p->balance++;
   11706         1243 :           else if (p->balance > 0)
   11707              :             {
   11708         1176 :               if (r->balance > 0)
   11709              :                 {
   11710              :                   /* R rotation.  */
   11711         1174 :                   p->right = r->left;
   11712         1174 :                   if (p->right)
   11713          177 :                     p->right->parent = p;
   11714         1174 :                   r->left = p;
   11715              : 
   11716         1174 :                   p->balance = 0;
   11717         1174 :                   r->balance = 0;
   11718              : 
   11719         1174 :                   s = p->parent;
   11720         1174 :                   p->parent = r;
   11721         1174 :                   r->parent = s;
   11722         1174 :                   if (s)
   11723              :                     {
   11724          378 :                       if (s->left == p)
   11725            2 :                         s->left = r;
   11726              :                       else
   11727          376 :                         s->right = r;
   11728              :                     }
   11729              :                   else
   11730          796 :                     constructor_pending_elts = r;
   11731              :                 }
   11732              :               else /* r->balance == -1 */
   11733              :                 {
   11734              :                   /* RL rotation */
   11735            2 :                   struct init_node *t = r->left;
   11736              : 
   11737            2 :                   r->left = t->right;
   11738            2 :                   if (r->left)
   11739            2 :                     r->left->parent = r;
   11740            2 :                   t->right = r;
   11741              : 
   11742            2 :                   p->right = t->left;
   11743            2 :                   if (p->right)
   11744            2 :                     p->right->parent = p;
   11745            2 :                   t->left = p;
   11746              : 
   11747            2 :                   r->balance = (t->balance < 0);
   11748            2 :                   p->balance = -(t->balance > 0);
   11749            2 :                   t->balance = 0;
   11750              : 
   11751            2 :                   s = p->parent;
   11752            2 :                   p->parent = t;
   11753            2 :                   r->parent = t;
   11754            2 :                   t->parent = s;
   11755            2 :                   if (s)
   11756              :                     {
   11757            0 :                       if (s->left == p)
   11758            0 :                         s->left = t;
   11759              :                       else
   11760            0 :                         s->right = t;
   11761              :                     }
   11762              :                   else
   11763            2 :                     constructor_pending_elts = t;
   11764              :                 }
   11765              :               break;
   11766              :             }
   11767              :           else
   11768              :             {
   11769              :               /* p->balance == -1; growth of right side balances the node.  */
   11770           67 :               p->balance = 0;
   11771           67 :               break;
   11772              :             }
   11773              :         }
   11774              : 
   11775         3708 :       r = p;
   11776         3708 :       p = p->parent;
   11777              :     }
   11778              : }
   11779              : 
   11780              : /* Build AVL tree from a sorted chain.  */
   11781              : 
   11782              : static void
   11783         1812 : set_nonincremental_init (struct obstack * braced_init_obstack)
   11784              : {
   11785         1812 :   unsigned HOST_WIDE_INT ix;
   11786         1812 :   tree index, value;
   11787              : 
   11788         1812 :   if (TREE_CODE (constructor_type) != RECORD_TYPE
   11789         1812 :       && TREE_CODE (constructor_type) != ARRAY_TYPE)
   11790              :     return;
   11791              : 
   11792         5511 :   FOR_EACH_CONSTRUCTOR_ELT (constructor_elements, ix, index, value)
   11793         3699 :     add_pending_init (input_location, index, value, NULL_TREE, true,
   11794              :                       braced_init_obstack);
   11795         1812 :   constructor_elements = NULL;
   11796         1812 :   if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11797              :     {
   11798          948 :       constructor_unfilled_fields = TYPE_FIELDS (constructor_type);
   11799              :       /* Skip any nameless bit fields at the beginning.  */
   11800          948 :       while (constructor_unfilled_fields != NULL_TREE
   11801          948 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   11802            0 :         constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
   11803              : 
   11804              :     }
   11805          864 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11806              :     {
   11807          864 :       if (TYPE_DOMAIN (constructor_type))
   11808          806 :         constructor_unfilled_index
   11809          806 :           = convert (bitsizetype,
   11810          806 :                      TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type)));
   11811              :       else
   11812           58 :         constructor_unfilled_index = bitsize_zero_node;
   11813              :     }
   11814         1812 :   constructor_incremental = 0;
   11815              : }
   11816              : 
   11817              : /* Build AVL tree from a string constant.  */
   11818              : 
   11819              : static void
   11820            7 : set_nonincremental_init_from_string (tree str,
   11821              :                                      struct obstack * braced_init_obstack)
   11822              : {
   11823            7 :   tree value, purpose, type;
   11824            7 :   HOST_WIDE_INT val[2];
   11825            7 :   const char *p, *end;
   11826            7 :   int byte, wchar_bytes, charwidth, bitpos;
   11827              : 
   11828            7 :   gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE);
   11829              : 
   11830            7 :   wchar_bytes = TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) / BITS_PER_UNIT;
   11831            7 :   charwidth = TYPE_PRECISION (char_type_node);
   11832            7 :   gcc_assert ((size_t) wchar_bytes * charwidth
   11833              :               <= ARRAY_SIZE (val) * HOST_BITS_PER_WIDE_INT);
   11834            7 :   type = TREE_TYPE (constructor_type);
   11835            7 :   p = TREE_STRING_POINTER (str);
   11836            7 :   end = p + TREE_STRING_LENGTH (str);
   11837              : 
   11838            7 :   for (purpose = bitsize_zero_node;
   11839              :        p < end
   11840           52 :        && !(constructor_max_index
   11841           20 :             && tree_int_cst_lt (constructor_max_index, purpose));
   11842           25 :        purpose = size_binop (PLUS_EXPR, purpose, bitsize_one_node))
   11843              :     {
   11844           25 :       if (wchar_bytes == 1)
   11845              :         {
   11846            9 :           val[0] = (unsigned char) *p++;
   11847            9 :           val[1] = 0;
   11848              :         }
   11849              :       else
   11850              :         {
   11851           16 :           val[1] = 0;
   11852           16 :           val[0] = 0;
   11853           64 :           for (byte = 0; byte < wchar_bytes; byte++)
   11854              :             {
   11855           48 :               if (BYTES_BIG_ENDIAN)
   11856              :                 bitpos = (wchar_bytes - byte - 1) * charwidth;
   11857              :               else
   11858           48 :                 bitpos = byte * charwidth;
   11859           48 :               val[bitpos / HOST_BITS_PER_WIDE_INT]
   11860           48 :                 |= ((unsigned HOST_WIDE_INT) ((unsigned char) *p++))
   11861           48 :                    << (bitpos % HOST_BITS_PER_WIDE_INT);
   11862              :             }
   11863              :         }
   11864              : 
   11865           25 :       if (!TYPE_UNSIGNED (type))
   11866              :         {
   11867           13 :           bitpos = ((wchar_bytes - 1) * charwidth) + HOST_BITS_PER_CHAR;
   11868           13 :           if (bitpos < HOST_BITS_PER_WIDE_INT)
   11869              :             {
   11870           13 :               if (val[0] & (HOST_WIDE_INT_1 << (bitpos - 1)))
   11871              :                 {
   11872            0 :                   val[0] |= HOST_WIDE_INT_M1U << bitpos;
   11873            0 :                   val[1] = -1;
   11874              :                 }
   11875              :             }
   11876            0 :           else if (bitpos == HOST_BITS_PER_WIDE_INT)
   11877              :             {
   11878            0 :               if (val[0] < 0)
   11879            0 :                 val[1] = -1;
   11880              :             }
   11881            0 :           else if (val[1] & (HOST_WIDE_INT_1
   11882            0 :                              << (bitpos - 1 - HOST_BITS_PER_WIDE_INT)))
   11883            0 :             val[1] |= HOST_WIDE_INT_M1U << (bitpos - HOST_BITS_PER_WIDE_INT);
   11884              :         }
   11885              : 
   11886           25 :       value = wide_int_to_tree (type,
   11887           25 :                                 wide_int::from_array (val, 2,
   11888              :                                                       HOST_BITS_PER_WIDE_INT * 2));
   11889           25 :       add_pending_init (input_location, purpose, value, NULL_TREE, true,
   11890              :                         braced_init_obstack);
   11891              :     }
   11892              : 
   11893            7 :   constructor_incremental = 0;
   11894            7 : }
   11895              : 
   11896              : /* Return value of FIELD in pending initializer or NULL_TREE if the field was
   11897              :    not initialized yet.  */
   11898              : 
   11899              : static tree
   11900       705323 : find_init_member (tree field, struct obstack * braced_init_obstack)
   11901              : {
   11902       705323 :   struct init_node *p;
   11903              : 
   11904       705323 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   11905              :     {
   11906       703504 :       if (constructor_incremental
   11907       703504 :           && tree_int_cst_lt (field, constructor_unfilled_index))
   11908           16 :         set_nonincremental_init (braced_init_obstack);
   11909              : 
   11910       703504 :       p = constructor_pending_elts;
   11911       704103 :       while (p)
   11912              :         {
   11913         1151 :           if (tree_int_cst_lt (field, p->purpose))
   11914           93 :             p = p->left;
   11915         1058 :           else if (tree_int_cst_lt (p->purpose, field))
   11916          506 :             p = p->right;
   11917              :           else
   11918          552 :             return p->value;
   11919              :         }
   11920              :     }
   11921         1819 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   11922              :     {
   11923         1696 :       tree bitpos = bit_position (field);
   11924              : 
   11925         1696 :       if (constructor_incremental
   11926         1696 :           && (!constructor_unfilled_fields
   11927          609 :               || tree_int_cst_lt (bitpos,
   11928          609 :                                   bit_position (constructor_unfilled_fields))))
   11929          289 :         set_nonincremental_init (braced_init_obstack);
   11930              : 
   11931         1696 :       p = constructor_pending_elts;
   11932         2652 :       while (p)
   11933              :         {
   11934         2047 :           if (field == p->purpose)
   11935         1091 :             return p->value;
   11936          956 :           else if (tree_int_cst_lt (bitpos, bit_position (p->purpose)))
   11937            7 :             p = p->left;
   11938              :           else
   11939          949 :             p = p->right;
   11940              :         }
   11941              :     }
   11942          123 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   11943              :     {
   11944          123 :       if (!vec_safe_is_empty (constructor_elements)
   11945           50 :           && (constructor_elements->last ().index == field))
   11946           50 :         return constructor_elements->last ().value;
   11947              :     }
   11948              :   return NULL_TREE;
   11949              : }
   11950              : 
   11951              : /* "Output" the next constructor element.
   11952              :    At top level, really output it to assembler code now.
   11953              :    Otherwise, collect it in a list from which we will make a CONSTRUCTOR.
   11954              :    If ORIGTYPE is not NULL_TREE, it is the original type of VALUE.
   11955              :    TYPE is the data type that the containing data type wants here.
   11956              :    FIELD is the field (a FIELD_DECL) or the index that this element fills.
   11957              :    If VALUE is a string constant, STRICT_STRING is true if it is
   11958              :    unparenthesized or we should not warn here for it being parenthesized.
   11959              :    For other types of VALUE, STRICT_STRING is not used.
   11960              : 
   11961              :    PENDING if true means output pending elements that belong
   11962              :    right after this element.  (PENDING is normally true;
   11963              :    it is false while outputting pending elements, to avoid recursion.)
   11964              : 
   11965              :    IMPLICIT is true if value comes from pop_init_level (1),
   11966              :    the new initializer has been merged with the existing one
   11967              :    and thus no warnings should be emitted about overriding an
   11968              :    existing initializer.  */
   11969              : 
   11970              : static void
   11971      9632616 : output_init_element (location_t loc, tree value, tree origtype,
   11972              :                      bool strict_string, tree type, tree field, bool pending,
   11973              :                      bool implicit, struct obstack * braced_init_obstack)
   11974              : {
   11975      9632616 :   tree semantic_type = NULL_TREE;
   11976      9632616 :   bool maybe_const = true;
   11977      9632616 :   bool npc, int_const_expr, arith_const_expr;
   11978              : 
   11979      9632616 :   if (type == error_mark_node || value == error_mark_node)
   11980              :     {
   11981          329 :       constructor_erroneous = 1;
   11982         4575 :       return;
   11983              :     }
   11984      9632287 :   if (TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
   11985       200968 :       && (TREE_CODE (value) == STRING_CST
   11986       159557 :           || TREE_CODE (value) == COMPOUND_LITERAL_EXPR)
   11987        41419 :       && !(TREE_CODE (value) == STRING_CST
   11988        41411 :            && TREE_CODE (type) == ARRAY_TYPE
   11989         3898 :            && INTEGRAL_TYPE_P (TREE_TYPE (type)))
   11990      9669808 :       && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
   11991        37521 :                      TYPE_MAIN_VARIANT (type)))
   11992        37521 :     value = array_to_pointer_conversion (input_location, value);
   11993              : 
   11994      9632287 :   if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
   11995          182 :       && require_constant_value && pending)
   11996              :     {
   11997              :       /* As an extension, allow initializing objects with static storage
   11998              :          duration with compound literals (which are then treated just as
   11999              :          the brace enclosed list they contain).  */
   12000          114 :       if (flag_isoc99)
   12001           24 :         pedwarn_init (loc, OPT_Wpedantic, "initializer element is not "
   12002              :                       "constant");
   12003          114 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (value);
   12004          114 :       value = DECL_INITIAL (decl);
   12005              :     }
   12006              : 
   12007      9632287 :   npc = null_pointer_constant_p (value);
   12008     19264574 :   int_const_expr = (TREE_CODE (value) == INTEGER_CST
   12009      4222780 :                     && !TREE_OVERFLOW (value)
   12010     13855066 :                     && INTEGRAL_TYPE_P (TREE_TYPE (value)));
   12011              :   /* Not fully determined before folding.  */
   12012      9632287 :   arith_const_expr = true;
   12013      9632287 :   if (TREE_CODE (value) == EXCESS_PRECISION_EXPR)
   12014              :     {
   12015           16 :       semantic_type = TREE_TYPE (value);
   12016           16 :       value = TREE_OPERAND (value, 0);
   12017              :     }
   12018      9632287 :   value = c_fully_fold (value, require_constant_value, &maybe_const);
   12019              :   /* TODO: this may not detect all cases of expressions folding to
   12020              :      constants that are not arithmetic constant expressions.  */
   12021      9632287 :   if (!maybe_const)
   12022              :     arith_const_expr = false;
   12023     19262017 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (value))
   12024      3189388 :            && TREE_CODE (TREE_TYPE (value)) != REAL_TYPE
   12025     11476965 :            && TREE_CODE (TREE_TYPE (value)) != COMPLEX_TYPE)
   12026              :     arith_const_expr = false;
   12027      7800379 :   else if (TREE_CODE (value) != INTEGER_CST
   12028              :            && TREE_CODE (value) != REAL_CST
   12029              :            && TREE_CODE (value) != COMPLEX_CST
   12030              :            && TREE_CODE (value) != RAW_DATA_CST)
   12031              :     arith_const_expr = false;
   12032      4611783 :   else if (TREE_OVERFLOW (value))
   12033      5020505 :     arith_const_expr = false;
   12034              : 
   12035      9632287 :   if (value == error_mark_node)
   12036            0 :     constructor_erroneous = 1;
   12037      9632287 :   else if (!TREE_CONSTANT (value))
   12038      3209012 :     constructor_constant = 0;
   12039      6423275 :   else if (!initializer_constant_valid_p (value,
   12040      6423275 :                                           TREE_TYPE (value),
   12041      6423275 :                                           AGGREGATE_TYPE_P (constructor_type)
   12042      6423275 :                                           && TYPE_REVERSE_STORAGE_ORDER
   12043              :                                              (constructor_type))
   12044      6423275 :            || (RECORD_OR_UNION_TYPE_P (constructor_type)
   12045      1041131 :                && DECL_C_BIT_FIELD (field)
   12046         7995 :                && TREE_CODE (value) != INTEGER_CST))
   12047           77 :     constructor_simple = 0;
   12048      9632287 :   if (!maybe_const)
   12049         1172 :     constructor_nonconst = 1;
   12050              : 
   12051              :   /* Digest the initializer and issue any errors about incompatible
   12052              :      types before issuing errors about non-constant initializers.  */
   12053      9632287 :   tree new_value = value;
   12054      9632287 :   if (semantic_type)
   12055           16 :     new_value = build1 (EXCESS_PRECISION_EXPR, semantic_type, value);
   12056              :   /* In the case of braces around a scalar initializer, the result of
   12057              :      this initializer processing goes through digest_init again at the
   12058              :      outer level.  In the case of a constexpr initializer for a
   12059              :      pointer, avoid converting a null pointer constant to something
   12060              :      that is not a null pointer constant to avoid a spurious error
   12061              :      from that second processing.  */
   12062      9632287 :   if (!require_constexpr_value
   12063          398 :       || !npc
   12064           69 :       || TREE_CODE (constructor_type) != POINTER_TYPE)
   12065      9632276 :     new_value = digest_init (loc,
   12066      9632276 :                              RECORD_OR_UNION_TYPE_P (constructor_type)
   12067      8558084 :                              ? field : constructor_fields
   12068      8558084 :                              ? constructor_fields : constructor_decl,
   12069              :                              type, new_value, origtype, npc,
   12070              :                              int_const_expr, arith_const_expr, strict_string,
   12071              :                              require_constant_value, require_constexpr_value);
   12072      9632287 :   if (new_value == error_mark_node)
   12073              :     {
   12074           76 :       constructor_erroneous = 1;
   12075           76 :       return;
   12076              :     }
   12077      9632211 :   if (require_constant_value || require_constant_elements)
   12078      2713272 :     constant_expression_warning (new_value);
   12079              : 
   12080              :   /* Proceed to check the constness of the original initializer.  */
   12081      9632211 :   if (!initializer_constant_valid_p (value, TREE_TYPE (value)))
   12082              :     {
   12083      3209038 :       if (require_constant_value)
   12084              :         {
   12085            0 :           error_init (loc, "initializer element is not constant");
   12086            0 :           value = error_mark_node;
   12087              :         }
   12088      3209038 :       else if (require_constant_elements)
   12089           15 :         pedwarn (loc, OPT_Wpedantic,
   12090              :                  "initializer element is not computable at load time");
   12091              :     }
   12092      6423173 :   else if (!maybe_const
   12093           54 :            && (require_constant_value || require_constant_elements))
   12094           28 :     pedwarn_init (loc, OPT_Wpedantic,
   12095              :                   "initializer element is not a constant expression");
   12096              :   /* digest_init has already carried out the additional checks
   12097              :      required for 'constexpr' initializers (using the information
   12098              :      passed to it about whether the original initializer was certain
   12099              :      kinds of constant expression), so that check does not need to be
   12100              :      repeated here.  */
   12101              : 
   12102              :   /* Issue -Wc++-compat warnings about initializing a bitfield with
   12103              :      enum type.  */
   12104      9632211 :   if (warn_cxx_compat
   12105         6897 :       && field != NULL_TREE
   12106         6897 :       && TREE_CODE (field) == FIELD_DECL
   12107          461 :       && DECL_BIT_FIELD_TYPE (field) != NULL_TREE
   12108           21 :       && (TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))
   12109           21 :           != TYPE_MAIN_VARIANT (type))
   12110      9632232 :       && TREE_CODE (DECL_BIT_FIELD_TYPE (field)) == ENUMERAL_TYPE)
   12111              :     {
   12112           21 :       tree checktype = origtype != NULL_TREE ? origtype : TREE_TYPE (value);
   12113           21 :       if (checktype != error_mark_node
   12114           21 :           && (TYPE_MAIN_VARIANT (checktype)
   12115           21 :               != TYPE_MAIN_VARIANT (DECL_BIT_FIELD_TYPE (field))))
   12116            9 :         warning_init (loc, OPT_Wc___compat,
   12117              :                       "enum conversion in initialization is invalid in C++");
   12118              :     }
   12119              : 
   12120              :   /* If this field is empty and does not have side effects (and is not at
   12121              :      the end of structure), don't do anything other than checking the
   12122              :      initializer.  */
   12123      9632211 :   if (field
   12124      9632211 :       && (TREE_TYPE (field) == error_mark_node
   12125      9631776 :           || (COMPLETE_TYPE_P (TREE_TYPE (field))
   12126      9631467 :               && integer_zerop (TYPE_SIZE (TREE_TYPE (field)))
   12127           62 :               && !TREE_SIDE_EFFECTS (new_value)
   12128           33 :               && (TREE_CODE (constructor_type) == ARRAY_TYPE
   12129           33 :                   || DECL_CHAIN (field)))))
   12130           18 :     return;
   12131              : 
   12132              :   /* Finally, set VALUE to the initializer value digested above.  */
   12133      9632193 :   value = new_value;
   12134              : 
   12135              :   /* If this element doesn't come next in sequence,
   12136              :      put it on constructor_pending_elts.  */
   12137      9632193 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE
   12138      9632193 :       && (!constructor_incremental
   12139      1720454 :           || !tree_int_cst_equal (field, constructor_unfilled_index)
   12140      1720020 :           || (TREE_CODE (value) == RAW_DATA_CST
   12141          236 :               && constructor_pending_elts
   12142           66 :               && pending)))
   12143              :     {
   12144         1341 :       if (constructor_incremental
   12145         1341 :           && (tree_int_cst_lt (field, constructor_unfilled_index)
   12146          405 :               || (TREE_CODE (value) == RAW_DATA_CST
   12147           14 :                   && constructor_pending_elts
   12148           14 :                   && pending)))
   12149           48 :         set_nonincremental_init (braced_init_obstack);
   12150              : 
   12151         1341 :       add_pending_init (loc, field, value, origtype, implicit,
   12152              :                         braced_init_obstack);
   12153         1341 :       return;
   12154              :     }
   12155      9630852 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE
   12156      1042840 :            && (!constructor_incremental
   12157      1041174 :                || field != constructor_unfilled_fields))
   12158              :     {
   12159              :       /* We do this for records but not for unions.  In a union,
   12160              :          no matter which field is specified, it can be initialized
   12161              :          right away since it starts at the beginning of the union.  */
   12162         2811 :       if (constructor_incremental)
   12163              :         {
   12164         1145 :           if (!constructor_unfilled_fields)
   12165           39 :             set_nonincremental_init (braced_init_obstack);
   12166              :           else
   12167              :             {
   12168         1106 :               tree bitpos, unfillpos;
   12169              : 
   12170         1106 :               bitpos = bit_position (field);
   12171         1106 :               unfillpos = bit_position (constructor_unfilled_fields);
   12172              : 
   12173         1106 :               if (tree_int_cst_lt (bitpos, unfillpos))
   12174            4 :                 set_nonincremental_init (braced_init_obstack);
   12175              :             }
   12176              :         }
   12177              : 
   12178         2811 :       add_pending_init (loc, field, value, origtype, implicit,
   12179              :                         braced_init_obstack);
   12180         2811 :       return;
   12181              :     }
   12182      9628041 :   else if (TREE_CODE (constructor_type) == UNION_TYPE
   12183      9628041 :            && !vec_safe_is_empty (constructor_elements))
   12184              :     {
   12185           62 :       if (!implicit)
   12186              :         {
   12187           12 :           if (TREE_SIDE_EFFECTS (constructor_elements->last ().value))
   12188            3 :             warning_init (loc, OPT_Woverride_init_side_effects,
   12189              :                           "initialized field with side-effects overwritten");
   12190            9 :           else if (warn_override_init)
   12191            6 :             warning_init (loc, OPT_Woverride_init,
   12192              :                           "initialized field overwritten");
   12193              :         }
   12194              : 
   12195              :       /* We can have just one union field set.  */
   12196           62 :       constructor_elements = NULL;
   12197              :     }
   12198              : 
   12199              :   /* Otherwise, output this element either to
   12200              :      constructor_elements or to the assembler file.  */
   12201              : 
   12202      9628041 :   constructor_elt celt = {field, value};
   12203      9628041 :   vec_safe_push (constructor_elements, celt);
   12204              : 
   12205              :   /* Advance the variable that indicates sequential elements output.  */
   12206      9628041 :   if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12207              :     {
   12208      1720015 :       tree inc = bitsize_one_node;
   12209      1720015 :       if (value && TREE_CODE (value) == RAW_DATA_CST)
   12210          231 :         inc = bitsize_int (RAW_DATA_LENGTH (value));
   12211      1720015 :       constructor_unfilled_index
   12212      1720015 :         = size_binop_loc (input_location, PLUS_EXPR,
   12213              :                           constructor_unfilled_index, inc);
   12214              :     }
   12215      7908026 :   else if (TREE_CODE (constructor_type) == RECORD_TYPE)
   12216              :     {
   12217      1040029 :       constructor_unfilled_fields
   12218      1040029 :         = DECL_CHAIN (constructor_unfilled_fields);
   12219              : 
   12220              :       /* Skip any nameless bit fields.  */
   12221      1040029 :       while (constructor_unfilled_fields != NULL_TREE
   12222      1040130 :              && DECL_UNNAMED_BIT_FIELD (constructor_unfilled_fields))
   12223          101 :         constructor_unfilled_fields
   12224          101 :           = DECL_CHAIN (constructor_unfilled_fields);
   12225              :     }
   12226      6867997 :   else if (TREE_CODE (constructor_type) == UNION_TYPE)
   12227        31320 :     constructor_unfilled_fields = NULL_TREE;
   12228              : 
   12229              :   /* Now output any pending elements which have become next.  */
   12230      9628041 :   if (pending)
   12231      9621933 :     output_pending_init_elements (0, braced_init_obstack);
   12232              : }
   12233              : 
   12234              : /* For two FIELD_DECLs in the same chain, return -1 if field1
   12235              :    comes before field2, 1 if field1 comes after field2 and
   12236              :    0 if field1 == field2.  */
   12237              : 
   12238              : static int
   12239         6884 : init_field_decl_cmp (tree field1, tree field2)
   12240              : {
   12241         6884 :   if (field1 == field2)
   12242              :     return 0;
   12243              : 
   12244         3224 :   tree bitpos1 = bit_position (field1);
   12245         3224 :   tree bitpos2 = bit_position (field2);
   12246         3224 :   if (tree_int_cst_equal (bitpos1, bitpos2))
   12247              :     {
   12248              :       /* If one of the fields has non-zero bitsize, then that
   12249              :          field must be the last one in a sequence of zero
   12250              :          sized fields, fields after it will have bigger
   12251              :          bit_position.  */
   12252           22 :       if (TREE_TYPE (field1) != error_mark_node
   12253           22 :           && COMPLETE_TYPE_P (TREE_TYPE (field1))
   12254           44 :           && integer_nonzerop (TREE_TYPE (field1)))
   12255              :         return 1;
   12256           22 :       if (TREE_TYPE (field2) != error_mark_node
   12257           22 :           && COMPLETE_TYPE_P (TREE_TYPE (field2))
   12258           37 :           && integer_nonzerop (TREE_TYPE (field2)))
   12259              :         return -1;
   12260              :       /* Otherwise, fallback to DECL_CHAIN walk to find out
   12261              :          which field comes earlier.  Walk chains of both
   12262              :          fields, so that if field1 and field2 are close to each
   12263              :          other in either order, it is found soon even for large
   12264              :          sequences of zero sized fields.  */
   12265              :       tree f1 = field1, f2 = field2;
   12266           22 :       while (1)
   12267              :         {
   12268           22 :           f1 = DECL_CHAIN (f1);
   12269           22 :           f2 = DECL_CHAIN (f2);
   12270           22 :           if (f1 == NULL_TREE)
   12271              :             {
   12272            7 :               gcc_assert (f2);
   12273              :               return 1;
   12274              :             }
   12275           15 :           if (f2 == NULL_TREE)
   12276              :             return -1;
   12277            1 :           if (f1 == field2)
   12278              :             return -1;
   12279            0 :           if (f2 == field1)
   12280              :             return 1;
   12281            0 :           if (!tree_int_cst_equal (bit_position (f1), bitpos1))
   12282              :             return 1;
   12283            0 :           if (!tree_int_cst_equal (bit_position (f2), bitpos1))
   12284              :             return -1;
   12285              :         }
   12286              :     }
   12287         3202 :   else if (tree_int_cst_lt (bitpos1, bitpos2))
   12288              :     return -1;
   12289              :   else
   12290              :     return 1;
   12291              : }
   12292              : 
   12293              : /* Output any pending elements which have become next.
   12294              :    As we output elements, constructor_unfilled_{fields,index}
   12295              :    advances, which may cause other elements to become next;
   12296              :    if so, they too are output.
   12297              : 
   12298              :    If ALL is 0, we return when there are
   12299              :    no more pending elements to output now.
   12300              : 
   12301              :    If ALL is 1, we output space as necessary so that
   12302              :    we can output all the pending elements.  */
   12303              : static void
   12304     11693336 : output_pending_init_elements (int all, struct obstack * braced_init_obstack)
   12305              : {
   12306     11693336 :   struct init_node *elt = constructor_pending_elts;
   12307     11694480 :   tree next;
   12308              : 
   12309     11694480 :  retry:
   12310              : 
   12311              :   /* Look through the whole pending tree.
   12312              :      If we find an element that should be output now,
   12313              :      output it.  Otherwise, set NEXT to the element
   12314              :      that comes first among those still pending.  */
   12315              : 
   12316     11694480 :   next = NULL_TREE;
   12317     11706479 :   while (elt)
   12318              :     {
   12319        14845 :       if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12320              :         {
   12321         6812 :           if (tree_int_cst_equal (elt->purpose,
   12322              :                                   constructor_unfilled_index))
   12323         2829 :             output_init_element (input_location, elt->value, elt->origtype,
   12324         2829 :                                  true, TREE_TYPE (constructor_type),
   12325              :                                  constructor_unfilled_index, false, false,
   12326              :                                  braced_init_obstack);
   12327         3983 :           else if (tree_int_cst_lt (constructor_unfilled_index,
   12328         3983 :                                     elt->purpose))
   12329              :             {
   12330              :               /* Advance to the next smaller node.  */
   12331         1133 :               if (elt->left)
   12332              :                 elt = elt->left;
   12333              :               else
   12334              :                 {
   12335              :                   /* We have reached the smallest node bigger than the
   12336              :                      current unfilled index.  Fill the space first.  */
   12337          345 :                   next = elt->purpose;
   12338          345 :                   break;
   12339              :                 }
   12340              :             }
   12341              :           else
   12342              :             {
   12343              :               /* Advance to the next bigger node.  */
   12344         2850 :               if (elt->right)
   12345              :                 elt = elt->right;
   12346              :               else
   12347              :                 {
   12348              :                   /* We have reached the biggest node in a subtree.  Find
   12349              :                      the parent of it, which is the next bigger node.  */
   12350         2850 :                   while (elt->parent && elt->parent->right == elt)
   12351              :                     elt = elt->parent;
   12352         1896 :                   elt = elt->parent;
   12353         2679 :                   if (elt && tree_int_cst_lt (constructor_unfilled_index,
   12354          783 :                                               elt->purpose))
   12355              :                     {
   12356           22 :                       next = elt->purpose;
   12357           22 :                       break;
   12358              :                     }
   12359              :                 }
   12360              :             }
   12361              :         }
   12362         8033 :       else if (RECORD_OR_UNION_TYPE_P (constructor_type))
   12363              :         {
   12364              :           /* If the current record is complete we are done.  */
   12365         8033 :           if (constructor_unfilled_fields == NULL_TREE)
   12366              :             break;
   12367              : 
   12368         6440 :           int cmp = init_field_decl_cmp (constructor_unfilled_fields,
   12369              :                                          elt->purpose);
   12370         6440 :           if (cmp == 0)
   12371         3279 :             output_init_element (input_location, elt->value, elt->origtype,
   12372         3279 :                                  true, TREE_TYPE (elt->purpose),
   12373              :                                  elt->purpose, false, false,
   12374              :                                  braced_init_obstack);
   12375         3161 :           else if (cmp < 0)
   12376              :             {
   12377              :               /* Advance to the next smaller node.  */
   12378         1274 :               if (elt->left)
   12379              :                 elt = elt->left;
   12380              :               else
   12381              :                 {
   12382              :                   /* We have reached the smallest node bigger than the
   12383              :                      current unfilled field.  Fill the space first.  */
   12384          823 :                   next = elt->purpose;
   12385          823 :                   break;
   12386              :                 }
   12387              :             }
   12388              :           else
   12389              :             {
   12390              :               /* Advance to the next bigger node.  */
   12391         1887 :               if (elt->right)
   12392              :                 elt = elt->right;
   12393              :               else
   12394              :                 {
   12395              :                   /* We have reached the biggest node in a subtree.  Find
   12396              :                      the parent of it, which is the next bigger node.  */
   12397          977 :                   while (elt->parent && elt->parent->right == elt)
   12398              :                     elt = elt->parent;
   12399          757 :                   elt = elt->parent;
   12400          757 :                   if (elt
   12401          757 :                       && init_field_decl_cmp (constructor_unfilled_fields,
   12402              :                                               elt->purpose) < 0)
   12403              :                     {
   12404           63 :                       next = elt->purpose;
   12405           63 :                       break;
   12406              :                     }
   12407              :                 }
   12408              :             }
   12409              :         }
   12410              :     }
   12411              : 
   12412              :   /* Ordinarily return, but not if we want to output all
   12413              :      and there are elements left.  */
   12414     11694480 :   if (!(all && next != NULL_TREE))
   12415     11693336 :     return;
   12416              : 
   12417              :   /* If it's not incremental, just skip over the gap, so that after
   12418              :      jumping to retry we will output the next successive element.  */
   12419         1144 :   if (RECORD_OR_UNION_TYPE_P (constructor_type))
   12420          816 :     constructor_unfilled_fields = next;
   12421          328 :   else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12422          328 :     constructor_unfilled_index = next;
   12423              : 
   12424              :   /* ELT now points to the node in the pending tree with the next
   12425              :      initializer to output.  */
   12426         1144 :   goto retry;
   12427              : }
   12428              : 
   12429              : /* Expression VALUE coincides with the start of type TYPE in a braced
   12430              :    initializer.  Return true if we should treat VALUE as initializing
   12431              :    the first element of TYPE, false if we should treat it as initializing
   12432              :    TYPE as a whole.
   12433              : 
   12434              :    If the initializer is clearly invalid, the question becomes:
   12435              :    which choice gives the best error message?  */
   12436              : 
   12437              : static bool
   12438      3488753 : initialize_elementwise_p (tree type, tree value)
   12439              : {
   12440      3488753 :   if (type == error_mark_node || value == error_mark_node)
   12441              :     return false;
   12442              : 
   12443      3488445 :   gcc_checking_assert (TYPE_MAIN_VARIANT (type) == type);
   12444              : 
   12445      3488445 :   tree value_type = TREE_TYPE (value);
   12446      3488445 :   if (value_type == error_mark_node)
   12447              :     return false;
   12448              : 
   12449              :   /* GNU vectors can be initialized elementwise.  However, treat any
   12450              :      kind of vector value as initializing the vector type as a whole,
   12451              :      regardless of whether the value is a GNU vector.  Such initializers
   12452              :      are valid if and only if they would have been valid in a non-braced
   12453              :      initializer like:
   12454              : 
   12455              :         TYPE foo = VALUE;
   12456              : 
   12457              :      so recursing into the vector type would be at best confusing or at
   12458              :      worst wrong.  For example, when -flax-vector-conversions is in effect,
   12459              :      it's possible to initialize a V8HI from a V4SI, even though the vectors
   12460              :      have different element types and different numbers of elements.  */
   12461      3488445 :   if (gnu_vector_type_p (type))
   12462        19535 :     return !VECTOR_TYPE_P (value_type);
   12463              : 
   12464      3468910 :   if (AGGREGATE_TYPE_P (type))
   12465      1743202 :     return !comptypes (type, TYPE_MAIN_VARIANT (value_type));
   12466              : 
   12467              :   return false;
   12468              : }
   12469              : 
   12470              : /* Helper function for process_init_element.  Split first element of
   12471              :    RAW_DATA_CST and save the rest to *RAW_DATA.  */
   12472              : 
   12473              : static inline tree
   12474      9626387 : maybe_split_raw_data (tree value, tree *raw_data)
   12475              : {
   12476      9626387 :   if (value == NULL_TREE || TREE_CODE (value) != RAW_DATA_CST)
   12477              :     return value;
   12478          211 :   *raw_data = value;
   12479          211 :   value = build_int_cst (integer_type_node,
   12480          211 :                          RAW_DATA_UCHAR_ELT (*raw_data, 0));
   12481          211 :   ++RAW_DATA_POINTER (*raw_data);
   12482          211 :   --RAW_DATA_LENGTH (*raw_data);
   12483          211 :   return value;
   12484              : }
   12485              : 
   12486              : /* Return non-zero if c_parser_initval should attempt to optimize
   12487              :    large initializers into RAW_DATA_CST.  In that case return how
   12488              :    many elements to optimize at most.  */
   12489              : 
   12490              : unsigned
   12491      2993290 : c_maybe_optimize_large_byte_initializer (void)
   12492              : {
   12493      2993290 :   if (!constructor_type
   12494      2993220 :       || TREE_CODE (constructor_type) != ARRAY_TYPE
   12495       209761 :       || constructor_stack->implicit)
   12496              :     return 0;
   12497       206996 :   tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12498       206996 :   if (TREE_CODE (elttype) != INTEGER_TYPE
   12499       206996 :       && TREE_CODE (elttype) != BITINT_TYPE)
   12500              :     return 0;
   12501       184351 :   if (TYPE_PRECISION (elttype) != CHAR_BIT
   12502        27892 :       || constructor_stack->replacement_value.value
   12503        27892 :       || (COMPLETE_TYPE_P (constructor_type)
   12504        26247 :           && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   12505       212243 :       || constructor_range_stack)
   12506              :     return 0;
   12507        27892 :   if (constructor_max_index == NULL_TREE)
   12508              :     return INT_MAX;
   12509        26247 :   if (tree_int_cst_le (constructor_max_index, constructor_index)
   12510        26247 :       || integer_all_onesp (constructor_max_index))
   12511         4767 :     return 0;
   12512        21480 :   widest_int w = wi::to_widest (constructor_max_index);
   12513        21480 :   w -= wi::to_widest (constructor_index);
   12514        21480 :   w += 1;
   12515        21480 :   if (w < 64)
   12516              :     return 0;
   12517         6891 :   if (w > INT_MAX)
   12518              :     return INT_MAX;
   12519         6891 :   return w.to_uhwi ();
   12520        21480 : }
   12521              : 
   12522              : /* Add one non-braced element to the current constructor level.
   12523              :    This adjusts the current position within the constructor's type.
   12524              :    This may also start or terminate implicit levels
   12525              :    to handle a partly-braced initializer.
   12526              : 
   12527              :    Once this has found the correct level for the new element,
   12528              :    it calls output_init_element.
   12529              : 
   12530              :    IMPLICIT is true if value comes from pop_init_level (1),
   12531              :    the new initializer has been merged with the existing one
   12532              :    and thus no warnings should be emitted about overriding an
   12533              :    existing initializer.  */
   12534              : 
   12535              : void
   12536      9616682 : process_init_element (location_t loc, struct c_expr value, bool implicit,
   12537              :                       struct obstack * braced_init_obstack)
   12538              : {
   12539      9616682 :   tree orig_value = value.value;
   12540     19233364 :   int string_flag
   12541      9616682 :     = (orig_value != NULL_TREE && TREE_CODE (orig_value) == STRING_CST);
   12542      9616682 :   bool strict_string = value.original_code == STRING_CST;
   12543      9616682 :   bool was_designated = designator_depth != 0;
   12544      9616682 :   tree raw_data = NULL_TREE;
   12545              : 
   12546      9616894 : retry:
   12547      9616894 :   designator_depth = 0;
   12548      9616894 :   designator_erroneous = 0;
   12549              : 
   12550      9616894 :   if (!implicit && value.value && !integer_zerop (value.value))
   12551      7591980 :     constructor_zeroinit = 0;
   12552              : 
   12553              :   /* Handle superfluous braces around string cst as in
   12554              :      char x[] = {"foo"}; */
   12555      9616894 :   if (constructor_type
   12556      9616766 :       && !was_designated
   12557      9579894 :       && TREE_CODE (constructor_type) == ARRAY_TYPE
   12558      1706017 :       && INTEGRAL_TYPE_P (TREE_TYPE (constructor_type))
   12559     10353791 :       && integer_zerop (constructor_unfilled_index))
   12560              :     {
   12561       163176 :       if (constructor_stack->replacement_value.value)
   12562              :         {
   12563            8 :           error_init (loc, "excess elements in %qT initializer", constructor_type);
   12564          409 :           return;
   12565              :         }
   12566       163168 :       else if (string_flag)
   12567              :         {
   12568          138 :           constructor_stack->replacement_value = value;
   12569          138 :           return;
   12570              :         }
   12571              :     }
   12572              : 
   12573      9616748 :   if (constructor_stack->replacement_value.value != NULL_TREE)
   12574              :     {
   12575            0 :       error_init (loc, "excess elements in struct initializer");
   12576            0 :       return;
   12577              :     }
   12578              : 
   12579              :   /* Ignore elements of a brace group if it is entirely superfluous
   12580              :      and has already been diagnosed, or if the type is erroneous.  */
   12581      9616748 :   if (constructor_type == NULL_TREE || constructor_type == error_mark_node)
   12582              :     return;
   12583              : 
   12584              :   /* Ignore elements of an initializer for a variable-size type.
   12585              :      Those are diagnosed in the parser (empty initializer braces are OK).  */
   12586      9616551 :   if (COMPLETE_TYPE_P (constructor_type)
   12587      9616551 :       && !poly_int_tree_p (TYPE_SIZE (constructor_type)))
   12588              :     return;
   12589              : 
   12590      8911170 :   if (!implicit && warn_designated_init && !was_designated
   12591      8876616 :       && TREE_CODE (constructor_type) == RECORD_TYPE
   12592     10651684 :       && lookup_attribute ("designated_init",
   12593      1035191 :                            TYPE_ATTRIBUTES (constructor_type)))
   12594           50 :     warning_init (loc,
   12595              :                   OPT_Wdesignated_init,
   12596              :                   "positional initialization of field "
   12597              :                   "in %<struct%> declared with %<designated_init%> attribute");
   12598              : 
   12599              :   /* If we've exhausted any levels that didn't have braces,
   12600              :      pop them now.  */
   12601     10318472 :   while (constructor_stack->implicit)
   12602              :     {
   12603       708550 :       if (RECORD_OR_UNION_TYPE_P (constructor_type)
   12604       703711 :           && constructor_fields == NULL_TREE)
   12605       701738 :         process_init_element (loc,
   12606              :                               pop_init_level (loc, 1, braced_init_obstack,
   12607              :                                               last_init_list_comma),
   12608              :                               true, braced_init_obstack);
   12609         6812 :       else if ((TREE_CODE (constructor_type) == ARRAY_TYPE
   12610         2617 :                 || gnu_vector_type_p (constructor_type))
   12611         4839 :                && constructor_max_index
   12612        11624 :                && tree_int_cst_lt (constructor_max_index,
   12613              :                                    constructor_index))
   12614          241 :         process_init_element (loc,
   12615              :                               pop_init_level (loc, 1, braced_init_obstack,
   12616              :                                               last_init_list_comma),
   12617              :                               true, braced_init_obstack);
   12618              :       else
   12619              :         break;
   12620              :     }
   12621              : 
   12622              :   /* In the case of [LO ... HI] = VALUE, only evaluate VALUE once.  */
   12623      9616493 :   if (constructor_range_stack)
   12624              :     {
   12625              :       /* If value is a compound literal and we'll be just using its
   12626              :          content, don't put it into a SAVE_EXPR.  */
   12627          371 :       if (TREE_CODE (value.value) != COMPOUND_LITERAL_EXPR
   12628            3 :           || !require_constant_value)
   12629              :         {
   12630          368 :           tree semantic_type = NULL_TREE;
   12631          368 :           if (TREE_CODE (value.value) == EXCESS_PRECISION_EXPR)
   12632              :             {
   12633            0 :               semantic_type = TREE_TYPE (value.value);
   12634            0 :               value.value = TREE_OPERAND (value.value, 0);
   12635              :             }
   12636          368 :           value.value = save_expr (value.value);
   12637          368 :           if (semantic_type)
   12638            0 :             value.value = build1 (EXCESS_PRECISION_EXPR, semantic_type,
   12639              :                                   value.value);
   12640              :         }
   12641              :     }
   12642              : 
   12643     10330737 :   while (1)
   12644              :     {
   12645     10330737 :       if (TREE_CODE (constructor_type) == RECORD_TYPE)
   12646              :         {
   12647      1041301 :           tree fieldtype;
   12648      1041301 :           enum tree_code fieldcode;
   12649              : 
   12650      1041301 :           if (constructor_fields == NULL_TREE)
   12651              :             {
   12652         1280 :               pedwarn_init (loc, 0, "excess elements in struct initializer");
   12653         1280 :               break;
   12654              :             }
   12655              : 
   12656      1040021 :           fieldtype = TREE_TYPE (constructor_fields);
   12657      1040021 :           if (fieldtype != error_mark_node)
   12658      1040020 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   12659      1040021 :           fieldcode = TREE_CODE (fieldtype);
   12660              : 
   12661              :           /* Error for non-static initialization of a flexible array member.  */
   12662      1040021 :           if (fieldcode == ARRAY_TYPE
   12663       156026 :               && !require_constant_value
   12664         1892 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   12665      1040031 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   12666              :             {
   12667           10 :               error_init (loc, "non-static initialization of a flexible "
   12668              :                           "array member");
   12669           10 :               break;
   12670              :             }
   12671              : 
   12672              :           /* Error for initialization of a flexible array member with
   12673              :              a string constant if the structure is in an array.  E.g.:
   12674              :              struct S { int x; char y[]; };
   12675              :              struct S s[] = { { 1, "foo" } };
   12676              :              is invalid.  */
   12677      1040011 :           if (string_flag
   12678      1040011 :               && fieldcode == ARRAY_TYPE
   12679         3353 :               && constructor_depth > 1
   12680          489 :               && TYPE_SIZE (fieldtype) == NULL_TREE
   12681      1040058 :               && DECL_CHAIN (constructor_fields) == NULL_TREE)
   12682              :             {
   12683           47 :               bool in_array_p = false;
   12684           47 :               for (struct constructor_stack *p = constructor_stack;
   12685           73 :                    p && p->type; p = p->next)
   12686           59 :                 if (TREE_CODE (p->type) == ARRAY_TYPE)
   12687              :                   {
   12688              :                     in_array_p = true;
   12689              :                     break;
   12690              :                   }
   12691           47 :               if (in_array_p)
   12692              :                 {
   12693           33 :                   error_init (loc, "initialization of flexible array "
   12694              :                               "member in a nested context");
   12695           33 :                   break;
   12696              :                 }
   12697              :             }
   12698              : 
   12699              :           /* Accept a string constant to initialize a subarray.  */
   12700      1039978 :           if (value.value != NULL_TREE
   12701      1039905 :               && fieldcode == ARRAY_TYPE
   12702       155910 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   12703      1194585 :               && string_flag)
   12704              :             value.value = orig_value;
   12705              :           /* Otherwise, if we have come to a subaggregate,
   12706              :              and we don't have an element of its type, push into it.  */
   12707      1036962 :           else if (value.value != NULL_TREE
   12708      1036658 :                    && initialize_elementwise_p (fieldtype, value.value))
   12709              :             {
   12710          304 :               push_init_level (loc, 1, braced_init_obstack);
   12711          304 :               continue;
   12712              :             }
   12713              : 
   12714      1039674 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12715      1039674 :           if (value.value)
   12716              :             {
   12717      1039601 :               push_member_name (constructor_fields);
   12718      1039601 :               output_init_element (loc, value.value, value.original_type,
   12719              :                                    strict_string, fieldtype,
   12720              :                                    constructor_fields, true, implicit,
   12721              :                                    braced_init_obstack);
   12722      1039601 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12723              :             }
   12724              :           else
   12725              :             /* Do the bookkeeping for an element that was
   12726              :                directly output as a constructor.  */
   12727              :             {
   12728              :               /* For a record, keep track of end position of last field.  */
   12729           73 :               if (DECL_SIZE (constructor_fields))
   12730           30 :                 constructor_bit_index
   12731           30 :                   = size_binop_loc (input_location, PLUS_EXPR,
   12732              :                                     bit_position (constructor_fields),
   12733           30 :                                     DECL_SIZE (constructor_fields));
   12734              : 
   12735              :               /* If the current field was the first one not yet written out,
   12736              :                  it isn't now, so update.  */
   12737           73 :               if (constructor_unfilled_fields == constructor_fields)
   12738              :                 {
   12739           64 :                   constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   12740              :                   /* Skip any nameless bit fields.  */
   12741           64 :                   while (constructor_unfilled_fields != 0
   12742           64 :                          && (DECL_UNNAMED_BIT_FIELD
   12743              :                              (constructor_unfilled_fields)))
   12744            0 :                     constructor_unfilled_fields =
   12745            0 :                       DECL_CHAIN (constructor_unfilled_fields);
   12746              :                 }
   12747              :             }
   12748              : 
   12749      1039674 :           constructor_fields = DECL_CHAIN (constructor_fields);
   12750              :           /* Skip any nameless bit fields at the beginning.  */
   12751      1039674 :           while (constructor_fields != NULL_TREE
   12752      1039775 :                  && DECL_UNNAMED_BIT_FIELD (constructor_fields))
   12753          101 :             constructor_fields = DECL_CHAIN (constructor_fields);
   12754              :         }
   12755      9289436 :       else if (TREE_CODE (constructor_type) == UNION_TYPE)
   12756              :         {
   12757        31383 :           tree fieldtype;
   12758        31383 :           enum tree_code fieldcode;
   12759              : 
   12760        31383 :           if (constructor_fields == NULL_TREE)
   12761              :             {
   12762            3 :               pedwarn_init (loc, 0,
   12763              :                             "excess elements in union initializer");
   12764            3 :               break;
   12765              :             }
   12766              : 
   12767        31380 :           fieldtype = TREE_TYPE (constructor_fields);
   12768        31380 :           if (fieldtype != error_mark_node)
   12769        31380 :             fieldtype = TYPE_MAIN_VARIANT (fieldtype);
   12770        31380 :           fieldcode = TREE_CODE (fieldtype);
   12771              : 
   12772              :           /* Warn that traditional C rejects initialization of unions.
   12773              :              We skip the warning if the value is zero.  This is done
   12774              :              under the assumption that the zero initializer in user
   12775              :              code appears conditioned on e.g. __STDC__ to avoid
   12776              :              "missing initializer" warnings and relies on default
   12777              :              initialization to zero in the traditional C case.
   12778              :              We also skip the warning if the initializer is designated,
   12779              :              again on the assumption that this must be conditional on
   12780              :              __STDC__ anyway (and we've already complained about the
   12781              :              member-designator already).  */
   12782        33830 :           if (!in_system_header_at (input_location) && !constructor_designated
   12783        32931 :               && !(value.value && (integer_zerop (value.value)
   12784         1444 :                                    || real_zerop (value.value))))
   12785         1437 :             warning (OPT_Wtraditional, "traditional C rejects initialization "
   12786              :                      "of unions");
   12787              : 
   12788              :           /* Error for non-static initialization of a flexible array member.  */
   12789        31380 :           if (fieldcode == ARRAY_TYPE
   12790          766 :               && !require_constant_value
   12791        31437 :               && TYPE_SIZE (fieldtype) == NULL_TREE)
   12792              :             {
   12793            3 :               error_init (loc, "non-static initialization of a flexible "
   12794              :                           "array member");
   12795            3 :               break;
   12796              :             }
   12797              : 
   12798              :           /* Error for initialization of a flexible array member with
   12799              :              a string constant if the structure is in an array.  E.g.:
   12800              :              union U { int x; char y[]; };
   12801              :              union U s[] = { { 1, "foo" } };
   12802              :              is invalid.  */
   12803        31377 :           if (string_flag
   12804        31377 :               && fieldcode == ARRAY_TYPE
   12805            7 :               && constructor_depth > 1
   12806        31381 :               && TYPE_SIZE (fieldtype) == NULL_TREE)
   12807              :             {
   12808            3 :               bool in_array_p = false;
   12809            3 :               for (struct constructor_stack *p = constructor_stack;
   12810            3 :                    p && p->type; p = p->next)
   12811            3 :                 if (TREE_CODE (p->type) == ARRAY_TYPE)
   12812              :                   {
   12813              :                     in_array_p = true;
   12814              :                     break;
   12815              :                   }
   12816            3 :               if (in_array_p)
   12817              :                 {
   12818            3 :                   error_init (loc, "initialization of flexible array "
   12819              :                               "member in a nested context");
   12820            3 :                   break;
   12821              :                 }
   12822              :             }
   12823              : 
   12824              :           /* Accept a string constant to initialize a subarray.  */
   12825        31374 :           if (value.value != NULL_TREE
   12826        31374 :               && fieldcode == ARRAY_TYPE
   12827          760 :               && INTEGRAL_TYPE_P (TREE_TYPE (fieldtype))
   12828        32129 :               && string_flag)
   12829              :             value.value = orig_value;
   12830              :           /* Otherwise, if we have come to a subaggregate,
   12831              :              and we don't have an element of its type, push into it.  */
   12832        31420 :           else if (value.value != NULL_TREE
   12833        31370 :                    && initialize_elementwise_p (fieldtype, value.value))
   12834              :             {
   12835           50 :               push_init_level (loc, 1, braced_init_obstack);
   12836           50 :               continue;
   12837              :             }
   12838              : 
   12839        31324 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12840        31324 :           if (value.value)
   12841              :             {
   12842        31324 :               push_member_name (constructor_fields);
   12843        31324 :               output_init_element (loc, value.value, value.original_type,
   12844              :                                    strict_string, fieldtype,
   12845              :                                    constructor_fields, true, implicit,
   12846              :                                    braced_init_obstack);
   12847        31324 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12848              :             }
   12849              :           else
   12850              :             /* Do the bookkeeping for an element that was
   12851              :                directly output as a constructor.  */
   12852              :             {
   12853            0 :               constructor_bit_index = DECL_SIZE (constructor_fields);
   12854            0 :               constructor_unfilled_fields = DECL_CHAIN (constructor_fields);
   12855              :             }
   12856              : 
   12857        31324 :           constructor_fields = NULL_TREE;
   12858              :         }
   12859      9258053 :       else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
   12860              :         {
   12861      2421294 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12862      2421294 :           enum tree_code eltcode = TREE_CODE (elttype);
   12863              : 
   12864              :           /* Accept a string constant to initialize a subarray.  */
   12865      2421294 :           if (value.value != NULL_TREE
   12866      2421294 :               && eltcode == ARRAY_TYPE
   12867         7031 :               && INTEGRAL_TYPE_P (TREE_TYPE (elttype))
   12868      2426842 :               && string_flag)
   12869              :             value.value = orig_value;
   12870              :           /* Otherwise, if we have come to a subaggregate,
   12871              :              and we don't have an element of its type, push into it.  */
   12872      3123124 :           else if (value.value != NULL_TREE
   12873      2420798 :                    && initialize_elementwise_p (elttype, value.value))
   12874              :             {
   12875       702326 :               push_init_level (loc, 1, braced_init_obstack);
   12876       702326 :               continue;
   12877              :             }
   12878              : 
   12879      1718968 :           if (constructor_max_index != NULL_TREE
   12880       676106 :               && (tree_int_cst_lt (constructor_max_index, constructor_index)
   12881       675991 :                   || integer_all_onesp (constructor_max_index))
   12882              :               /* For VLA we got an error already.  */
   12883      1719083 :               && !C_TYPE_VARIABLE_SIZE (constructor_type))
   12884              :             {
   12885          113 :               pedwarn_init (loc, 0,
   12886              :                             "excess elements in array initializer");
   12887          113 :               break;
   12888              :             }
   12889              : 
   12890      1718855 :           if (value.value
   12891      1718855 :               && TREE_CODE (value.value) == RAW_DATA_CST
   12892          194 :               && RAW_DATA_LENGTH (value.value) > 1
   12893          194 :               && (TREE_CODE (elttype) == INTEGER_TYPE
   12894          194 :                   || TREE_CODE (elttype) == BITINT_TYPE)
   12895          194 :               && TYPE_PRECISION (elttype) == CHAR_BIT
   12896      1719049 :               && (constructor_max_index == NULL_TREE
   12897           56 :                   || tree_int_cst_lt (constructor_index,
   12898              :                                       constructor_max_index)))
   12899              :             {
   12900          194 :               unsigned int len = RAW_DATA_LENGTH (value.value);
   12901          194 :               if (constructor_max_index)
   12902              :                 {
   12903           56 :                   widest_int w = wi::to_widest (constructor_max_index);
   12904           56 :                   w -= wi::to_widest (constructor_index);
   12905           56 :                   w += 1;
   12906           56 :                   if (w < len)
   12907            3 :                     len = w.to_uhwi ();
   12908           56 :                 }
   12909          194 :               if (len < (unsigned) RAW_DATA_LENGTH (value.value))
   12910              :                 {
   12911            3 :                   raw_data = copy_node (value.value);
   12912            3 :                   RAW_DATA_LENGTH (raw_data) -= len;
   12913            3 :                   RAW_DATA_POINTER (raw_data) += len;
   12914            3 :                   RAW_DATA_LENGTH (value.value) = len;
   12915              :                 }
   12916          194 :               TREE_TYPE (value.value) = elttype;
   12917          194 :               push_array_bounds (tree_to_uhwi (constructor_index));
   12918          194 :               output_init_element (loc, value.value, value.original_type,
   12919              :                                    false, elttype, constructor_index, true,
   12920              :                                    implicit, braced_init_obstack);
   12921          194 :               RESTORE_SPELLING_DEPTH (constructor_depth);
   12922          194 :               constructor_index
   12923          194 :                 = size_binop_loc (input_location, PLUS_EXPR,
   12924          194 :                                   constructor_index, bitsize_int (len));
   12925              :             }
   12926              :           else
   12927              :             {
   12928      1718661 :               value.value = maybe_split_raw_data (value.value, &raw_data);
   12929              :               /* Now output the actual element.  */
   12930      1718661 :               if (value.value)
   12931              :                 {
   12932      1718661 :                   push_array_bounds (tree_to_uhwi (constructor_index));
   12933      1718661 :                   output_init_element (loc, value.value, value.original_type,
   12934              :                                        strict_string, elttype,
   12935              :                                        constructor_index, true, implicit,
   12936              :                                        braced_init_obstack);
   12937      1718661 :                   RESTORE_SPELLING_DEPTH (constructor_depth);
   12938              :                 }
   12939              : 
   12940      1718661 :               constructor_index
   12941      1718661 :                 = size_binop_loc (input_location, PLUS_EXPR,
   12942              :                                   constructor_index, bitsize_one_node);
   12943              : 
   12944      1718661 :               if (!value.value)
   12945              :                 /* If we are doing the bookkeeping for an element that was
   12946              :                    directly output as a constructor, we must update
   12947              :                    constructor_unfilled_index.  */
   12948            0 :                 constructor_unfilled_index = constructor_index;
   12949              :             }
   12950              :         }
   12951      6836759 :       else if (gnu_vector_type_p (constructor_type))
   12952              :         {
   12953      6836267 :           tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
   12954              : 
   12955              :           /* Do a basic check of initializer size.  Note that vectors
   12956              :              may not always have a fixed size derived from their type.  */
   12957      6836267 :           if (maybe_lt (tree_to_poly_uint64 (constructor_max_index),
   12958      6836267 :                         tree_to_poly_uint64 (constructor_index)))
   12959              :             {
   12960              :               /* Diagose VLA out-of-bounds as errors.  */
   12961            2 :               if (tree_to_poly_uint64 (constructor_max_index).is_constant())
   12962            2 :                 pedwarn_init (loc, 0,
   12963              :                               "excess elements in vector initializer");
   12964              :               else
   12965              :                 error_init (loc, "excess elements in vector initializer");
   12966              : 
   12967              :               break;
   12968              :             }
   12969              : 
   12970      6836265 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   12971              :           /* Now output the actual element.  */
   12972      6836265 :           if (value.value)
   12973              :             {
   12974      6836265 :               if (TREE_CODE (value.value) == VECTOR_CST)
   12975            0 :                 elttype = TYPE_MAIN_VARIANT (constructor_type);
   12976      6836265 :               output_init_element (loc, value.value, value.original_type,
   12977              :                                    strict_string, elttype,
   12978              :                                    constructor_index, true, implicit,
   12979              :                                    braced_init_obstack);
   12980              :             }
   12981              : 
   12982      6836265 :           constructor_index
   12983      6836265 :             = size_binop_loc (input_location,
   12984              :                               PLUS_EXPR, constructor_index, bitsize_one_node);
   12985              : 
   12986      6836265 :           if (!value.value)
   12987              :             /* If we are doing the bookkeeping for an element that was
   12988              :                directly output as a constructor, we must update
   12989              :                constructor_unfilled_index.  */
   12990            0 :             constructor_unfilled_index = constructor_index;
   12991              :         }
   12992              : 
   12993              :       /* Handle the sole element allowed in a braced initializer
   12994              :          for a scalar variable.  */
   12995          492 :       else if (constructor_type != error_mark_node
   12996          492 :                && constructor_fields == NULL_TREE)
   12997              :         {
   12998           29 :           pedwarn_init (loc, 0,
   12999              :                         "excess elements in scalar initializer");
   13000           29 :           break;
   13001              :         }
   13002              :       else
   13003              :         {
   13004          463 :           value.value = maybe_split_raw_data (value.value, &raw_data);
   13005          463 :           if (value.value)
   13006          463 :             output_init_element (loc, value.value, value.original_type,
   13007              :                                  strict_string, constructor_type,
   13008              :                                  NULL_TREE, true, implicit,
   13009              :                                  braced_init_obstack);
   13010          463 :           constructor_fields = NULL_TREE;
   13011              :         }
   13012              : 
   13013              :       /* Handle range initializers either at this level or anywhere higher
   13014              :          in the designator stack.  */
   13015      9626581 :       if (constructor_range_stack)
   13016              :         {
   13017        11564 :           struct constructor_range_stack *p, *range_stack;
   13018        11564 :           int finish = 0;
   13019              : 
   13020        11564 :           range_stack = constructor_range_stack;
   13021        11564 :           constructor_range_stack = 0;
   13022        11564 :           while (constructor_stack != range_stack->stack)
   13023              :             {
   13024            0 :               gcc_assert (constructor_stack->implicit);
   13025            0 :               process_init_element (loc,
   13026              :                                     pop_init_level (loc, 1,
   13027              :                                                     braced_init_obstack,
   13028              :                                                     last_init_list_comma),
   13029              :                                     true, braced_init_obstack);
   13030              :             }
   13031          325 :           for (p = range_stack;
   13032        11889 :                !p->range_end || tree_int_cst_equal (p->index, p->range_end);
   13033          325 :                p = p->prev)
   13034              :             {
   13035          325 :               gcc_assert (constructor_stack->implicit);
   13036          325 :               process_init_element (loc,
   13037              :                                     pop_init_level (loc, 1,
   13038              :                                                     braced_init_obstack,
   13039              :                                                     last_init_list_comma),
   13040              :                                     true, braced_init_obstack);
   13041              :             }
   13042              : 
   13043        11564 :           p->index = size_binop_loc (input_location,
   13044              :                                      PLUS_EXPR, p->index, bitsize_one_node);
   13045        11564 :           if (tree_int_cst_equal (p->index, p->range_end) && !p->prev)
   13046          379 :             finish = 1;
   13047              : 
   13048        11889 :           while (1)
   13049              :             {
   13050        11889 :               constructor_index = p->index;
   13051        11889 :               constructor_fields = p->fields;
   13052        11889 :               if (finish && p->range_end && p->index == p->range_start)
   13053              :                 {
   13054            8 :                   finish = 0;
   13055            8 :                   p->prev = 0;
   13056              :                 }
   13057        11889 :               p = p->next;
   13058        11889 :               if (!p)
   13059              :                 break;
   13060          325 :               finish_implicit_inits (loc, braced_init_obstack);
   13061          325 :               push_init_level (loc, 2, braced_init_obstack);
   13062          325 :               p->stack = constructor_stack;
   13063          325 :               if (p->range_end && tree_int_cst_equal (p->index, p->range_end))
   13064           33 :                 p->index = p->range_start;
   13065              :             }
   13066              : 
   13067        11564 :           if (!finish)
   13068        11193 :             constructor_range_stack = range_stack;
   13069        11564 :           continue;
   13070        11564 :         }
   13071              : 
   13072              :       break;
   13073              :     }
   13074              : 
   13075      9616493 :   constructor_range_stack = 0;
   13076              : 
   13077      9616493 :   if (raw_data && RAW_DATA_LENGTH (raw_data))
   13078              :     {
   13079          212 :       gcc_assert (!string_flag && !was_designated);
   13080          212 :       value.value = raw_data;
   13081          212 :       raw_data = NULL_TREE;
   13082          212 :       goto retry;
   13083              :     }
   13084              : }
   13085              : 
   13086              : /* Build a complete asm-statement, whose components are a CV_QUALIFIER
   13087              :    (guaranteed to be 'volatile' or null) and ARGS (represented using
   13088              :    an ASM_EXPR node).  */
   13089              : tree
   13090       205275 : build_asm_stmt (bool is_volatile, tree args)
   13091              : {
   13092       205275 :   if (is_volatile)
   13093       165452 :     ASM_VOLATILE_P (args) = 1;
   13094       205275 :   return add_stmt (args);
   13095              : }
   13096              : 
   13097              : /* Build an asm-expr, whose components are a STRING, some OUTPUTS,
   13098              :    some INPUTS, and some CLOBBERS.  The latter three may be NULL.
   13099              :    SIMPLE indicates whether there was anything at all after the
   13100              :    string in the asm expression -- asm("blah") and asm("blah" : )
   13101              :    are subtly different.  We use a ASM_EXPR node to represent this.
   13102              :    LOC is the location of the asm, and IS_INLINE says whether this
   13103              :    is asm inline.  */
   13104              : tree
   13105       205327 : build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
   13106              :                 tree clobbers, tree labels, bool simple, bool is_inline)
   13107              : {
   13108       205327 :   tree tail;
   13109       205327 :   tree args;
   13110       205327 :   int i;
   13111       205327 :   const char *constraint;
   13112       205327 :   const char **oconstraints;
   13113       205327 :   bool allows_mem, allows_reg, is_inout;
   13114       205327 :   int ninputs, noutputs;
   13115              : 
   13116       205327 :   ninputs = list_length (inputs);
   13117       205327 :   noutputs = list_length (outputs);
   13118       205327 :   oconstraints = (const char **) alloca (noutputs * sizeof (const char *));
   13119              : 
   13120       205327 :   string = resolve_asm_operand_names (string, outputs, inputs, labels);
   13121              : 
   13122              :   /* Remove output conversions that change the type but not the mode.  */
   13123       555351 :   for (i = 0, tail = outputs; tail; ++i, tail = TREE_CHAIN (tail))
   13124              :     {
   13125       350024 :       tree output = TREE_VALUE (tail);
   13126              : 
   13127       350024 :       output = c_fully_fold (output, false, NULL, true);
   13128              : 
   13129              :       /* ??? Really, this should not be here.  Users should be using a
   13130              :          proper lvalue, dammit.  But there's a long history of using casts
   13131              :          in the output operands.  In cases like longlong.h, this becomes a
   13132              :          primitive form of typechecking -- if the cast can be removed, then
   13133              :          the output operand had a type of the proper width; otherwise we'll
   13134              :          get an error.  Gross, but ...  */
   13135       350024 :       STRIP_NOPS (output);
   13136              : 
   13137       350024 :       if (!lvalue_or_else (loc, output, lv_asm))
   13138            4 :         output = error_mark_node;
   13139              : 
   13140       350024 :       if (output != error_mark_node
   13141       350024 :           && (TREE_READONLY (output)
   13142       350017 :               || TYPE_READONLY (TREE_TYPE (output))
   13143       350017 :               || (RECORD_OR_UNION_TYPE_P (TREE_TYPE (output))
   13144          112 :                   && C_TYPE_FIELDS_READONLY (TREE_TYPE (output)))))
   13145            2 :         readonly_error (loc, output, lv_asm);
   13146              : 
   13147       350024 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   13148       350024 :       oconstraints[i] = constraint;
   13149              : 
   13150       350024 :       if (parse_output_constraint (&constraint, i, ninputs, noutputs,
   13151              :                                    &allows_mem, &allows_reg, &is_inout,
   13152              :                                    nullptr))
   13153              :         {
   13154              :           /* If the operand is going to end up in memory,
   13155              :              mark it addressable.  */
   13156       350016 :           if (!allows_reg && !c_mark_addressable (output))
   13157            3 :             output = error_mark_node;
   13158         1422 :           if (!(!allows_reg && allows_mem)
   13159       348594 :               && output != error_mark_node
   13160       698608 :               && VOID_TYPE_P (TREE_TYPE (output)))
   13161              :             {
   13162            4 :               error_at (loc, "invalid use of void expression");
   13163            4 :               output = error_mark_node;
   13164              :             }
   13165       350016 :           if (allows_reg && current_function_decl == NULL_TREE)
   13166              :             {
   13167            1 :               error_at (loc, "constraint allows registers outside of "
   13168              :                              "a function");
   13169            1 :               output = error_mark_node;
   13170              :             }
   13171              :         }
   13172              :       else
   13173            8 :         output = error_mark_node;
   13174              : 
   13175       350024 :       if (current_function_decl == NULL_TREE && output != error_mark_node)
   13176              :         {
   13177            7 :           if (TREE_SIDE_EFFECTS (output))
   13178              :             {
   13179            0 :               error_at (loc, "side-effects in output operand outside "
   13180              :                              "of a function");
   13181            0 :               output = error_mark_node;
   13182              :             }
   13183              :           else
   13184              :             {
   13185            7 :               tree addr = build_unary_op (loc, ADDR_EXPR, output, false);
   13186            7 :               if (addr == error_mark_node)
   13187              :                 output = error_mark_node;
   13188            7 :               else if (!initializer_constant_valid_p (addr, TREE_TYPE (addr)))
   13189              :                 {
   13190            1 :                   error_at (loc, "output operand outside of a function is not "
   13191              :                                  "constant");
   13192            1 :                   output = error_mark_node;
   13193              :                 }
   13194              :             }
   13195              :         }
   13196       350017 :       else if (output != error_mark_node && strstr (constraint, "-"))
   13197              :         {
   13198            1 :           error_at (loc, "%<-%> modifier used inside of a function");
   13199            1 :           output = error_mark_node;
   13200              :         }
   13201              : 
   13202       350024 :       TREE_VALUE (tail) = output;
   13203              :     }
   13204              : 
   13205       570387 :   for (i = 0, tail = inputs; tail; ++i, tail = TREE_CHAIN (tail))
   13206              :     {
   13207       365060 :       tree input;
   13208              : 
   13209       365060 :       constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (tail)));
   13210       365060 :       input = TREE_VALUE (tail);
   13211              : 
   13212       365060 :       if (parse_input_constraint (&constraint, i, ninputs, noutputs, 0,
   13213              :                                   oconstraints, &allows_mem, &allows_reg,
   13214              :                                   nullptr))
   13215              :         {
   13216              :           /* If the operand is going to end up in memory,
   13217              :              mark it addressable.  */
   13218       365052 :           if (!allows_reg && allows_mem)
   13219              :             {
   13220         1370 :               input = c_fully_fold (input, false, NULL, true);
   13221              : 
   13222              :               /* Strip the nops as we allow this case.  FIXME, this really
   13223              :                  should be rejected or made deprecated.  */
   13224         1370 :               STRIP_NOPS (input);
   13225         1370 :               if (!c_mark_addressable (input))
   13226            2 :                 input = error_mark_node;
   13227              :             }
   13228              :           else
   13229              :             {
   13230       363682 :               input = c_fully_fold (convert_lvalue_to_rvalue (loc, input,
   13231              :                                                               true, false),
   13232              :                                     false, NULL);
   13233              : 
   13234       363682 :               if (input != error_mark_node && VOID_TYPE_P (TREE_TYPE (input)))
   13235              :                 {
   13236            4 :                   error_at (loc, "invalid use of void expression");
   13237            4 :                   input = error_mark_node;
   13238              :                 }
   13239              :             }
   13240       365052 :           if (allows_reg && current_function_decl == NULL_TREE)
   13241              :             {
   13242            1 :               error_at (loc, "constraint allows registers outside of "
   13243              :                              "a function");
   13244            1 :               input = error_mark_node;
   13245              :             }
   13246       365052 :           if (constraint[0] == ':' && input != error_mark_node)
   13247              :             {
   13248           35 :               tree t = input;
   13249           35 :               STRIP_NOPS (t);
   13250           35 :               if (TREE_CODE (t) != ADDR_EXPR
   13251           35 :                   || !(TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL
   13252           23 :                        || (VAR_P (TREE_OPERAND (t, 0))
   13253           21 :                            && is_global_var (TREE_OPERAND (t, 0)))))
   13254              :                 {
   13255            5 :                   error_at (loc, "%<:%> constraint operand is not address "
   13256              :                                  "of a function or non-automatic variable");
   13257            5 :                   input = error_mark_node;
   13258              :                 }
   13259           30 :               else if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL)
   13260           10 :                 suppress_warning (TREE_OPERAND (t, 0), OPT_Wunused);
   13261              :             }
   13262              :         }
   13263              :       else
   13264            8 :         input = error_mark_node;
   13265              : 
   13266       365060 :       if (current_function_decl == NULL_TREE && input != error_mark_node)
   13267              :         {
   13268           58 :           if (TREE_SIDE_EFFECTS (input))
   13269              :             {
   13270            2 :               error_at (loc, "side-effects in input operand outside "
   13271              :                              "of a function");
   13272            2 :               input = error_mark_node;
   13273              :             }
   13274              :           else
   13275              :             {
   13276           56 :               tree tem = input;
   13277           56 :               if (allows_mem && lvalue_p (input))
   13278            7 :                 tem = build_unary_op (loc, ADDR_EXPR, input, false);
   13279           56 :               if (!initializer_constant_valid_p (tem, TREE_TYPE (tem)))
   13280              :                 {
   13281            2 :                   error_at (loc, "input operand outside of a function is not "
   13282              :                                  "constant");
   13283            2 :                   input = error_mark_node;
   13284              :                 }
   13285              :             }
   13286              :         }
   13287       365002 :       else if (input != error_mark_node && strstr (constraint, "-"))
   13288              :         {
   13289            3 :           error_at (loc, "%<-%> modifier used inside of a function");
   13290            3 :           input = error_mark_node;
   13291              :         }
   13292              : 
   13293       365060 :       TREE_VALUE (tail) = input;
   13294              :     }
   13295              : 
   13296       205327 :   args = build_stmt (loc, ASM_EXPR, string, outputs, inputs, clobbers, labels);
   13297              : 
   13298              :   /* asm statements without outputs, including simple ones, are treated
   13299              :      as volatile.  */
   13300       205327 :   ASM_BASIC_P (args) = simple;
   13301       205327 :   ASM_VOLATILE_P (args) = (noutputs == 0);
   13302       205327 :   ASM_INLINE_P (args) = is_inline;
   13303              : 
   13304       205327 :   return args;
   13305              : }
   13306              : 
   13307              : /* Generate a goto statement to LABEL.  LOC is the location of the
   13308              :    GOTO.  */
   13309              : 
   13310              : tree
   13311        83015 : c_finish_goto_label (location_t loc, tree label)
   13312              : {
   13313        83015 :   tree decl = lookup_label_for_goto (loc, label);
   13314        83015 :   if (!decl)
   13315              :     return NULL_TREE;
   13316        83015 :   TREE_USED (decl) = 1;
   13317        83015 :   mark_decl_used (decl, false);
   13318        83015 :   {
   13319        83015 :     add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN));
   13320        83015 :     tree t = build1 (GOTO_EXPR, void_type_node, decl);
   13321        83015 :     SET_EXPR_LOCATION (t, loc);
   13322        83015 :     return add_stmt (t);
   13323              :   }
   13324              : }
   13325              : 
   13326              : /* Generate a computed goto statement to EXPR.  LOC is the location of
   13327              :    the GOTO.  */
   13328              : 
   13329              : tree
   13330          949 : c_finish_goto_ptr (location_t loc, c_expr val)
   13331              : {
   13332          949 :   tree expr = val.value;
   13333          949 :   tree t;
   13334          949 :   pedwarn (loc, OPT_Wpedantic, "ISO C forbids %<goto *expr;%>");
   13335          949 :   if (expr != error_mark_node
   13336          948 :       && !POINTER_TYPE_P (TREE_TYPE (expr))
   13337          954 :       && !null_pointer_constant_p (expr))
   13338              :     {
   13339            2 :       error_at (val.get_location (),
   13340              :                 "computed goto must be pointer type");
   13341            2 :       expr = build_zero_cst (ptr_type_node);
   13342              :     }
   13343          949 :   expr = c_fully_fold (expr, false, NULL);
   13344          949 :   expr = convert (ptr_type_node, expr);
   13345          949 :   t = build1 (GOTO_EXPR, void_type_node, expr);
   13346          949 :   SET_EXPR_LOCATION (t, loc);
   13347          949 :   return add_stmt (t);
   13348              : }
   13349              : 
   13350              : /* Generate a C `return' statement.  RETVAL is the expression for what
   13351              :    to return, or a null pointer for `return;' with no value.  LOC is
   13352              :    the location of the return statement, or the location of the expression,
   13353              :    if the statement has any.  If ORIGTYPE is not NULL_TREE, it
   13354              :    is the original type of RETVAL.  MUSTTAIL_P indicates a musttail
   13355              :    attribute.  */
   13356              : 
   13357              : tree
   13358     34661748 : c_finish_return (location_t loc, tree retval, tree origtype, bool musttail_p)
   13359              : {
   13360     34661748 :   tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
   13361     34661748 :   bool no_warning = false;
   13362     34661748 :   bool npc = false;
   13363              : 
   13364              :   /* Use the expansion point to handle cases such as returning NULL
   13365              :      in a function returning void.  */
   13366     34661748 :   location_t xloc = expansion_point_location_if_in_system_header (loc);
   13367              : 
   13368     34661748 :   if (TREE_THIS_VOLATILE (current_function_decl))
   13369           23 :     warning_at (xloc, 0,
   13370              :                 "function declared %<noreturn%> has a %<return%> statement");
   13371              : 
   13372     34661748 :   set_musttail_on_return (retval, xloc, musttail_p);
   13373              : 
   13374     34661748 :   if (retval)
   13375              :     {
   13376     34640318 :       tree semantic_type = NULL_TREE;
   13377     34640318 :       npc = null_pointer_constant_p (retval);
   13378     34640318 :       if (TREE_CODE (retval) == EXCESS_PRECISION_EXPR)
   13379              :         {
   13380           92 :           semantic_type = TREE_TYPE (retval);
   13381           92 :           retval = TREE_OPERAND (retval, 0);
   13382              :         }
   13383     34640318 :       retval = c_fully_fold (retval, false, NULL);
   13384     34640318 :       if (semantic_type
   13385     34640318 :           && valtype != NULL_TREE
   13386           92 :           && TREE_CODE (valtype) != VOID_TYPE)
   13387           92 :         retval = build1 (EXCESS_PRECISION_EXPR, semantic_type, retval);
   13388              :     }
   13389              : 
   13390     34640318 :   if (!retval)
   13391              :     {
   13392        21430 :       current_function_returns_null = 1;
   13393        21430 :       if ((warn_return_type >= 0 || flag_isoc99)
   13394        21305 :           && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE)
   13395              :         {
   13396           46 :           no_warning = true;
   13397           47 :           if (emit_diagnostic (flag_isoc99
   13398              :                                ? diagnostics::kind::permerror
   13399              :                                : diagnostics::kind::warning,
   13400           46 :                                loc, OPT_Wreturn_mismatch,
   13401              :                                "%<return%> with no value,"
   13402              :                                " in function returning non-void"))
   13403           27 :             inform (DECL_SOURCE_LOCATION (current_function_decl),
   13404              :                     "declared here");
   13405              :         }
   13406              :     }
   13407     34640318 :   else if (valtype == NULL_TREE || VOID_TYPE_P (valtype))
   13408              :     {
   13409          322 :       current_function_returns_null = 1;
   13410          322 :       bool warned_here;
   13411          322 :       if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
   13412           64 :         warned_here = permerror_opt
   13413           64 :           (xloc, OPT_Wreturn_mismatch,
   13414              :            "%<return%> with a value, in function returning void");
   13415              :       else
   13416          258 :         warned_here = pedwarn
   13417          258 :           (xloc, OPT_Wpedantic, "ISO C forbids "
   13418              :            "%<return%> with expression, in function returning void");
   13419          322 :       if (warned_here)
   13420           43 :         inform (DECL_SOURCE_LOCATION (current_function_decl),
   13421              :                 "declared here");
   13422              :     }
   13423              :   else
   13424              :     {
   13425     34639996 :       tree t = convert_for_assignment (loc, UNKNOWN_LOCATION, valtype,
   13426              :                                        retval, origtype, ic_return,
   13427              :                                        npc, NULL_TREE, NULL_TREE, 0);
   13428     34639996 :       tree res = DECL_RESULT (current_function_decl);
   13429     34639996 :       tree inner;
   13430     34639996 :       bool save;
   13431              : 
   13432     34639996 :       current_function_returns_value = 1;
   13433     34639996 :       if (t == error_mark_node)
   13434              :         {
   13435              :           /* Suppress -Wreturn-type for this function.  */
   13436          299 :           if (warn_return_type)
   13437          298 :             suppress_warning (current_function_decl, OPT_Wreturn_type);
   13438          299 :           return NULL_TREE;
   13439              :         }
   13440              : 
   13441     34639697 :       save = in_late_binary_op;
   13442     69271229 :       if (C_BOOLEAN_TYPE_P (TREE_TYPE (res))
   13443     34630727 :           || TREE_CODE (TREE_TYPE (res)) == COMPLEX_TYPE
   13444     69269144 :           || (SCALAR_FLOAT_TYPE_P (TREE_TYPE (t))
   13445       333472 :               && (TREE_CODE (TREE_TYPE (res)) == INTEGER_TYPE
   13446       333472 :                   || TREE_CODE (TREE_TYPE (res)) == ENUMERAL_TYPE)
   13447            0 :               && sanitize_flags_p (SANITIZE_FLOAT_CAST)))
   13448        10250 :         in_late_binary_op = true;
   13449     34639697 :       inner = t = convert (TREE_TYPE (res), t);
   13450     34639697 :       in_late_binary_op = save;
   13451              : 
   13452              :       /* Strip any conversions, additions, and subtractions, and see if
   13453              :          we are returning the address of a local variable.  Warn if so.  */
   13454     37918603 :       while (1)
   13455              :         {
   13456     37918603 :           switch (TREE_CODE (inner))
   13457              :             {
   13458      3277480 :             CASE_CONVERT:
   13459      3277480 :             case NON_LVALUE_EXPR:
   13460      3277480 :             case PLUS_EXPR:
   13461      3277480 :             case POINTER_PLUS_EXPR:
   13462      3277480 :               inner = TREE_OPERAND (inner, 0);
   13463      3277480 :               continue;
   13464              : 
   13465         1431 :             case MINUS_EXPR:
   13466              :               /* If the second operand of the MINUS_EXPR has a pointer
   13467              :                  type (or is converted from it), this may be valid, so
   13468              :                  don't give a warning.  */
   13469         1431 :               {
   13470         1431 :                 tree op1 = TREE_OPERAND (inner, 1);
   13471              : 
   13472         3111 :                 while (!POINTER_TYPE_P (TREE_TYPE (op1))
   13473         3365 :                        && (CONVERT_EXPR_P (op1)
   13474         1426 :                            || TREE_CODE (op1) == NON_LVALUE_EXPR))
   13475          254 :                   op1 = TREE_OPERAND (op1, 0);
   13476              : 
   13477         1431 :                 if (POINTER_TYPE_P (TREE_TYPE (op1)))
   13478              :                   break;
   13479              : 
   13480         1426 :                 inner = TREE_OPERAND (inner, 0);
   13481         1426 :                 continue;
   13482         1426 :               }
   13483              : 
   13484         2936 :             case ADDR_EXPR:
   13485         2936 :               inner = TREE_OPERAND (inner, 0);
   13486              : 
   13487         2936 :               while (REFERENCE_CLASS_P (inner)
   13488         3822 :                      && !INDIRECT_REF_P (inner))
   13489          886 :                 inner = TREE_OPERAND (inner, 0);
   13490              : 
   13491         2936 :               if (DECL_P (inner)
   13492         1613 :                   && !DECL_EXTERNAL (inner)
   13493          978 :                   && DECL_CONTEXT (inner) == current_function_decl
   13494         3158 :                   && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (current_function_decl))))
   13495              :                 {
   13496          182 :                   if (TREE_CODE (inner) == LABEL_DECL)
   13497            4 :                     warning_at (loc, OPT_Wreturn_local_addr,
   13498              :                                 "function returns address of label");
   13499          178 :                   else if (TREE_CODE (inner) == FUNCTION_DECL
   13500          178 :                            && (C_FUNC_NONLOCAL_CONTEXT (inner)
   13501            9 :                                || !DECL_INITIAL (inner)))
   13502           14 :                     warning_at (loc, OPT_Wreturn_local_addr,
   13503              :                                 "function returns address of nested function "
   13504              :                                 "referencing local context");
   13505          164 :                   else if (TREE_CODE (inner) != FUNCTION_DECL
   13506          156 :                            && !TREE_STATIC (inner))
   13507              :                     {
   13508            9 :                       warning_at (loc, OPT_Wreturn_local_addr,
   13509              :                                   "function returns address of local variable");
   13510            9 :                       tree zero = build_zero_cst (TREE_TYPE (res));
   13511            9 :                       t = build2 (COMPOUND_EXPR, TREE_TYPE (res), t, zero);
   13512              :                     }
   13513              :                 }
   13514              :               break;
   13515              : 
   13516              :             default:
   13517              :               break;
   13518      3277480 :             }
   13519              : 
   13520     34639697 :           break;
   13521              :         }
   13522              : 
   13523     34639697 :       retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, t);
   13524     34639697 :       SET_EXPR_LOCATION (retval, loc);
   13525              : 
   13526     34639697 :       if (warn_sequence_point)
   13527      2965932 :         verify_sequence_points (retval);
   13528              :     }
   13529              : 
   13530     34661449 :   ret_stmt = build_stmt (loc, RETURN_EXPR, retval);
   13531     34661449 :   if (no_warning)
   13532           46 :     suppress_warning (ret_stmt, OPT_Wreturn_type);
   13533     34661449 :   return add_stmt (ret_stmt);
   13534              : }
   13535              : 
   13536              : struct c_switch {
   13537              :   /* The SWITCH_STMT being built.  */
   13538              :   tree switch_stmt;
   13539              : 
   13540              :   /* The original type of the testing expression, i.e. before the
   13541              :      default conversion is applied.  */
   13542              :   tree orig_type;
   13543              : 
   13544              :   /* A splay-tree mapping the low element of a case range to the high
   13545              :      element, or NULL_TREE if there is no high element.  Used to
   13546              :      determine whether or not a new case label duplicates an old case
   13547              :      label.  We need a tree, rather than simply a hash table, because
   13548              :      of the GNU case range extension.  */
   13549              :   splay_tree cases;
   13550              : 
   13551              :   /* The bindings at the point of the switch.  This is used for
   13552              :      warnings crossing decls when branching to a case label.  */
   13553              :   struct c_spot_bindings *bindings;
   13554              : 
   13555              :   /* Whether the switch includes any break statements.  */
   13556              :   bool break_stmt_seen_p;
   13557              : 
   13558              :   /* The next node on the stack.  */
   13559              :   struct c_switch *next;
   13560              : 
   13561              :   /* Remember whether the controlling expression had boolean type
   13562              :      before integer promotions for the sake of -Wswitch-bool.  */
   13563              :   bool bool_cond_p;
   13564              : };
   13565              : 
   13566              : /* A stack of the currently active switch statements.  The innermost
   13567              :    switch statement is on the top of the stack.  There is no need to
   13568              :    mark the stack for garbage collection because it is only active
   13569              :    during the processing of the body of a function, and we never
   13570              :    collect at that point.  */
   13571              : 
   13572              : struct c_switch *c_switch_stack;
   13573              : 
   13574              : /* Start a C switch statement, testing expression EXP.  Return the new
   13575              :    SWITCH_STMT.  SWITCH_LOC is the location of the `switch'.
   13576              :    SWITCH_COND_LOC is the location of the switch's condition.
   13577              :    EXPLICIT_CAST_P is true if the expression EXP has an explicit cast.  */
   13578              : 
   13579              : tree
   13580        37398 : c_start_switch (location_t switch_loc,
   13581              :                 location_t switch_cond_loc,
   13582              :                 tree exp, bool explicit_cast_p, tree switch_name)
   13583              : {
   13584        37398 :   tree orig_type = error_mark_node;
   13585        37398 :   bool bool_cond_p = false;
   13586        37398 :   struct c_switch *cs;
   13587              : 
   13588        37398 :   if (exp != error_mark_node)
   13589              :     {
   13590        37355 :       orig_type = TREE_TYPE (exp);
   13591              : 
   13592        37355 :       if (!INTEGRAL_TYPE_P (orig_type))
   13593              :         {
   13594           12 :           if (orig_type != error_mark_node)
   13595              :             {
   13596           12 :               error_at (switch_cond_loc, "switch quantity not an integer");
   13597           12 :               orig_type = error_mark_node;
   13598              :             }
   13599           12 :           exp = integer_zero_node;
   13600              :         }
   13601              :       else
   13602              :         {
   13603        37343 :           tree type = TYPE_MAIN_VARIANT (orig_type);
   13604        37343 :           tree e = exp;
   13605              : 
   13606              :           /* Warn if the condition has boolean value.  */
   13607        37346 :           while (TREE_CODE (e) == COMPOUND_EXPR)
   13608            3 :             e = TREE_OPERAND (e, 1);
   13609              : 
   13610        37318 :           if ((C_BOOLEAN_TYPE_P (type)
   13611        37318 :                || truth_value_p (TREE_CODE (e)))
   13612              :               /* Explicit cast to int suppresses this warning.  */
   13613        37365 :               && !(TREE_CODE (type) == INTEGER_TYPE
   13614              :                    && explicit_cast_p))
   13615              :             bool_cond_p = true;
   13616              : 
   13617        37343 :           if (!in_system_header_at (input_location)
   13618        37343 :               && (type == long_integer_type_node
   13619        12018 :                   || type == long_unsigned_type_node))
   13620          290 :             warning_at (switch_cond_loc,
   13621          290 :                         OPT_Wtraditional, "%<long%> switch expression not "
   13622              :                         "converted to %<int%> in ISO C");
   13623              : 
   13624        37343 :           exp = c_fully_fold (exp, false, NULL);
   13625        37343 :           exp = default_conversion (exp);
   13626              : 
   13627        37343 :           if (warn_sequence_point)
   13628         6038 :             verify_sequence_points (exp);
   13629              :         }
   13630              :     }
   13631              : 
   13632              :   /* Add this new SWITCH_STMT to the stack.  */
   13633        37398 :   cs = XNEW (struct c_switch);
   13634        37398 :   cs->switch_stmt = build_stmt (switch_loc, SWITCH_STMT, exp,
   13635              :                                 NULL_TREE, orig_type, NULL_TREE, switch_name);
   13636        37398 :   cs->orig_type = orig_type;
   13637        37398 :   cs->cases = splay_tree_new (case_compare, NULL, NULL);
   13638        37398 :   cs->bindings = c_get_switch_bindings ();
   13639        37398 :   cs->break_stmt_seen_p = false;
   13640        37398 :   cs->bool_cond_p = bool_cond_p;
   13641        37398 :   cs->next = c_switch_stack;
   13642        37398 :   c_switch_stack = cs;
   13643              : 
   13644        37398 :   return add_stmt (cs->switch_stmt);
   13645              : }
   13646              : 
   13647              : /* Process a case label at location LOC, with attributes ATTRS.  */
   13648              : 
   13649              : tree
   13650      1030818 : do_case (location_t loc, tree low_value, tree high_value, tree attrs)
   13651              : {
   13652      1030818 :   tree label = NULL_TREE;
   13653              : 
   13654      1030818 :   if (low_value && TREE_CODE (low_value) != INTEGER_CST)
   13655              :     {
   13656           87 :       low_value = c_fully_fold (low_value, false, NULL);
   13657           87 :       if (TREE_CODE (low_value) == INTEGER_CST)
   13658            9 :         pedwarn (loc, OPT_Wpedantic,
   13659              :                  "case label is not an integer constant expression");
   13660              :     }
   13661              : 
   13662      1030818 :   if (high_value && TREE_CODE (high_value) != INTEGER_CST)
   13663              :     {
   13664            0 :       high_value = c_fully_fold (high_value, false, NULL);
   13665            0 :       if (TREE_CODE (high_value) == INTEGER_CST)
   13666            0 :         pedwarn (input_location, OPT_Wpedantic,
   13667              :                  "case label is not an integer constant expression");
   13668              :     }
   13669              : 
   13670      1030818 :   if (c_switch_stack == NULL)
   13671              :     {
   13672            3 :       if (low_value)
   13673            2 :         error_at (loc, "case label not within a switch statement");
   13674              :       else
   13675            1 :         error_at (loc, "%<default%> label not within a switch statement");
   13676            3 :       return NULL_TREE;
   13677              :     }
   13678              : 
   13679      1030815 :   if (c_check_switch_jump_warnings (c_switch_stack->bindings,
   13680      1030815 :                                     EXPR_LOCATION (c_switch_stack->switch_stmt),
   13681              :                                     loc))
   13682              :     return NULL_TREE;
   13683              : 
   13684      1030803 :   label = c_add_case_label (loc, c_switch_stack->cases,
   13685      1030803 :                             SWITCH_STMT_COND (c_switch_stack->switch_stmt),
   13686              :                             low_value, high_value, attrs);
   13687      1030803 :   if (label == error_mark_node)
   13688          144 :     label = NULL_TREE;
   13689              :   return label;
   13690              : }
   13691              : 
   13692              : /* Finish the switch statement.  TYPE is the original type of the
   13693              :    controlling expression of the switch, or NULL_TREE.  */
   13694              : 
   13695              : void
   13696        37398 : c_finish_switch (tree body, tree type)
   13697              : {
   13698        37398 :   struct c_switch *cs = c_switch_stack;
   13699        37398 :   location_t switch_location;
   13700              : 
   13701        37398 :   SWITCH_STMT_BODY (cs->switch_stmt) = body;
   13702              : 
   13703              :   /* Emit warnings as needed.  */
   13704        37398 :   switch_location = EXPR_LOCATION (cs->switch_stmt);
   13705        43604 :   c_do_switch_warnings (cs->cases, switch_location,
   13706         6206 :                         type ? type : SWITCH_STMT_TYPE (cs->switch_stmt),
   13707        37398 :                         SWITCH_STMT_COND (cs->switch_stmt), cs->bool_cond_p);
   13708        37398 :   if (c_switch_covers_all_cases_p (cs->cases,
   13709        37398 :                                    SWITCH_STMT_TYPE (cs->switch_stmt)))
   13710        33471 :     SWITCH_STMT_ALL_CASES_P (cs->switch_stmt) = 1;
   13711        37398 :   SWITCH_STMT_NO_BREAK_P (cs->switch_stmt) = !cs->break_stmt_seen_p;
   13712              : 
   13713              :   /* Pop the stack.  */
   13714        37398 :   c_switch_stack = cs->next;
   13715        37398 :   splay_tree_delete (cs->cases);
   13716        37398 :   c_release_switch_bindings (cs->bindings);
   13717        37398 :   XDELETE (cs);
   13718        37398 : }
   13719              : 
   13720              : /* Emit an if statement.  IF_LOCUS is the location of the 'if'.  COND,
   13721              :    THEN_BLOCK and ELSE_BLOCK are expressions to be used; ELSE_BLOCK
   13722              :    may be null.  */
   13723              : 
   13724              : void
   13725      1273295 : c_finish_if_stmt (location_t if_locus, tree cond, tree then_block,
   13726              :                   tree else_block)
   13727              : {
   13728      1273295 :   tree stmt;
   13729              : 
   13730      1273295 :   stmt = build3 (COND_EXPR, void_type_node, cond, then_block, else_block);
   13731      1273295 :   SET_EXPR_LOCATION (stmt, if_locus);
   13732      1273295 :   add_stmt (stmt);
   13733      1273295 : }
   13734              : 
   13735              : tree
   13736       187660 : c_finish_bc_stmt (location_t loc, tree label, bool is_break, tree name)
   13737              : {
   13738              :   /* In switch statements break is sometimes stylistically used after
   13739              :      a return statement.  This can lead to spurious warnings about
   13740              :      control reaching the end of a non-void function when it is
   13741              :      inlined.  Note that we are calling block_may_fallthru with
   13742              :      language specific tree nodes; this works because
   13743              :      block_may_fallthru returns true when given something it does not
   13744              :      understand.  */
   13745       187660 :   bool skip = !block_may_fallthru (cur_stmt_list);
   13746              : 
   13747       187660 :   if (is_break)
   13748       174481 :     switch (in_statement & ~IN_NAMED_STMT)
   13749              :       {
   13750            9 :       case 0:
   13751            9 :         error_at (loc, "break statement not within loop or switch");
   13752            9 :         return NULL_TREE;
   13753            4 :       case IN_OMP_BLOCK:
   13754            4 :         error_at (loc, "invalid exit from OpenMP structured block");
   13755            4 :         return NULL_TREE;
   13756           12 :       case IN_OMP_FOR:
   13757           12 :         error_at (loc, "break statement used with OpenMP for loop");
   13758           12 :         return NULL_TREE;
   13759              :       case IN_ITERATION_STMT:
   13760              :       case IN_OBJC_FOREACH:
   13761              :         break;
   13762       158620 :       default:
   13763       158620 :         gcc_assert (in_statement & IN_SWITCH_STMT);
   13764       158620 :         c_switch_stack->break_stmt_seen_p = true;
   13765       158620 :         break;
   13766              :       }
   13767              :   else
   13768        13179 :     switch (in_statement & ~(IN_SWITCH_STMT | IN_NAMED_STMT))
   13769              :       {
   13770            7 :       case 0:
   13771            7 :         error_at (loc, "continue statement not within a loop");
   13772            7 :         return NULL_TREE;
   13773            4 :       case IN_OMP_BLOCK:
   13774            4 :         error_at (loc, "invalid exit from OpenMP structured block");
   13775            4 :         return NULL_TREE;
   13776              :       case IN_ITERATION_STMT:
   13777              :       case IN_OMP_FOR:
   13778              :       case IN_OBJC_FOREACH:
   13779              :         break;
   13780            0 :       default:
   13781            0 :         gcc_unreachable ();
   13782              :       }
   13783              : 
   13784       187624 :   if (skip)
   13785              :     return NULL_TREE;
   13786       187142 :   else if ((in_statement & IN_OBJC_FOREACH)
   13787            0 :            && !(is_break && (in_statement & IN_SWITCH_STMT))
   13788            0 :            && name == NULL_TREE)
   13789              :     {
   13790              :       /* The foreach expander produces low-level code using gotos instead
   13791              :          of a structured loop construct.  */
   13792            0 :       gcc_assert (label);
   13793            0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   13794              :     }
   13795       187239 :   else if (name && C_DECL_LOOP_NAME (name) && C_DECL_SWITCH_NAME (name))
   13796              :     {
   13797            0 :       label = DECL_CHAIN (name);
   13798            0 :       if (!is_break)
   13799            0 :         label = DECL_CHAIN (label);
   13800              :       /* Foreach expander from some outer level.  */
   13801            0 :       return add_stmt (build_stmt (loc, GOTO_EXPR, label));
   13802              :     }
   13803       200310 :   return add_stmt (build_stmt (loc, is_break ? BREAK_STMT : CONTINUE_STMT,
   13804       187142 :                                name));
   13805              : }
   13806              : 
   13807              : /* A helper routine for c_process_expr_stmt and c_finish_stmt_expr.  */
   13808              : 
   13809              : static void
   13810      6374135 : emit_side_effect_warnings (location_t loc, tree expr)
   13811              : {
   13812      6374135 :   maybe_warn_nodiscard (loc, expr);
   13813      6374135 :   if (!warn_unused_value)
   13814              :     return;
   13815      1303002 :   if (expr == error_mark_node)
   13816              :     ;
   13817      1302927 :   else if (!TREE_SIDE_EFFECTS (expr))
   13818              :     {
   13819         6544 :       if (!VOID_TYPE_P (TREE_TYPE (expr))
   13820         6544 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   13821           28 :         warning_at (loc, OPT_Wunused_value, "statement with no effect");
   13822              :     }
   13823      1296383 :   else if (TREE_CODE (expr) == COMPOUND_EXPR)
   13824              :     {
   13825              :       tree r = expr;
   13826              :       location_t cloc = loc;
   13827        11987 :       while (TREE_CODE (r) == COMPOUND_EXPR)
   13828              :         {
   13829         6009 :           if (EXPR_HAS_LOCATION (r))
   13830         5479 :             cloc = EXPR_LOCATION (r);
   13831         6009 :           r = TREE_OPERAND (r, 1);
   13832              :         }
   13833         5978 :       if (!TREE_SIDE_EFFECTS (r)
   13834           33 :           && !VOID_TYPE_P (TREE_TYPE (r))
   13835           24 :           && !CONVERT_EXPR_P (r)
   13836           24 :           && !warning_suppressed_p (r, OPT_Wunused_value)
   13837         5990 :           && !warning_suppressed_p (expr, OPT_Wunused_value))
   13838            8 :         warning_at (cloc, OPT_Wunused_value,
   13839              :                     "right-hand operand of comma expression has no effect");
   13840              :     }
   13841              :   else
   13842      1290405 :     warn_if_unused_value (expr, loc);
   13843              : }
   13844              : 
   13845              : /* Process an expression as if it were a complete statement.  Emit
   13846              :    diagnostics, but do not call ADD_STMT.  LOC is the location of the
   13847              :    statement.  */
   13848              : 
   13849              : tree
   13850      6250655 : c_process_expr_stmt (location_t loc, tree expr)
   13851              : {
   13852      6250655 :   tree exprv;
   13853              : 
   13854      6250655 :   if (!expr)
   13855              :     return NULL_TREE;
   13856              : 
   13857      6246315 :   expr = c_fully_fold (expr, false, NULL);
   13858              : 
   13859      6246315 :   if (warn_sequence_point)
   13860      1298710 :     verify_sequence_points (expr);
   13861              : 
   13862      6246315 :   if (TREE_TYPE (expr) != error_mark_node
   13863      6243661 :       && !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
   13864      6246315 :       && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
   13865            0 :     error_at (loc, "expression statement has incomplete type");
   13866              : 
   13867              :   /* If we're not processing a statement expression, warn about unused values.
   13868              :      Warnings for statement expressions will be emitted later, once we figure
   13869              :      out which is the result.  */
   13870      6246315 :   if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   13871      6246315 :       && (warn_unused_value || warn_unused_result))
   13872      6160401 :     emit_side_effect_warnings (EXPR_LOC_OR_LOC (expr, loc), expr);
   13873              : 
   13874              :   exprv = expr;
   13875      6285186 :   while (TREE_CODE (exprv) == COMPOUND_EXPR)
   13876        38872 :     exprv = TREE_OPERAND (exprv, 1);
   13877      6257783 :   while (CONVERT_EXPR_P (exprv))
   13878        11469 :     exprv = TREE_OPERAND (exprv, 0);
   13879      6246314 :   if (DECL_P (exprv)
   13880      6246900 :       || handled_component_p (exprv)
   13881     12472782 :       || TREE_CODE (exprv) == ADDR_EXPR)
   13882        20432 :     mark_exp_read (exprv);
   13883              : 
   13884              :   /* If the expression is not of a type to which we cannot assign a line
   13885              :      number, wrap the thing in a no-op NOP_EXPR.  */
   13886      6246314 :   if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
   13887              :     {
   13888        14889 :       expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   13889        14889 :       SET_EXPR_LOCATION (expr, loc);
   13890              :     }
   13891              : 
   13892              :   return expr;
   13893              : }
   13894              : 
   13895              : /* Emit an expression as a statement.  LOC is the location of the
   13896              :    expression.  */
   13897              : 
   13898              : tree
   13899      5950030 : c_finish_expr_stmt (location_t loc, tree expr)
   13900              : {
   13901      5950030 :   if (expr)
   13902      5937449 :     return add_stmt (c_process_expr_stmt (loc, expr));
   13903              :   else
   13904              :     return NULL;
   13905              : }
   13906              : 
   13907              : /* Do the opposite and emit a statement as an expression.  To begin,
   13908              :    create a new binding level and return it.  */
   13909              : 
   13910              : tree
   13911        34915 : c_begin_stmt_expr (void)
   13912              : {
   13913        34915 :   tree ret;
   13914              : 
   13915              :   /* We must force a BLOCK for this level so that, if it is not expanded
   13916              :      later, there is a way to turn off the entire subtree of blocks that
   13917              :      are contained in it.  */
   13918        34915 :   keep_next_level ();
   13919        34915 :   ret = c_begin_compound_stmt (true);
   13920              : 
   13921        34915 :   c_bindings_start_stmt_expr (c_switch_stack == NULL
   13922              :                               ? NULL
   13923              :                               : c_switch_stack->bindings);
   13924              : 
   13925              :   /* Mark the current statement list as belonging to a statement list.  */
   13926        34915 :   STATEMENT_LIST_STMT_EXPR (ret) = 1;
   13927              : 
   13928        34915 :   return ret;
   13929              : }
   13930              : 
   13931              : /* LOC is the location of the compound statement to which this body
   13932              :    belongs.  */
   13933              : 
   13934              : tree
   13935        34915 : c_finish_stmt_expr (location_t loc, tree body)
   13936              : {
   13937        34915 :   tree last, type, tmp, val;
   13938        34915 :   tree *last_p;
   13939              : 
   13940        34915 :   body = c_end_compound_stmt (loc, body, true);
   13941              : 
   13942        34915 :   c_bindings_end_stmt_expr (c_switch_stack == NULL
   13943              :                             ? NULL
   13944              :                             : c_switch_stack->bindings);
   13945              : 
   13946              :   /* Locate the last statement in BODY.  See c_end_compound_stmt
   13947              :      about always returning a BIND_EXPR.  */
   13948        34915 :   last_p = &BIND_EXPR_BODY (body);
   13949        34915 :   last = BIND_EXPR_BODY (body);
   13950              : 
   13951        34915 :  continue_searching:
   13952        34915 :   if (TREE_CODE (last) == STATEMENT_LIST)
   13953              :     {
   13954        26101 :       tree_stmt_iterator l = tsi_last (last);
   13955              : 
   13956        26107 :       while (!tsi_end_p (l) && TREE_CODE (tsi_stmt (l)) == DEBUG_BEGIN_STMT)
   13957            6 :         tsi_prev (&l);
   13958              : 
   13959              :       /* This can happen with degenerate cases like ({ }).  No value.  */
   13960        26101 :       if (tsi_end_p (l))
   13961          389 :         return body;
   13962              : 
   13963              :       /* If we're supposed to generate side effects warnings, process
   13964              :          all of the statements except the last.  */
   13965        25712 :       if (warn_unused_value || warn_unused_result)
   13966              :         {
   13967        25712 :           for (tree_stmt_iterator i = tsi_start (last);
   13968       275871 :                tsi_stmt (i) != tsi_stmt (l); tsi_next (&i))
   13969              :             {
   13970       250159 :               location_t tloc;
   13971       250159 :               tree t = tsi_stmt (i);
   13972              : 
   13973       250159 :               tloc = EXPR_HAS_LOCATION (t) ? EXPR_LOCATION (t) : loc;
   13974       250159 :               emit_side_effect_warnings (tloc, t);
   13975              :             }
   13976              :         }
   13977        25712 :       last_p = tsi_stmt_ptr (l);
   13978        25712 :       last = *last_p;
   13979              :     }
   13980              : 
   13981              :   /* If the end of the list is exception related, then the list was split
   13982              :      by a call to push_cleanup.  Continue searching.  */
   13983        34526 :   if (TREE_CODE (last) == TRY_FINALLY_EXPR
   13984        34526 :       || TREE_CODE (last) == TRY_CATCH_EXPR)
   13985              :     {
   13986            0 :       last_p = &TREE_OPERAND (last, 0);
   13987            0 :       last = *last_p;
   13988            0 :       goto continue_searching;
   13989              :     }
   13990              : 
   13991        34526 :   if (last == error_mark_node)
   13992              :     return last;
   13993              : 
   13994              :   /* In the case that the BIND_EXPR is not necessary, return the
   13995              :      expression out from inside it.  */
   13996        34517 :   if ((last == BIND_EXPR_BODY (body)
   13997              :        /* Skip nested debug stmts.  */
   13998        25711 :        || last == expr_first (BIND_EXPR_BODY (body)))
   13999        45544 :       && BIND_EXPR_VARS (body) == NULL)
   14000              :     {
   14001              :       /* Even if this looks constant, do not allow it in a constant
   14002              :          expression.  */
   14003        11015 :       last = c_wrap_maybe_const (last, true);
   14004              :       /* Do not warn if the return value of a statement expression is
   14005              :          unused.  */
   14006        11015 :       suppress_warning (last, OPT_Wunused);
   14007        11015 :       return last;
   14008              :     }
   14009              : 
   14010              :   /* Extract the type of said expression.  */
   14011        23502 :   type = TREE_TYPE (last);
   14012              : 
   14013              :   /* If we're not returning a value at all, then the BIND_EXPR that
   14014              :      we already have is a fine expression to return.  */
   14015        23502 :   if (!type || VOID_TYPE_P (type))
   14016              :     return body;
   14017              : 
   14018              :   /* Now that we've located the expression containing the value, it seems
   14019              :      silly to make voidify_wrapper_expr repeat the process.  Create a
   14020              :      temporary of the appropriate type and stick it in a TARGET_EXPR.  */
   14021        18178 :   tmp = create_tmp_var_raw (type);
   14022              : 
   14023              :   /* Unwrap a no-op NOP_EXPR as added by c_finish_expr_stmt.  This avoids
   14024              :      tree_expr_nonnegative_p giving up immediately.  */
   14025        18178 :   val = last;
   14026        18178 :   if (TREE_CODE (val) == NOP_EXPR
   14027        18178 :       && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0)))
   14028         3793 :     val = TREE_OPERAND (val, 0);
   14029              : 
   14030        18178 :   *last_p = build2 (MODIFY_EXPR, void_type_node, tmp, val);
   14031        18178 :   SET_EXPR_LOCATION (*last_p, EXPR_LOCATION (last));
   14032              : 
   14033        18178 :   {
   14034        18178 :     tree t = build4 (TARGET_EXPR, type, tmp, body, NULL_TREE, NULL_TREE);
   14035        18178 :     SET_EXPR_LOCATION (t, loc);
   14036        18178 :     return t;
   14037              :   }
   14038              : }
   14039              : 
   14040              : /* Begin and end compound statements.  This is as simple as pushing
   14041              :    and popping new statement lists from the tree.  */
   14042              : 
   14043              : tree
   14044     41198149 : c_begin_compound_stmt (bool do_scope)
   14045              : {
   14046     41198149 :   tree stmt = push_stmt_list ();
   14047     41198149 :   if (do_scope)
   14048     41102095 :     push_scope ();
   14049     41198149 :   return stmt;
   14050              : }
   14051              : 
   14052              : /* End a compound statement.  STMT is the statement.  LOC is the
   14053              :    location of the compound statement-- this is usually the location
   14054              :    of the opening brace.  */
   14055              : 
   14056              : tree
   14057     41198148 : c_end_compound_stmt (location_t loc, tree stmt, bool do_scope)
   14058              : {
   14059     41198148 :   tree block = NULL;
   14060              : 
   14061     41198148 :   if (do_scope)
   14062              :     {
   14063     41102094 :       if (c_dialect_objc ())
   14064            0 :         objc_clear_super_receiver ();
   14065     41102094 :       block = pop_scope ();
   14066              :     }
   14067              : 
   14068     41198148 :   stmt = pop_stmt_list (stmt);
   14069     41198148 :   stmt = c_build_bind_expr (loc, block, stmt);
   14070              : 
   14071              :   /* If this compound statement is nested immediately inside a statement
   14072              :      expression, then force a BIND_EXPR to be created.  Otherwise we'll
   14073              :      do the wrong thing for ({ { 1; } }) or ({ 1; { } }).  In particular,
   14074              :      STATEMENT_LISTs merge, and thus we can lose track of what statement
   14075              :      was really last.  */
   14076     82396296 :   if (building_stmt_list_p ()
   14077     41198063 :       && STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
   14078     41320833 :       && TREE_CODE (stmt) != BIND_EXPR)
   14079              :     {
   14080       120942 :       stmt = build3 (BIND_EXPR, void_type_node, NULL, stmt, NULL);
   14081       120942 :       TREE_SIDE_EFFECTS (stmt) = 1;
   14082       120942 :       SET_EXPR_LOCATION (stmt, loc);
   14083              :     }
   14084              : 
   14085     41198148 :   return stmt;
   14086              : }
   14087              : 
   14088              : /* Queue a cleanup.  CLEANUP is an expression/statement to be executed
   14089              :    when the current scope is exited.  EH_ONLY is true when this is not
   14090              :    meant to apply to normal control flow transfer.  */
   14091              : 
   14092              : void
   14093          131 : push_cleanup (tree decl, tree cleanup, bool eh_only)
   14094              : {
   14095          131 :   enum tree_code code;
   14096          131 :   tree stmt, list;
   14097          131 :   bool stmt_expr;
   14098              : 
   14099          131 :   code = eh_only ? TRY_CATCH_EXPR : TRY_FINALLY_EXPR;
   14100          131 :   stmt = build_stmt (DECL_SOURCE_LOCATION (decl), code, NULL, cleanup);
   14101          131 :   add_stmt (stmt);
   14102          131 :   stmt_expr = STATEMENT_LIST_STMT_EXPR (cur_stmt_list);
   14103          131 :   list = push_stmt_list ();
   14104          131 :   TREE_OPERAND (stmt, 0) = list;
   14105          131 :   STATEMENT_LIST_STMT_EXPR (list) = stmt_expr;
   14106          131 : }
   14107              : 
   14108              : /* Build a vector comparison of ARG0 and ARG1 using CODE opcode
   14109              :    into a value of TYPE type.  Comparison is done via VEC_COND_EXPR.  */
   14110              : 
   14111              : static tree
   14112       101030 : build_vec_cmp (tree_code code, tree type,
   14113              :                tree arg0, tree arg1)
   14114              : {
   14115       101030 :   tree zero_vec = build_zero_cst (type);
   14116       101030 :   tree minus_one_vec = build_minus_one_cst (type);
   14117       101030 :   tree cmp_type = truth_type_for (TREE_TYPE (arg0));
   14118       101030 :   tree cmp = build2 (code, cmp_type, arg0, arg1);
   14119       101030 :   return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
   14120              : }
   14121              : 
   14122              : /* Possibly warn about an address of OP never being NULL in a comparison
   14123              :    operation CODE involving null.  */
   14124              : 
   14125              : static void
   14126        51783 : maybe_warn_for_null_address (location_t loc, tree op, tree_code code)
   14127              : {
   14128              :   /* Prevent warnings issued for macro expansion.  */
   14129        51783 :   if (!warn_address
   14130        30322 :       || warning_suppressed_p (op, OPT_Waddress)
   14131        81749 :       || from_macro_expansion_at (loc))
   14132        24546 :     return;
   14133              : 
   14134        27237 :   if (TREE_CODE (op) == NOP_EXPR)
   14135              :     {
   14136              :       /* Allow casts to intptr_t to suppress the warning.  */
   14137         1133 :       tree type = TREE_TYPE (op);
   14138         1133 :       if (TREE_CODE (type) == INTEGER_TYPE)
   14139              :         return;
   14140         1133 :       op = TREE_OPERAND (op, 0);
   14141              :     }
   14142              : 
   14143        27237 :   if (TREE_CODE (op) == POINTER_PLUS_EXPR)
   14144              :     {
   14145              :       /* Allow a cast to void* to suppress the warning.  */
   14146           24 :       tree type = TREE_TYPE (TREE_TYPE (op));
   14147           24 :       if (VOID_TYPE_P (type))
   14148              :         return;
   14149              : 
   14150              :       /* Adding any value to a null pointer, including zero, is undefined
   14151              :          in C.  This includes the expression &p[0] where p is the null
   14152              :          pointer, although &p[0] will have been folded to p by this point
   14153              :          and so not diagnosed.  */
   14154           24 :       if (code == EQ_EXPR)
   14155           22 :         warning_at (loc, OPT_Waddress,
   14156              :                     "the comparison will always evaluate as %<false%> "
   14157              :                     "for the pointer operand in %qE must not be NULL",
   14158              :                     op);
   14159              :       else
   14160            2 :         warning_at (loc, OPT_Waddress,
   14161              :                     "the comparison will always evaluate as %<true%> "
   14162              :                     "for the pointer operand in %qE must not be NULL",
   14163              :                     op);
   14164              : 
   14165           24 :       return;
   14166              :     }
   14167              : 
   14168        27213 :   if (TREE_CODE (op) != ADDR_EXPR)
   14169              :     return;
   14170              : 
   14171          254 :   op = TREE_OPERAND (op, 0);
   14172              : 
   14173          254 :   if (TREE_CODE (op) == IMAGPART_EXPR
   14174          254 :       || TREE_CODE (op) == REALPART_EXPR)
   14175              :     {
   14176              :       /* The address of either complex part may not be null.  */
   14177           14 :       if (code == EQ_EXPR)
   14178            9 :         warning_at (loc, OPT_Waddress,
   14179              :                     "the comparison will always evaluate as %<false%> "
   14180              :                     "for the address of %qE will never be NULL",
   14181              :                     op);
   14182              :       else
   14183            5 :         warning_at (loc, OPT_Waddress,
   14184              :                     "the comparison will always evaluate as %<true%> "
   14185              :                     "for the address of %qE will never be NULL",
   14186              :                     op);
   14187           14 :       return;
   14188              :     }
   14189              : 
   14190              :   /* Set to true in the loop below if OP dereferences is operand.
   14191              :      In such a case the ultimate target need not be a decl for
   14192              :      the null [in]equality test to be constant.  */
   14193              :   bool deref = false;
   14194              : 
   14195              :   /* Get the outermost array or object, or member.  */
   14196          294 :   while (handled_component_p (op))
   14197              :     {
   14198           72 :       if (TREE_CODE (op) == COMPONENT_REF)
   14199              :         {
   14200              :           /* Get the member (its address is never null).  */
   14201           18 :           op = TREE_OPERAND (op, 1);
   14202           18 :           break;
   14203              :         }
   14204              : 
   14205              :       /* Get the outer array/object to refer to in the warning.  */
   14206           54 :       op = TREE_OPERAND (op, 0);
   14207           54 :       deref = true;
   14208              :     }
   14209              : 
   14210          192 :   if ((!deref && !decl_with_nonnull_addr_p (op))
   14211          371 :       || from_macro_expansion_at (loc))
   14212          109 :     return;
   14213              : 
   14214          131 :   bool w;
   14215          131 :   if (code == EQ_EXPR)
   14216           93 :     w = warning_at (loc, OPT_Waddress,
   14217              :                     "the comparison will always evaluate as %<false%> "
   14218              :                     "for the address of %qE will never be NULL",
   14219              :                     op);
   14220              :   else
   14221           38 :     w = warning_at (loc, OPT_Waddress,
   14222              :                     "the comparison will always evaluate as %<true%> "
   14223              :                     "for the address of %qE will never be NULL",
   14224              :                     op);
   14225              : 
   14226          131 :   if (w && DECL_P (op))
   14227          120 :     inform (DECL_SOURCE_LOCATION (op), "%qD declared here", op);
   14228              : }
   14229              : 
   14230              : /* Build a binary-operation expression without default conversions.
   14231              :    CODE is the kind of expression to build.
   14232              :    LOCATION is the operator's location.
   14233              :    This function differs from `build' in several ways:
   14234              :    the data type of the result is computed and recorded in it,
   14235              :    warnings are generated if arg data types are invalid,
   14236              :    special handling for addition and subtraction of pointers is known,
   14237              :    and some optimization is done (operations on narrow ints
   14238              :    are done in the narrower type when that gives the same result).
   14239              :    Constant folding is also done before the result is returned.
   14240              : 
   14241              :    Note that the operands will never have enumeral types, or function
   14242              :    or array types, because either they will have the default conversions
   14243              :    performed or they have both just been converted to some other type in which
   14244              :    the arithmetic is to be done.  */
   14245              : 
   14246              : tree
   14247     16856268 : build_binary_op (location_t location, enum tree_code code,
   14248              :                  tree orig_op0, tree orig_op1, bool convert_p)
   14249              : {
   14250     16856268 :   tree type0, type1, orig_type0, orig_type1;
   14251     16856268 :   tree eptype;
   14252     16856268 :   enum tree_code code0, code1;
   14253     16856268 :   tree op0, op1;
   14254     16856268 :   tree ret = error_mark_node;
   14255     16856268 :   const char *invalid_op_diag;
   14256     16856268 :   bool op0_int_operands, op1_int_operands;
   14257     16856268 :   bool int_const, int_const_or_overflow, int_operands;
   14258              : 
   14259              :   /* Expression code to give to the expression when it is built.
   14260              :      Normally this is CODE, which is what the caller asked for,
   14261              :      but in some special cases we change it.  */
   14262     16856268 :   enum tree_code resultcode = code;
   14263              : 
   14264              :   /* Data type in which the computation is to be performed.
   14265              :      In the simplest cases this is the common type of the arguments.  */
   14266     16856268 :   tree result_type = NULL;
   14267              : 
   14268              :   /* When the computation is in excess precision, the type of the
   14269              :      final EXCESS_PRECISION_EXPR.  */
   14270     16856268 :   tree semantic_result_type = NULL;
   14271              : 
   14272              :   /* Nonzero means operands have already been type-converted
   14273              :      in whatever way is necessary.
   14274              :      Zero means they need to be converted to RESULT_TYPE.  */
   14275     16856268 :   int converted = 0;
   14276              : 
   14277              :   /* Nonzero means create the expression with this type, rather than
   14278              :      RESULT_TYPE.  */
   14279     16856268 :   tree build_type = NULL_TREE;
   14280              : 
   14281              :   /* Nonzero means after finally constructing the expression
   14282              :      convert it to this type.  */
   14283     16856268 :   tree final_type = NULL_TREE;
   14284              : 
   14285              :   /* Nonzero if this is an operation like MIN or MAX which can
   14286              :      safely be computed in short if both args are promoted shorts.
   14287              :      Also implies COMMON.
   14288              :      -1 indicates a bitwise operation; this makes a difference
   14289              :      in the exact conditions for when it is safe to do the operation
   14290              :      in a narrower mode.  */
   14291     16856268 :   int shorten = 0;
   14292              : 
   14293              :   /* Nonzero if this is a comparison operation;
   14294              :      if both args are promoted shorts, compare the original shorts.
   14295              :      Also implies COMMON.  */
   14296     16856268 :   int short_compare = 0;
   14297              : 
   14298              :   /* Nonzero if this is a right-shift operation, which can be computed on the
   14299              :      original short and then promoted if the operand is a promoted short.  */
   14300     16856268 :   int short_shift = 0;
   14301              : 
   14302              :   /* Nonzero means set RESULT_TYPE to the common type of the args.  */
   14303     16856268 :   int common = 0;
   14304              : 
   14305              :   /* True means types are compatible as far as ObjC is concerned.  */
   14306     16856268 :   bool objc_ok;
   14307              : 
   14308              :   /* True means this is an arithmetic operation that may need excess
   14309              :      precision.  */
   14310     16856268 :   bool may_need_excess_precision;
   14311              : 
   14312              :   /* True means this is a boolean operation that converts both its
   14313              :      operands to truth-values.  */
   14314     16856268 :   bool boolean_op = false;
   14315              : 
   14316              :   /* Remember whether we're doing / or %.  */
   14317     16856268 :   bool doing_div_or_mod = false;
   14318              : 
   14319              :   /* Remember whether we're doing << or >>.  */
   14320     16856268 :   bool doing_shift = false;
   14321              : 
   14322              :   /* Tree holding instrumentation expression.  */
   14323     16856268 :   tree instrument_expr = NULL;
   14324              : 
   14325     16856268 :   if (location == UNKNOWN_LOCATION)
   14326           79 :     location = input_location;
   14327              : 
   14328     16856268 :   op0 = orig_op0;
   14329     16856268 :   op1 = orig_op1;
   14330              : 
   14331     16856268 :   op0_int_operands = EXPR_INT_CONST_OPERANDS (orig_op0);
   14332      8151551 :   if (op0_int_operands)
   14333      8151551 :     op0 = remove_c_maybe_const_expr (op0);
   14334     16856268 :   op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
   14335     11421939 :   if (op1_int_operands)
   14336     11421939 :     op1 = remove_c_maybe_const_expr (op1);
   14337     28278207 :   int_operands = (op0_int_operands && op1_int_operands);
   14338     11421939 :   if (int_operands)
   14339              :     {
   14340     15946571 :       int_const_or_overflow = (TREE_CODE (orig_op0) == INTEGER_CST
   14341      7988456 :                                && TREE_CODE (orig_op1) == INTEGER_CST);
   14342      7958115 :       int_const = (int_const_or_overflow
   14343      7958115 :                    && !TREE_OVERFLOW (orig_op0)
   14344      7958046 :                    && !TREE_OVERFLOW (orig_op1));
   14345              :     }
   14346              :   else
   14347              :     int_const = int_const_or_overflow = false;
   14348              : 
   14349              :   /* Do not apply default conversion in mixed vector/scalar expression.  */
   14350     16856268 :   if (convert_p
   14351     16856268 :       && VECTOR_TYPE_P (TREE_TYPE (op0)) == VECTOR_TYPE_P (TREE_TYPE (op1)))
   14352              :     {
   14353     10135612 :       op0 = default_conversion (op0);
   14354     10135612 :       op1 = default_conversion (op1);
   14355              :     }
   14356              : 
   14357     16856268 :   orig_type0 = type0 = TREE_TYPE (op0);
   14358              : 
   14359     16856268 :   orig_type1 = type1 = TREE_TYPE (op1);
   14360              : 
   14361              :   /* The expression codes of the data types of the arguments tell us
   14362              :      whether the arguments are integers, floating, pointers, etc.  */
   14363     16856268 :   code0 = TREE_CODE (type0);
   14364     16856268 :   code1 = TREE_CODE (type1);
   14365              : 
   14366              :   /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue.  */
   14367     16856270 :   STRIP_TYPE_NOPS (op0);
   14368     16856271 :   STRIP_TYPE_NOPS (op1);
   14369              : 
   14370              :   /* If an error was already reported for one of the arguments,
   14371              :      avoid reporting another error.  */
   14372              : 
   14373     16856268 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   14374          710 :     return error_mark_node;
   14375              : 
   14376     16855558 :   if (code0 == POINTER_TYPE
   14377     16855558 :       && reject_gcc_builtin (op0, EXPR_LOCATION (orig_op0)))
   14378           11 :     return error_mark_node;
   14379              : 
   14380     16855547 :   if (code1 == POINTER_TYPE
   14381     16855547 :       && reject_gcc_builtin (op1, EXPR_LOCATION (orig_op1)))
   14382           11 :     return error_mark_node;
   14383              : 
   14384     33711072 :   if ((invalid_op_diag
   14385     16855536 :        = targetm.invalid_binary_op (code, type0, type1)))
   14386              :     {
   14387            0 :       error_at (location, invalid_op_diag);
   14388            0 :       return error_mark_node;
   14389              :     }
   14390              : 
   14391     16855536 :   switch (code)
   14392              :     {
   14393              :     case PLUS_EXPR:
   14394              :     case MINUS_EXPR:
   14395              :     case MULT_EXPR:
   14396              :     case TRUNC_DIV_EXPR:
   14397              :     case CEIL_DIV_EXPR:
   14398              :     case FLOOR_DIV_EXPR:
   14399              :     case ROUND_DIV_EXPR:
   14400              :     case EXACT_DIV_EXPR:
   14401              :       may_need_excess_precision = true;
   14402              :       break;
   14403              : 
   14404      2737947 :     case EQ_EXPR:
   14405      2737947 :     case NE_EXPR:
   14406      2737947 :     case LE_EXPR:
   14407      2737947 :     case GE_EXPR:
   14408      2737947 :     case LT_EXPR:
   14409      2737947 :     case GT_EXPR:
   14410              :       /* Excess precision for implicit conversions of integers to
   14411              :          floating point in C11 and later.  */
   14412      2737947 :       may_need_excess_precision = (flag_isoc11
   14413      2737947 :                                    && (ANY_INTEGRAL_TYPE_P (type0)
   14414       488043 :                                        || ANY_INTEGRAL_TYPE_P (type1)));
   14415              :       break;
   14416              : 
   14417              :     default:
   14418     16855536 :       may_need_excess_precision = false;
   14419              :       break;
   14420              :     }
   14421     16855536 :   if (TREE_CODE (op0) == EXCESS_PRECISION_EXPR)
   14422              :     {
   14423          184 :       op0 = TREE_OPERAND (op0, 0);
   14424          184 :       type0 = TREE_TYPE (op0);
   14425              :     }
   14426     16855352 :   else if (may_need_excess_precision
   14427     16855352 :            && (eptype = excess_precision_type (type0)) != NULL_TREE)
   14428              :     {
   14429          771 :       type0 = eptype;
   14430          771 :       op0 = convert (eptype, op0);
   14431              :     }
   14432     16855536 :   if (TREE_CODE (op1) == EXCESS_PRECISION_EXPR)
   14433              :     {
   14434          889 :       op1 = TREE_OPERAND (op1, 0);
   14435          889 :       type1 = TREE_TYPE (op1);
   14436              :     }
   14437     16854647 :   else if (may_need_excess_precision
   14438     16854647 :            && (eptype = excess_precision_type (type1)) != NULL_TREE)
   14439              :     {
   14440          592 :       type1 = eptype;
   14441          592 :       op1 = convert (eptype, op1);
   14442              :     }
   14443              : 
   14444     16855536 :   objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE);
   14445              : 
   14446              :   /* In case when one of the operands of the binary operation is
   14447              :      a vector and another is a scalar -- convert scalar to vector.  */
   14448     18435774 :   if ((gnu_vector_type_p (type0) && code1 != VECTOR_TYPE)
   14449     18433861 :       || (gnu_vector_type_p (type1) && code0 != VECTOR_TYPE))
   14450              :     {
   14451         2520 :       enum stv_conv convert_flag = scalar_to_vector (location, code, orig_op0,
   14452              :                                                      orig_op1, true);
   14453              : 
   14454         2520 :       switch (convert_flag)
   14455              :         {
   14456           12 :           case stv_error:
   14457           12 :             return error_mark_node;
   14458          594 :           case stv_firstarg:
   14459          594 :             {
   14460          594 :               bool maybe_const = true;
   14461          594 :               tree sc;
   14462          594 :               sc = c_fully_fold (op0, false, &maybe_const);
   14463          594 :               sc = save_expr (sc);
   14464          594 :               sc = convert (TREE_TYPE (type1), sc);
   14465          594 :               op0 = build_vector_from_val (type1, sc);
   14466          594 :               if (!maybe_const)
   14467           93 :                 op0 = c_wrap_maybe_const (op0, true);
   14468          594 :               orig_type0 = type0 = TREE_TYPE (op0);
   14469          594 :               code0 = TREE_CODE (type0);
   14470          594 :               converted = 1;
   14471          594 :               break;
   14472              :             }
   14473         1072 :           case stv_secondarg:
   14474         1072 :             {
   14475         1072 :               bool maybe_const = true;
   14476         1072 :               tree sc;
   14477         1072 :               sc = c_fully_fold (op1, false, &maybe_const);
   14478         1072 :               sc = save_expr (sc);
   14479         1072 :               sc = convert (TREE_TYPE (type0), sc);
   14480         1072 :               op1 = build_vector_from_val (type0, sc);
   14481         1072 :               if (!maybe_const)
   14482           37 :                 op1 = c_wrap_maybe_const (op1, true);
   14483         1072 :               orig_type1 = type1 = TREE_TYPE (op1);
   14484         1072 :               code1 = TREE_CODE (type1);
   14485         1072 :               converted = 1;
   14486         1072 :               break;
   14487              :             }
   14488              :           default:
   14489              :             break;
   14490              :         }
   14491              :     }
   14492              : 
   14493     16855524 :   switch (code)
   14494              :     {
   14495      8645153 :     case PLUS_EXPR:
   14496              :       /* Handle the pointer + int case.  */
   14497      8645153 :       if (code0 == POINTER_TYPE
   14498      1251349 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14499              :         {
   14500      1251343 :           ret = pointer_int_sum (location, PLUS_EXPR, op0, op1);
   14501      1251343 :           goto return_build_binary_op;
   14502              :         }
   14503      7393810 :       else if (code1 == POINTER_TYPE
   14504         1539 :                && (code0 == INTEGER_TYPE || code0 == BITINT_TYPE))
   14505              :         {
   14506         1533 :           ret = pointer_int_sum (location, PLUS_EXPR, op1, op0);
   14507         1533 :           goto return_build_binary_op;
   14508              :         }
   14509              :       else
   14510              :         common = 1;
   14511              :       break;
   14512              : 
   14513       791625 :     case MINUS_EXPR:
   14514              :       /* Subtraction of two similar pointers.
   14515              :          We must subtract them as integers, then divide by object size.  */
   14516       791625 :       if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
   14517       791625 :           && comp_target_types (location, type0, type1))
   14518              :         {
   14519         3709 :           ret = pointer_diff (location, op0, op1, &instrument_expr);
   14520         3709 :           goto return_build_binary_op;
   14521              :         }
   14522              :       /* Handle pointer minus int.  Just like pointer plus int.  */
   14523       787916 :       else if (code0 == POINTER_TYPE
   14524        16856 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14525              :         {
   14526        16844 :           ret = pointer_int_sum (location, MINUS_EXPR, op0, op1);
   14527        16844 :           goto return_build_binary_op;
   14528              :         }
   14529              :       else
   14530              :         common = 1;
   14531              :       break;
   14532              : 
   14533              :     case MULT_EXPR:
   14534              :       common = 1;
   14535              :       break;
   14536              : 
   14537       274759 :     case TRUNC_DIV_EXPR:
   14538       274759 :     case CEIL_DIV_EXPR:
   14539       274759 :     case FLOOR_DIV_EXPR:
   14540       274759 :     case ROUND_DIV_EXPR:
   14541       274759 :     case EXACT_DIV_EXPR:
   14542       274759 :       doing_div_or_mod = true;
   14543       274759 :       warn_for_div_by_zero (location, op1);
   14544              : 
   14545       274758 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   14546        49656 :            || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   14547        47642 :            || code0 == COMPLEX_TYPE
   14548        45594 :            || gnu_vector_type_p (type0))
   14549       324413 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   14550        47223 :               || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   14551        47056 :               || code1 == COMPLEX_TYPE
   14552        45596 :               || gnu_vector_type_p (type1)))
   14553              :         {
   14554       274754 :           enum tree_code tcode0 = code0, tcode1 = code1;
   14555              : 
   14556       274754 :           if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
   14557        47641 :             tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
   14558       274754 :           if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
   14559        47053 :             tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
   14560              : 
   14561       274754 :           if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE
   14562        69644 :                   || (tcode0 == ENUMERAL_TYPE && code0 == VECTOR_TYPE))
   14563       205111 :                  && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE
   14564        12988 :                      || (tcode1 == ENUMERAL_TYPE && code1 == VECTOR_TYPE)))
   14565        82630 :                 || (tcode0 == FIXED_POINT_TYPE && tcode1 == FIXED_POINT_TYPE)))
   14566              :             resultcode = RDIV_EXPR;
   14567              :           else
   14568              :             /* Although it would be tempting to shorten always here, that
   14569              :                loses on some targets, since the modulo instruction is
   14570              :                undefined if the quotient can't be represented in the
   14571              :                computation mode.  We shorten only if unsigned or if
   14572              :                dividing by something we know != -1.  */
   14573       192124 :             shorten = may_shorten_divmod (op0, op1);
   14574              :           common = 1;
   14575              :         }
   14576              :       break;
   14577              : 
   14578      1586701 :     case BIT_AND_EXPR:
   14579      1586701 :     case BIT_IOR_EXPR:
   14580      1586701 :     case BIT_XOR_EXPR:
   14581      1586701 :       if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14582      1051157 :           && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14583              :         shorten = -1;
   14584              :       /* Allow vector types which are not floating point types.   */
   14585       535580 :       else if (gnu_vector_type_p (type0)
   14586       535503 :                && gnu_vector_type_p (type1)
   14587       535503 :                && !VECTOR_FLOAT_TYPE_P (type0)
   14588      1071080 :                && !VECTOR_FLOAT_TYPE_P (type1))
   14589              :         common = 1;
   14590              :       break;
   14591              : 
   14592        58561 :     case TRUNC_MOD_EXPR:
   14593        58561 :     case FLOOR_MOD_EXPR:
   14594        58561 :       doing_div_or_mod = true;
   14595        58561 :       warn_for_div_by_zero (location, op1);
   14596              : 
   14597        58561 :       if (gnu_vector_type_p (type0)
   14598          297 :           && gnu_vector_type_p (type1)
   14599          297 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14600        58858 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE)
   14601              :         common = 1;
   14602        58264 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14603        58263 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14604              :         {
   14605              :           /* Although it would be tempting to shorten always here, that loses
   14606              :              on some targets, since the modulo instruction is undefined if the
   14607              :              quotient can't be represented in the computation mode.  We shorten
   14608              :              only if unsigned or if dividing by something we know != -1.  */
   14609        58263 :           shorten = may_shorten_divmod (op0, op1);
   14610        58263 :           common = 1;
   14611              :         }
   14612              :       break;
   14613              : 
   14614       511707 :     case TRUTH_ANDIF_EXPR:
   14615       511707 :     case TRUTH_ORIF_EXPR:
   14616       511707 :     case TRUTH_AND_EXPR:
   14617       511707 :     case TRUTH_OR_EXPR:
   14618       511707 :     case TRUTH_XOR_EXPR:
   14619       511707 :       if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
   14620            0 :            || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   14621            0 :            || code0 == FIXED_POINT_TYPE || code0 == NULLPTR_TYPE
   14622            0 :            || code0 == BITINT_TYPE)
   14623       511707 :           && (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
   14624          163 :               || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   14625           24 :               || code1 == FIXED_POINT_TYPE || code1 == NULLPTR_TYPE
   14626           22 :               || code1 == BITINT_TYPE))
   14627              :         {
   14628              :           /* Result of these operations is always an int,
   14629              :              but that does not mean the operands should be
   14630              :              converted to ints!  */
   14631       511707 :           result_type = integer_type_node;
   14632       511707 :           if (op0_int_operands)
   14633              :             {
   14634       110670 :               op0 = c_objc_common_truthvalue_conversion (location, orig_op0);
   14635       110670 :               op0 = remove_c_maybe_const_expr (op0);
   14636              :             }
   14637              :           else
   14638       401037 :             op0 = c_objc_common_truthvalue_conversion (location, op0);
   14639       511707 :           if (op1_int_operands)
   14640              :             {
   14641        71669 :               op1 = c_objc_common_truthvalue_conversion (location, orig_op1);
   14642        71669 :               op1 = remove_c_maybe_const_expr (op1);
   14643              :             }
   14644              :           else
   14645       440038 :             op1 = c_objc_common_truthvalue_conversion (location, op1);
   14646              :           converted = 1;
   14647              :           boolean_op = true;
   14648              :         }
   14649       511707 :       if (code == TRUTH_ANDIF_EXPR)
   14650              :         {
   14651       250585 :           int_const_or_overflow = (int_operands
   14652        63484 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   14653       250601 :                                    && (op0 == truthvalue_false_node
   14654        13357 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   14655              :           int_const = (int_const_or_overflow
   14656        63457 :                        && !TREE_OVERFLOW (orig_op0)
   14657        63457 :                        && (op0 == truthvalue_false_node
   14658        13341 :                            || !TREE_OVERFLOW (orig_op1)));
   14659              :         }
   14660       324579 :       else if (code == TRUTH_ORIF_EXPR)
   14661              :         {
   14662       331259 :           int_const_or_overflow = (int_operands
   14663         6831 :                                    && TREE_CODE (orig_op0) == INTEGER_CST
   14664       331282 :                                    && (op0 == truthvalue_true_node
   14665         2146 :                                        || TREE_CODE (orig_op1) == INTEGER_CST));
   14666              :           int_const = (int_const_or_overflow
   14667         6801 :                        && !TREE_OVERFLOW (orig_op0)
   14668         6801 :                        && (op0 == truthvalue_true_node
   14669         2123 :                            || !TREE_OVERFLOW (orig_op1)));
   14670              :         }
   14671              :       break;
   14672              : 
   14673              :       /* Shift operations: result has same type as first operand;
   14674              :          always convert second operand to int.
   14675              :          Also set SHORT_SHIFT if shifting rightward.  */
   14676              : 
   14677       231409 :     case RSHIFT_EXPR:
   14678       231409 :       if (gnu_vector_type_p (type0)
   14679          814 :           && gnu_vector_type_p (type1)
   14680          258 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14681          256 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   14682       231665 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   14683              :                        TYPE_VECTOR_SUBPARTS (type1)))
   14684              :         {
   14685              :           result_type = type0;
   14686              :           converted = 1;
   14687              :         }
   14688       231155 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   14689         1119 :                 || code0 == BITINT_TYPE
   14690          564 :                 || (gnu_vector_type_p (type0)
   14691          560 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   14692       232267 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14693              :         {
   14694       231146 :           doing_shift = true;
   14695       231146 :           if (TREE_CODE (op1) == INTEGER_CST)
   14696              :             {
   14697       201697 :               if (tree_int_cst_sgn (op1) < 0)
   14698              :                 {
   14699          269 :                   int_const = false;
   14700          269 :                   if (c_inhibit_evaluation_warnings == 0)
   14701          129 :                     warning_at (location, OPT_Wshift_count_negative,
   14702              :                                 "right shift count is negative");
   14703              :                 }
   14704       201428 :               else if (code0 == VECTOR_TYPE)
   14705              :                 {
   14706          458 :                   if (compare_tree_int (op1,
   14707          458 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   14708              :                       >= 0)
   14709              :                     {
   14710           16 :                       int_const = false;
   14711           16 :                       if (c_inhibit_evaluation_warnings == 0)
   14712           16 :                         warning_at (location, OPT_Wshift_count_overflow,
   14713              :                                     "right shift count >= width of vector element");
   14714              :                     }
   14715              :                 }
   14716              :               else
   14717              :                 {
   14718       200970 :                   if (!integer_zerop (op1))
   14719       200612 :                     short_shift = 1;
   14720              : 
   14721       200970 :                   if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   14722              :                     {
   14723          586 :                       int_const = false;
   14724          586 :                       if (c_inhibit_evaluation_warnings == 0)
   14725           52 :                         warning_at (location, OPT_Wshift_count_overflow,
   14726              :                                     "right shift count >= width of type");
   14727              :                     }
   14728              :                 }
   14729              :             }
   14730              : 
   14731              :           /* Use the type of the value to be shifted.  */
   14732              :           result_type = type0;
   14733              :           /* Avoid converting op1 to result_type later.  */
   14734              :           converted = 1;
   14735              :         }
   14736              :       break;
   14737              : 
   14738       803447 :     case LSHIFT_EXPR:
   14739       803447 :       if (gnu_vector_type_p (type0)
   14740          596 :           && gnu_vector_type_p (type1)
   14741          316 :           && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE
   14742          314 :           && TREE_CODE (TREE_TYPE (type1)) == INTEGER_TYPE
   14743       803760 :           && known_eq (TYPE_VECTOR_SUBPARTS (type0),
   14744              :                        TYPE_VECTOR_SUBPARTS (type1)))
   14745              :         {
   14746              :           result_type = type0;
   14747              :           converted = 1;
   14748              :         }
   14749       803136 :       else if ((code0 == INTEGER_TYPE || code0 == FIXED_POINT_TYPE
   14750          781 :                 || code0 == BITINT_TYPE
   14751          291 :                 || (gnu_vector_type_p (type0)
   14752          285 :                     && TREE_CODE (TREE_TYPE (type0)) == INTEGER_TYPE))
   14753       803908 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14754              :         {
   14755       803122 :           doing_shift = true;
   14756       803122 :           if (TREE_CODE (op0) == INTEGER_CST
   14757       438821 :               && tree_int_cst_sgn (op0) < 0
   14758       803871 :               && !TYPE_OVERFLOW_WRAPS (type0))
   14759              :             {
   14760              :               /* Don't reject a left shift of a negative value in a context
   14761              :                  where a constant expression is needed in C90.  */
   14762          712 :               if (flag_isoc99)
   14763          666 :                 int_const = false;
   14764          712 :               if (c_inhibit_evaluation_warnings == 0)
   14765          712 :                 warning_at (location, OPT_Wshift_negative_value,
   14766              :                             "left shift of negative value");
   14767              :             }
   14768       803122 :           if (TREE_CODE (op1) == INTEGER_CST)
   14769              :             {
   14770       730657 :               if (tree_int_cst_sgn (op1) < 0)
   14771              :                 {
   14772          313 :                   int_const = false;
   14773          313 :                   if (c_inhibit_evaluation_warnings == 0)
   14774          135 :                     warning_at (location, OPT_Wshift_count_negative,
   14775              :                                 "left shift count is negative");
   14776              :                 }
   14777       730344 :               else if (code0 == VECTOR_TYPE)
   14778              :                 {
   14779          216 :                   if (compare_tree_int (op1,
   14780          216 :                                         TYPE_PRECISION (TREE_TYPE (type0)))
   14781              :                       >= 0)
   14782              :                     {
   14783            6 :                       int_const = false;
   14784            6 :                       if (c_inhibit_evaluation_warnings == 0)
   14785            6 :                         warning_at (location, OPT_Wshift_count_overflow,
   14786              :                                     "left shift count >= width of vector element");
   14787              :                     }
   14788              :                 }
   14789       730128 :               else if (compare_tree_int (op1, TYPE_PRECISION (type0)) >= 0)
   14790              :                 {
   14791        29733 :                   int_const = false;
   14792        29733 :                   if (c_inhibit_evaluation_warnings == 0)
   14793          113 :                     warning_at (location, OPT_Wshift_count_overflow,
   14794              :                                 "left shift count >= width of type");
   14795              :                 }
   14796       700395 :               else if (TREE_CODE (op0) == INTEGER_CST
   14797       365033 :                        && maybe_warn_shift_overflow (location, op0, op1)
   14798       701023 :                        && flag_isoc99)
   14799              :                 int_const = false;
   14800              :             }
   14801              : 
   14802              :           /* Use the type of the value to be shifted.  */
   14803              :           result_type = type0;
   14804              :           /* Avoid converting op1 to result_type later.  */
   14805              :           converted = 1;
   14806              :         }
   14807              :       break;
   14808              : 
   14809      1740139 :     case EQ_EXPR:
   14810      1740139 :     case NE_EXPR:
   14811      1740139 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   14812              :         {
   14813        41899 :           tree intt;
   14814        41899 :           if (!vector_types_compatible_elements_p (type0, type1))
   14815              :             {
   14816            4 :               error_at (location, "comparing vectors with different "
   14817              :                                   "element types");
   14818            4 :               return error_mark_node;
   14819              :             }
   14820              : 
   14821        41895 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   14822        83790 :                         TYPE_VECTOR_SUBPARTS (type1)))
   14823              :             {
   14824            1 :               error_at (location, "comparing vectors with different "
   14825              :                                   "number of elements");
   14826            1 :               return error_mark_node;
   14827              :             }
   14828              : 
   14829              :           /* It's not precisely specified how the usual arithmetic
   14830              :              conversions apply to the vector types.  Here, we use
   14831              :              the unsigned type if one of the operands is signed and
   14832              :              the other one is unsigned.  */
   14833        41894 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   14834              :             {
   14835            4 :               if (!TYPE_UNSIGNED (type0))
   14836            4 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   14837              :               else
   14838            0 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   14839            4 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   14840              :                           "types %qT and %qT", type0, type1);
   14841              :             }
   14842              : 
   14843              :           /* Always construct signed integer vector type.  */
   14844        41894 :           if (VECTOR_BOOLEAN_TYPE_P (type0) && VECTOR_BOOLEAN_TYPE_P (type1))
   14845              :             result_type = type0;
   14846              :           else
   14847              :             {
   14848        41894 :               auto nelts = TYPE_VECTOR_SUBPARTS (type0);
   14849              : 
   14850       125682 :               intt = c_common_type_for_size (GET_MODE_BITSIZE
   14851        83788 :                                              (SCALAR_TYPE_MODE
   14852              :                                                 (TREE_TYPE (type0))), 0);
   14853        41894 :               if (!intt)
   14854              :                 {
   14855            0 :                   error_at (location, "could not find an integer type "
   14856              :                                       "of the same size as %qT",
   14857            0 :                             TREE_TYPE (type0));
   14858            0 :                   return error_mark_node;
   14859              :                 }
   14860        41894 :               result_type = build_opaque_vector_type (intt, nelts);
   14861              :             }
   14862        41894 :           converted = 1;
   14863        41894 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   14864        41894 :           goto return_build_binary_op;
   14865              :         }
   14866      1698240 :       if (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))
   14867       254612 :         warning_at (location,
   14868       254612 :                     OPT_Wfloat_equal,
   14869              :                     "comparing floating-point with %<==%> or %<!=%> is unsafe");
   14870              :       /* Result of comparison is always int,
   14871              :          but don't convert the args to int!  */
   14872      1698240 :       build_type = integer_type_node;
   14873      1698240 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == BITINT_TYPE
   14874       156767 :            || code0 == FIXED_POINT_TYPE || code0 == COMPLEX_TYPE)
   14875      1577034 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   14876              :               || code1 == BITINT_TYPE
   14877              :               || code1 == FIXED_POINT_TYPE || code1 == COMPLEX_TYPE))
   14878              :         short_compare = 1;
   14879       121472 :       else if (code0 == POINTER_TYPE
   14880       121472 :                && (code1 == NULLPTR_TYPE
   14881       121095 :                    || null_pointer_constant_p (orig_op1)))
   14882              :         {
   14883        51491 :           maybe_warn_for_null_address (location, op0, code);
   14884        51491 :           result_type = type0;
   14885              :         }
   14886        69981 :       else if (code1 == POINTER_TYPE
   14887        69981 :                && (code0 == NULLPTR_TYPE
   14888        69879 :                    || null_pointer_constant_p (orig_op0)))
   14889              :         {
   14890          292 :           maybe_warn_for_null_address (location, op1, code);
   14891          292 :           result_type = type1;
   14892              :         }
   14893        69689 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   14894              :         {
   14895        69599 :           tree tt0 = TREE_TYPE (type0);
   14896        69599 :           tree tt1 = TREE_TYPE (type1);
   14897        69599 :           addr_space_t as0 = TYPE_ADDR_SPACE (tt0);
   14898        69599 :           addr_space_t as1 = TYPE_ADDR_SPACE (tt1);
   14899        69599 :           addr_space_t as_common = ADDR_SPACE_GENERIC;
   14900              : 
   14901              :           /* Anything compares with void *.  void * compares with anything.
   14902              :              Otherwise, the targets must be compatible
   14903              :              and both must be object or both incomplete.  */
   14904        69599 :           if (comp_target_types (location, type0, type1))
   14905        48267 :             result_type = common_pointer_type (type0, type1, NULL_TREE);
   14906        21332 :           else if (!addr_space_superset (as0, as1, &as_common))
   14907              :             {
   14908            0 :               error_at (location, "comparison of pointers to "
   14909              :                         "disjoint address spaces");
   14910            0 :               return error_mark_node;
   14911              :             }
   14912        21332 :           else if (VOID_TYPE_P (tt0) && !TYPE_ATOMIC (tt0))
   14913              :             {
   14914        21105 :               if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE)
   14915            4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14916              :                          "comparison of %<void *%> with function pointer");
   14917              :             }
   14918          227 :           else if (VOID_TYPE_P (tt1) && !TYPE_ATOMIC (tt1))
   14919              :             {
   14920          179 :               if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE)
   14921            4 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   14922              :                          "comparison of %<void *%> with function pointer");
   14923              :             }
   14924              :           else
   14925              :             /* Avoid warning about the volatile ObjC EH puts on decls.  */
   14926           48 :             if (!objc_ok)
   14927           48 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   14928              :                        "comparison of distinct pointer types lacks a cast");
   14929              : 
   14930        48323 :           if (result_type == NULL_TREE)
   14931              :             {
   14932        21332 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   14933        21332 :               result_type = c_build_pointer_type
   14934        21332 :                               (c_build_qualified_type (void_type_node, qual));
   14935              :             }
   14936              :         }
   14937           90 :       else if (code0 == POINTER_TYPE
   14938           26 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   14939              :         {
   14940           26 :           result_type = type0;
   14941           26 :           pedwarn (location, 0, "comparison between pointer and integer");
   14942              :         }
   14943           64 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   14944           21 :                && code1 == POINTER_TYPE)
   14945              :         {
   14946            8 :           result_type = type1;
   14947            8 :           pedwarn (location, 0, "comparison between pointer and integer");
   14948              :         }
   14949              :       /* 6.5.9: One of the following shall hold:
   14950              :          -- both operands have type nullptr_t;  */
   14951           56 :       else if (code0 == NULLPTR_TYPE && code1 == NULLPTR_TYPE)
   14952              :         {
   14953           22 :           result_type = nullptr_type_node;
   14954              :           /* No need to convert the operands to result_type later.  */
   14955           22 :           converted = 1;
   14956              :         }
   14957              :     /* -- one operand has type nullptr_t and the other is a null pointer
   14958              :        constant.  We will have to convert the former to the type of the
   14959              :        latter, because during gimplification we can't have mismatching
   14960              :        comparison operand type.  We convert from nullptr_t to the other
   14961              :        type, since only nullptr_t can be converted to nullptr_t.  Also,
   14962              :        even a constant 0 is a null pointer constant, so we may have to
   14963              :        create a pointer type from its type.  */
   14964           34 :       else if (code0 == NULLPTR_TYPE && null_pointer_constant_p (orig_op1))
   14965           19 :         result_type = (INTEGRAL_TYPE_P (type1)
   14966           19 :                        ? c_build_pointer_type (type1) : type1);
   14967           15 :       else if (code1 == NULLPTR_TYPE && null_pointer_constant_p (orig_op0))
   14968           11 :         result_type = (INTEGRAL_TYPE_P (type0)
   14969           11 :                        ? c_build_pointer_type (type0) : type0);
   14970      5020067 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   14971      3321802 :            || truth_value_p (TREE_CODE (orig_op0)))
   14972      3389197 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   14973      3389193 :              || truth_value_p (TREE_CODE (orig_op1))))
   14974        71618 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   14975              :       break;
   14976              : 
   14977       997804 :     case LE_EXPR:
   14978       997804 :     case GE_EXPR:
   14979       997804 :     case LT_EXPR:
   14980       997804 :     case GT_EXPR:
   14981       997804 :       if (gnu_vector_type_p (type0) && gnu_vector_type_p (type1))
   14982              :         {
   14983        59141 :           tree intt;
   14984        59141 :           if (!vector_types_compatible_elements_p (type0, type1))
   14985              :             {
   14986            5 :               error_at (location, "comparing vectors with different "
   14987              :                                   "element types");
   14988            5 :               return error_mark_node;
   14989              :             }
   14990              : 
   14991        59136 :           if (maybe_ne (TYPE_VECTOR_SUBPARTS (type0),
   14992       118272 :                         TYPE_VECTOR_SUBPARTS (type1)))
   14993              :             {
   14994            0 :               error_at (location, "comparing vectors with different "
   14995              :                                   "number of elements");
   14996            0 :               return error_mark_node;
   14997              :             }
   14998              : 
   14999              :           /* It's not precisely specified how the usual arithmetic
   15000              :              conversions apply to the vector types.  Here, we use
   15001              :              the unsigned type if one of the operands is signed and
   15002              :              the other one is unsigned.  */
   15003        59136 :           if (TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1))
   15004              :             {
   15005           15 :               if (!TYPE_UNSIGNED (type0))
   15006            8 :                 op0 = build1 (VIEW_CONVERT_EXPR, type1, op0);
   15007              :               else
   15008            7 :                 op1 = build1 (VIEW_CONVERT_EXPR, type0, op1);
   15009           15 :               warning_at (location, OPT_Wsign_compare, "comparison between "
   15010              :                           "types %qT and %qT", type0, type1);
   15011              :             }
   15012              : 
   15013              :           /* Always construct signed integer vector type.  */
   15014       177408 :           intt = c_common_type_for_size (GET_MODE_BITSIZE
   15015       118272 :                                          (SCALAR_TYPE_MODE
   15016              :                                           (TREE_TYPE (type0))), 0);
   15017        59136 :           if (!intt)
   15018              :             {
   15019            0 :               error_at (location, "could not find an integer type "
   15020              :                                   "of the same size as %qT",
   15021            0 :                         TREE_TYPE (type0));
   15022            0 :               return error_mark_node;
   15023              :             }
   15024        59136 :           result_type = build_opaque_vector_type (intt,
   15025        59136 :                                                   TYPE_VECTOR_SUBPARTS (type0));
   15026        59136 :           converted = 1;
   15027        59136 :           ret = build_vec_cmp (resultcode, result_type, op0, op1);
   15028        59136 :           goto return_build_binary_op;
   15029              :         }
   15030       938663 :       build_type = integer_type_node;
   15031       938663 :       if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE
   15032        64969 :            || code0 == BITINT_TYPE || code0 == FIXED_POINT_TYPE)
   15033       874241 :           && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
   15034              :               || code1 == BITINT_TYPE || code1 == FIXED_POINT_TYPE))
   15035              :         short_compare = 1;
   15036        64454 :       else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
   15037              :         {
   15038        64387 :           addr_space_t as0 = TYPE_ADDR_SPACE (TREE_TYPE (type0));
   15039        64387 :           addr_space_t as1 = TYPE_ADDR_SPACE (TREE_TYPE (type1));
   15040        64387 :           addr_space_t as_common;
   15041              : 
   15042        64387 :           if (comp_target_types (location, type0, type1))
   15043              :             {
   15044        64222 :               result_type = common_pointer_type (type0, type1, NULL_TREE);
   15045        64222 :               if (!COMPLETE_TYPE_P (TREE_TYPE (type0))
   15046        64222 :                   != !COMPLETE_TYPE_P (TREE_TYPE (type1)))
   15047           32 :                 pedwarn_c99 (location, OPT_Wpedantic,
   15048              :                              "comparison of complete and incomplete pointers");
   15049        64190 :               else if (TREE_CODE (TREE_TYPE (type0)) == FUNCTION_TYPE)
   15050            0 :                 pedwarn (location, OPT_Wpedantic, "ISO C forbids "
   15051              :                          "ordered comparisons of pointers to functions");
   15052        64190 :               else if (null_pointer_constant_p (orig_op0)
   15053        64190 :                        || null_pointer_constant_p (orig_op1))
   15054            8 :                 warning_at (location, OPT_Wextra,
   15055              :                             "ordered comparison of pointer with null pointer");
   15056              : 
   15057              :             }
   15058          165 :           else if (!addr_space_superset (as0, as1, &as_common))
   15059              :             {
   15060            0 :               error_at (location, "comparison of pointers to "
   15061              :                         "disjoint address spaces");
   15062            0 :               return error_mark_node;
   15063              :             }
   15064              :           else
   15065              :             {
   15066          165 :               int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
   15067          165 :               result_type = c_build_pointer_type
   15068          165 :                               (c_build_qualified_type (void_type_node, qual));
   15069          165 :               pedwarn (location, OPT_Wcompare_distinct_pointer_types,
   15070              :                        "comparison of distinct pointer types lacks a cast");
   15071              :             }
   15072              :         }
   15073           67 :       else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1))
   15074              :         {
   15075           17 :           result_type = type0;
   15076           17 :           if (pedantic)
   15077           11 :             pedwarn (location, OPT_Wpedantic,
   15078              :                      "ordered comparison of pointer with integer zero");
   15079            6 :           else if (extra_warnings)
   15080            1 :             warning_at (location, OPT_Wextra,
   15081              :                         "ordered comparison of pointer with integer zero");
   15082              :         }
   15083           50 :       else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0))
   15084              :         {
   15085           12 :           result_type = type1;
   15086           12 :           if (pedantic)
   15087            2 :             pedwarn (location, OPT_Wpedantic,
   15088              :                      "ordered comparison of pointer with integer zero");
   15089           10 :           else if (extra_warnings)
   15090            1 :             warning_at (location, OPT_Wextra,
   15091              :                         "ordered comparison of pointer with integer zero");
   15092              :         }
   15093           38 :       else if (code0 == POINTER_TYPE
   15094           18 :                && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
   15095              :         {
   15096           18 :           result_type = type0;
   15097           18 :           pedwarn (location, 0, "comparison between pointer and integer");
   15098              :         }
   15099           20 :       else if ((code0 == INTEGER_TYPE || code0 == BITINT_TYPE)
   15100           20 :                && code1 == POINTER_TYPE)
   15101              :         {
   15102           18 :           result_type = type1;
   15103           18 :           pedwarn (location, 0, "comparison between pointer and integer");
   15104              :         }
   15105              : 
   15106       938663 :       if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE)
   15107        64452 :           && current_function_decl != NULL_TREE
   15108      1003104 :           && sanitize_flags_p (SANITIZE_POINTER_COMPARE))
   15109              :         {
   15110           35 :           op0 = save_expr (c_fully_fold (op0, false, NULL));
   15111           35 :           op1 = save_expr (c_fully_fold (op1, false, NULL));
   15112              : 
   15113           35 :           tree tt = builtin_decl_explicit (BUILT_IN_ASAN_POINTER_COMPARE);
   15114           35 :           instrument_expr = build_call_expr_loc (location, tt, 2, op0, op1);
   15115              :         }
   15116              : 
   15117      2815897 :       if ((C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op0))
   15118      1877234 :            || truth_value_p (TREE_CODE (orig_op0)))
   15119      1877251 :           ^ (C_BOOLEAN_TYPE_P (TREE_TYPE (orig_op1))
   15120      1877251 :              || truth_value_p (TREE_CODE (orig_op1))))
   15121          517 :         maybe_warn_bool_compare (location, code, orig_op0, orig_op1);
   15122              :       break;
   15123              : 
   15124           43 :     case MIN_EXPR:
   15125           43 :     case MAX_EXPR:
   15126              :       /* Used for OpenMP atomics.  */
   15127           43 :       gcc_assert (flag_openmp);
   15128              :       common = 1;
   15129              :       break;
   15130              : 
   15131            0 :     default:
   15132            0 :       gcc_unreachable ();
   15133              :     }
   15134              : 
   15135     15481054 :   if (code0 == ERROR_MARK || code1 == ERROR_MARK)
   15136            0 :     return error_mark_node;
   15137              : 
   15138     15481054 :   if (gnu_vector_type_p (type0)
   15139      1479788 :       && gnu_vector_type_p (type1)
   15140     16960005 :       && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
   15141      1478931 :           || !vector_types_compatible_elements_p (type0, type1)))
   15142              :     {
   15143           26 :       gcc_rich_location richloc (location);
   15144           26 :       maybe_range_label_for_tree_type_mismatch
   15145           26 :         label_for_op0 (orig_op0, orig_op1),
   15146           26 :         label_for_op1 (orig_op1, orig_op0);
   15147           26 :       richloc.maybe_add_expr (orig_op0, &label_for_op0, highlight_colors::lhs);
   15148           26 :       richloc.maybe_add_expr (orig_op1, &label_for_op1, highlight_colors::rhs);
   15149           26 :       binary_op_error (&richloc, code, type0, type1);
   15150           26 :       return error_mark_node;
   15151           26 :     }
   15152              : 
   15153     15481028 :   if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
   15154      1734339 :        || code0 == FIXED_POINT_TYPE || code0 == BITINT_TYPE
   15155      1665805 :        || gnu_vector_type_p (type0))
   15156     17029324 :       && (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE
   15157      1572970 :           || code1 == FIXED_POINT_TYPE || code1 == BITINT_TYPE
   15158      1481038 :           || gnu_vector_type_p (type1)))
   15159              :     {
   15160     15292877 :       bool first_complex = (code0 == COMPLEX_TYPE);
   15161     15292877 :       bool second_complex = (code1 == COMPLEX_TYPE);
   15162     15292877 :       int none_complex = (!first_complex && !second_complex);
   15163              : 
   15164     15292877 :       if (shorten || common || short_compare)
   15165              :         {
   15166     13748056 :           result_type = c_common_type (type0, type1);
   15167     13748056 :           do_warn_double_promotion (result_type, type0, type1,
   15168              :                                     "implicit conversion from %qT to %qT "
   15169              :                                     "to match other operand of binary "
   15170              :                                     "expression",
   15171              :                                     location);
   15172     13748056 :           if (result_type == error_mark_node)
   15173              :             return error_mark_node;
   15174              :         }
   15175              : 
   15176     15292855 :       if (first_complex != second_complex
   15177        82045 :           && (code == PLUS_EXPR
   15178              :               || code == MINUS_EXPR
   15179        82045 :               || code == MULT_EXPR
   15180        17526 :               || (code == TRUNC_DIV_EXPR && first_complex))
   15181        65933 :           && TREE_CODE (TREE_TYPE (result_type)) == REAL_TYPE
   15182     15355109 :           && flag_signed_zeros)
   15183              :         {
   15184              :           /* An operation on mixed real/complex operands must be
   15185              :              handled specially, but the language-independent code can
   15186              :              more easily optimize the plain complex arithmetic if
   15187              :              -fno-signed-zeros.  */
   15188        61942 :           tree real_type = TREE_TYPE (result_type);
   15189        61942 :           tree real, imag;
   15190        61942 :           if (type0 != orig_type0 || type1 != orig_type1)
   15191              :             {
   15192           94 :               gcc_assert (may_need_excess_precision && common);
   15193           94 :               semantic_result_type = c_common_type (orig_type0, orig_type1);
   15194              :             }
   15195        61942 :           if (first_complex)
   15196              :             {
   15197         8253 :               if (TREE_TYPE (op0) != result_type)
   15198         1787 :                 op0 = convert_and_check (location, result_type, op0);
   15199         8253 :               if (TREE_TYPE (op1) != real_type)
   15200         4601 :                 op1 = convert_and_check (location, real_type, op1);
   15201              :             }
   15202              :           else
   15203              :             {
   15204        53689 :               if (TREE_TYPE (op0) != real_type)
   15205         2698 :                 op0 = convert_and_check (location, real_type, op0);
   15206        53689 :               if (TREE_TYPE (op1) != result_type)
   15207         1866 :                 op1 = convert_and_check (location, result_type, op1);
   15208              :             }
   15209        61942 :           if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   15210            0 :             return error_mark_node;
   15211        61942 :           if (first_complex)
   15212              :             {
   15213         8253 :               op0 = save_expr (op0);
   15214         8253 :               real = build_unary_op (EXPR_LOCATION (orig_op0), REALPART_EXPR,
   15215              :                                      op0, true);
   15216         8253 :               imag = build_unary_op (EXPR_LOCATION (orig_op0), IMAGPART_EXPR,
   15217              :                                      op0, true);
   15218         8253 :               switch (code)
   15219              :                 {
   15220         3488 :                 case MULT_EXPR:
   15221         3488 :                 case TRUNC_DIV_EXPR:
   15222         3488 :                   op1 = save_expr (op1);
   15223         3488 :                   imag = build2 (resultcode, real_type, imag, op1);
   15224              :                   /* Fall through.  */
   15225         8253 :                 case PLUS_EXPR:
   15226         8253 :                 case MINUS_EXPR:
   15227         8253 :                   real = build2 (resultcode, real_type, real, op1);
   15228         8253 :                   break;
   15229            0 :                 default:
   15230            0 :                   gcc_unreachable();
   15231              :                 }
   15232              :             }
   15233              :           else
   15234              :             {
   15235        53689 :               op1 = save_expr (op1);
   15236        53689 :               real = build_unary_op (EXPR_LOCATION (orig_op1), REALPART_EXPR,
   15237              :                                      op1, true);
   15238        53689 :               imag = build_unary_op (EXPR_LOCATION (orig_op1), IMAGPART_EXPR,
   15239              :                                      op1, true);
   15240        53689 :               switch (code)
   15241              :                 {
   15242         2008 :                 case MULT_EXPR:
   15243         2008 :                   op0 = save_expr (op0);
   15244         2008 :                   imag = build2 (resultcode, real_type, op0, imag);
   15245              :                   /* Fall through.  */
   15246        31957 :                 case PLUS_EXPR:
   15247        31957 :                   real = build2 (resultcode, real_type, op0, real);
   15248        31957 :                   break;
   15249        21732 :                 case MINUS_EXPR:
   15250        21732 :                   real = build2 (resultcode, real_type, op0, real);
   15251        21732 :                   imag = build1 (NEGATE_EXPR, real_type, imag);
   15252        21732 :                   break;
   15253            0 :                 default:
   15254            0 :                   gcc_unreachable();
   15255              :                 }
   15256              :             }
   15257        61942 :           ret = build2 (COMPLEX_EXPR, result_type, real, imag);
   15258        61942 :           goto return_build_binary_op;
   15259              :         }
   15260              : 
   15261              :       /* For certain operations (which identify themselves by shorten != 0)
   15262              :          if both args were extended from the same smaller type,
   15263              :          do the arithmetic in that type and then extend.
   15264              : 
   15265              :          shorten !=0 and !=1 indicates a bitwise operation.
   15266              :          For them, this optimization is safe only if
   15267              :          both args are zero-extended or both are sign-extended.
   15268              :          Otherwise, we might change the result.
   15269              :          Eg, (short)-1 | (unsigned short)-1 is (int)-1
   15270              :          but calculated in (unsigned short) it would be (unsigned short)-1.  */
   15271              : 
   15272     15230913 :       if (shorten && none_complex)
   15273              :         {
   15274      1294802 :           final_type = result_type;
   15275      1294802 :           result_type = shorten_binary_op (result_type, op0, op1,
   15276              :                                            shorten == -1);
   15277              :         }
   15278              : 
   15279              :       /* Shifts can be shortened if shifting right.  */
   15280              : 
   15281     15230913 :       if (short_shift)
   15282              :         {
   15283       200612 :           int unsigned_arg;
   15284       200612 :           tree arg0 = get_narrower (op0, &unsigned_arg);
   15285              : 
   15286       200612 :           final_type = result_type;
   15287              : 
   15288       200612 :           if (arg0 == op0 && final_type == TREE_TYPE (op0))
   15289       141117 :             unsigned_arg = TYPE_UNSIGNED (TREE_TYPE (op0));
   15290              : 
   15291       200612 :           if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
   15292         2990 :               && tree_int_cst_sgn (op1) > 0
   15293              :               /* We can shorten only if the shift count is less than the
   15294              :                  number of bits in the smaller type size.  */
   15295         2990 :               && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
   15296              :               /* We cannot drop an unsigned shift after sign-extension.  */
   15297       203462 :               && (!TYPE_UNSIGNED (final_type) || unsigned_arg))
   15298              :             {
   15299              :               /* Do an unsigned shift if the operand was zero-extended.  */
   15300         2835 :               result_type
   15301         2835 :                 = c_common_signed_or_unsigned_type (unsigned_arg,
   15302         2835 :                                                     TREE_TYPE (arg0));
   15303              :               /* Convert value-to-be-shifted to that type.  */
   15304         2835 :               if (TREE_TYPE (op0) != result_type)
   15305         2835 :                 op0 = convert (result_type, op0);
   15306              :               converted = 1;
   15307              :             }
   15308              :         }
   15309              : 
   15310              :       /* Comparison operations are shortened too but differently.
   15311              :          They identify themselves by setting short_compare = 1.  */
   15312              : 
   15313     15230913 :       if (short_compare)
   15314              :         {
   15315              :           /* Don't write &op0, etc., because that would prevent op0
   15316              :              from being kept in a register.
   15317              :              Instead, make copies of the our local variables and
   15318              :              pass the copies by reference, then copy them back afterward.  */
   15319      2450975 :           tree xop0 = op0, xop1 = op1, xresult_type = result_type;
   15320      2450975 :           enum tree_code xresultcode = resultcode;
   15321      2450975 :           tree val
   15322      2450975 :             = shorten_compare (location, &xop0, &xop1, &xresult_type,
   15323              :                                &xresultcode);
   15324              : 
   15325      2450975 :           if (val != NULL_TREE)
   15326              :             {
   15327        15793 :               ret = val;
   15328        15793 :               goto return_build_binary_op;
   15329              :             }
   15330              : 
   15331      2435182 :           op0 = xop0, op1 = xop1;
   15332      2435182 :           converted = 1;
   15333      2435182 :           resultcode = xresultcode;
   15334              : 
   15335      2435182 :           if (c_inhibit_evaluation_warnings == 0 && !c_in_omp_for)
   15336              :             {
   15337      2287599 :               bool op0_maybe_const = true;
   15338      2287599 :               bool op1_maybe_const = true;
   15339      2287599 :               tree orig_op0_folded, orig_op1_folded;
   15340              : 
   15341      2287599 :               if (in_late_binary_op)
   15342              :                 {
   15343              :                   orig_op0_folded = orig_op0;
   15344              :                   orig_op1_folded = orig_op1;
   15345              :                 }
   15346              :               else
   15347              :                 {
   15348              :                   /* Fold for the sake of possible warnings, as in
   15349              :                      build_conditional_expr.  This requires the
   15350              :                      "original" values to be folded, not just op0 and
   15351              :                      op1.  */
   15352      2279052 :                   c_inhibit_evaluation_warnings++;
   15353      2279052 :                   op0 = c_fully_fold (op0, require_constant_value,
   15354              :                                       &op0_maybe_const);
   15355      2279052 :                   op1 = c_fully_fold (op1, require_constant_value,
   15356              :                                       &op1_maybe_const);
   15357      2279052 :                   c_inhibit_evaluation_warnings--;
   15358      2279052 :                   orig_op0_folded = c_fully_fold (orig_op0,
   15359              :                                                   require_constant_value,
   15360              :                                                   NULL);
   15361      2279052 :                   orig_op1_folded = c_fully_fold (orig_op1,
   15362              :                                                   require_constant_value,
   15363              :                                                   NULL);
   15364              :                 }
   15365              : 
   15366      2287599 :               if (warn_sign_compare)
   15367       377089 :                 warn_for_sign_compare (location, orig_op0_folded,
   15368              :                                        orig_op1_folded, op0, op1,
   15369              :                                        result_type, resultcode);
   15370      2287599 :               if (!in_late_binary_op && !int_operands)
   15371              :                 {
   15372      2102226 :                   if (!op0_maybe_const || TREE_CODE (op0) != INTEGER_CST)
   15373      2098716 :                     op0 = c_wrap_maybe_const (op0, !op0_maybe_const);
   15374      2102226 :                   if (!op1_maybe_const || TREE_CODE (op1) != INTEGER_CST)
   15375       827205 :                     op1 = c_wrap_maybe_const (op1, !op1_maybe_const);
   15376              :                 }
   15377              :             }
   15378              :         }
   15379              :     }
   15380              : 
   15381              :   /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
   15382              :      If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
   15383              :      Then the expression will be built.
   15384              :      It will be given type FINAL_TYPE if that is nonzero;
   15385              :      otherwise, it will be given type RESULT_TYPE.  */
   15386              : 
   15387     15403271 :   if (!result_type)
   15388              :     {
   15389              :       /* Favor showing any expression locations that are available. */
   15390          514 :       op_location_t oploc (location, UNKNOWN_LOCATION);
   15391          514 :       binary_op_rich_location richloc (oploc, orig_op0, orig_op1, true);
   15392          514 :       binary_op_error (&richloc, code, TREE_TYPE (op0), TREE_TYPE (op1));
   15393          514 :       return error_mark_node;
   15394          514 :     }
   15395              : 
   15396     15402757 :   if (build_type == NULL_TREE)
   15397              :     {
   15398     12781655 :       build_type = result_type;
   15399     12781655 :       if ((type0 != orig_type0 || type1 != orig_type1)
   15400          797 :           && !boolean_op)
   15401              :         {
   15402          797 :           gcc_assert (may_need_excess_precision && common);
   15403          797 :           semantic_result_type = c_common_type (orig_type0, orig_type1);
   15404              :         }
   15405              :     }
   15406              : 
   15407     15402757 :   if (!converted)
   15408              :     {
   15409     11419775 :       op0 = ep_convert_and_check (location, result_type, op0,
   15410              :                                   semantic_result_type);
   15411     11419775 :       op1 = ep_convert_and_check (location, result_type, op1,
   15412              :                                   semantic_result_type);
   15413              : 
   15414              :       /* This can happen if one operand has a vector type, and the other
   15415              :          has a different type.  */
   15416     11419775 :       if (TREE_CODE (op0) == ERROR_MARK || TREE_CODE (op1) == ERROR_MARK)
   15417            3 :         return error_mark_node;
   15418              :     }
   15419              : 
   15420     15402754 :   if (sanitize_flags_p ((SANITIZE_SHIFT
   15421              :                          | SANITIZE_DIVIDE
   15422              :                          | SANITIZE_FLOAT_DIVIDE
   15423              :                          | SANITIZE_SI_OVERFLOW))
   15424        23386 :       && current_function_decl != NULL_TREE
   15425        19923 :       && (doing_div_or_mod || doing_shift)
   15426     15405679 :       && !require_constant_value)
   15427              :     {
   15428              :       /* OP0 and/or OP1 might have side-effects.  */
   15429         2869 :       op0 = save_expr (op0);
   15430         2869 :       op1 = save_expr (op1);
   15431         2869 :       op0 = c_fully_fold (op0, false, NULL);
   15432         2869 :       op1 = c_fully_fold (op1, false, NULL);
   15433         2869 :       if (doing_div_or_mod && (sanitize_flags_p ((SANITIZE_DIVIDE
   15434              :                                                   | SANITIZE_FLOAT_DIVIDE
   15435              :                                                   | SANITIZE_SI_OVERFLOW))))
   15436          912 :         instrument_expr = ubsan_instrument_division (location, op0, op1);
   15437         1957 :       else if (doing_shift && sanitize_flags_p (SANITIZE_SHIFT))
   15438         1777 :         instrument_expr = ubsan_instrument_shift (location, code, op0, op1);
   15439              :     }
   15440              : 
   15441              :   /* Treat expressions in initializers specially as they can't trap.  */
   15442     15402754 :   if (int_const_or_overflow)
   15443      7942686 :     ret = (require_constant_value
   15444      7942686 :            ? fold_build2_initializer_loc (location, resultcode, build_type,
   15445              :                                           op0, op1)
   15446      7896567 :            : fold_build2_loc (location, resultcode, build_type, op0, op1));
   15447              :   else
   15448      7460068 :     ret = build2 (resultcode, build_type, op0, op1);
   15449     15402754 :   if (final_type != NULL_TREE)
   15450      1495414 :     ret = convert (final_type, ret);
   15451              : 
   15452     13907340 :  return_build_binary_op:
   15453     16854948 :   gcc_assert (ret != error_mark_node);
   15454     16854948 :   if (TREE_CODE (ret) == INTEGER_CST && !TREE_OVERFLOW (ret) && !int_const)
   15455         1758 :     ret = (int_operands
   15456         1758 :            ? note_integer_operands (ret)
   15457          436 :            : build1 (NOP_EXPR, TREE_TYPE (ret), ret));
   15458     16853190 :   else if (TREE_CODE (ret) != INTEGER_CST && int_operands
   15459        60309 :            && !in_late_binary_op)
   15460        60309 :     ret = note_integer_operands (ret);
   15461     16854948 :   protected_set_expr_location (ret, location);
   15462              : 
   15463     16854948 :   if (instrument_expr != NULL)
   15464         1420 :     ret = fold_build2 (COMPOUND_EXPR, TREE_TYPE (ret),
   15465              :                        instrument_expr, ret);
   15466              : 
   15467     16854948 :   if (semantic_result_type)
   15468          891 :     ret = build1_loc (location, EXCESS_PRECISION_EXPR,
   15469              :                       semantic_result_type, ret);
   15470              : 
   15471              :   return ret;
   15472              : }
   15473              : 
   15474              : 
   15475              : /* Convert EXPR to be a truth-value (type TYPE), validating its type for this
   15476              :    purpose.  LOCATION is the source location for the expression.  */
   15477              : 
   15478              : tree
   15479      4133924 : c_objc_common_truthvalue_conversion (location_t location, tree expr, tree type)
   15480              : {
   15481      4133924 :   bool int_const, int_operands;
   15482              : 
   15483      4133924 :   switch (TREE_CODE (TREE_TYPE (expr)))
   15484              :     {
   15485           72 :     case ARRAY_TYPE:
   15486           72 :       error_at (location, "used array that cannot be converted to pointer where scalar is required");
   15487           72 :       return error_mark_node;
   15488              : 
   15489           86 :     case RECORD_TYPE:
   15490           86 :       error_at (location, "used struct type value where scalar is required");
   15491           86 :       return error_mark_node;
   15492              : 
   15493           83 :     case UNION_TYPE:
   15494           83 :       error_at (location, "used union type value where scalar is required");
   15495           83 :       return error_mark_node;
   15496              : 
   15497           22 :     case VOID_TYPE:
   15498           22 :       error_at (location, "void value not ignored as it ought to be");
   15499           22 :       return error_mark_node;
   15500              : 
   15501        30668 :     case POINTER_TYPE:
   15502        30668 :       if (reject_gcc_builtin (expr))
   15503            3 :         return error_mark_node;
   15504              :       break;
   15505              : 
   15506            0 :     case FUNCTION_TYPE:
   15507            0 :       gcc_unreachable ();
   15508              : 
   15509            8 :     case VECTOR_TYPE:
   15510            8 :       error_at (location, "used vector type where scalar is required");
   15511            8 :       return error_mark_node;
   15512              : 
   15513              :     default:
   15514              :       break;
   15515              :     }
   15516              : 
   15517              :   /* Conversion of a floating constant to boolean goes through here
   15518              :      and yields an integer constant expression.  Otherwise, the result
   15519              :      is only an integer constant expression if the argument is.  */
   15520       899270 :   int_const = ((TREE_CODE (expr) == INTEGER_CST && !TREE_OVERFLOW (expr))
   15521      4133726 :                || ((TREE_CODE (expr) == REAL_CST
   15522      3234082 :                     || TREE_CODE (expr) == COMPLEX_CST)
   15523          374 :                    && (TREE_CODE (type) == BOOLEAN_TYPE
   15524           15 :                        || (TREE_CODE (type) == ENUMERAL_TYPE
   15525            5 :                            && ENUM_UNDERLYING_TYPE (type) != NULL_TREE
   15526            5 :                            && (TREE_CODE (ENUM_UNDERLYING_TYPE (type))
   15527              :                                == BOOLEAN_TYPE)))));
   15528      4133650 :   int_operands = EXPR_INT_CONST_OPERANDS (expr);
   15529       899430 :   if (int_operands && TREE_CODE (expr) != INTEGER_CST)
   15530              :     {
   15531          319 :       expr = remove_c_maybe_const_expr (expr);
   15532          319 :       expr = build2 (NE_EXPR, type, expr,
   15533          319 :                      convert (TREE_TYPE (expr), integer_zero_node));
   15534          319 :       expr = note_integer_operands (expr);
   15535              :     }
   15536              :   else
   15537              :     {
   15538              :       /* ??? Should we also give an error for vectors rather than leaving
   15539              :          those to give errors later?  */
   15540      4133331 :       expr = c_common_truthvalue_conversion (location, expr);
   15541      4133331 :       expr = fold_convert_loc (location, type, expr);
   15542              :     }
   15543              : 
   15544      4133650 :   if (TREE_CODE (expr) == INTEGER_CST && int_operands && !int_const)
   15545              :     {
   15546           76 :       if (TREE_OVERFLOW (expr))
   15547              :         return expr;
   15548              :       else
   15549           76 :         return note_integer_operands (expr);
   15550              :     }
   15551      4133574 :   if (TREE_CODE (expr) == INTEGER_CST && !int_const)
   15552          754 :     return build1 (NOP_EXPR, TREE_TYPE (expr), expr);
   15553              :   return expr;
   15554              : }
   15555              : 
   15556              : 
   15557              : /* Convert EXPR to a contained DECL, updating *TC, *TI and *SE as
   15558              :    required.  */
   15559              : 
   15560              : tree
   15561    119564869 : c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se)
   15562              : {
   15563    119564869 :   if (TREE_CODE (expr) == COMPOUND_LITERAL_EXPR)
   15564              :     {
   15565          699 :       tree decl = COMPOUND_LITERAL_EXPR_DECL (expr);
   15566              :       /* Executing a compound literal inside a function reinitializes
   15567              :          it.  */
   15568          699 :       if (!TREE_STATIC (decl))
   15569          433 :         *se = true;
   15570          699 :       return decl;
   15571              :     }
   15572              :   else
   15573              :     return expr;
   15574              : }
   15575              : 
   15576              : /* Generate OMP construct CODE, with BODY and CLAUSES as its compound
   15577              :    statement.  LOC is the location of the construct.  */
   15578              : 
   15579              : tree
   15580         2154 : c_finish_omp_construct (location_t loc, enum tree_code code, tree body,
   15581              :                         tree clauses)
   15582              : {
   15583         2154 :   body = c_end_compound_stmt (loc, body, true);
   15584              : 
   15585         2154 :   tree stmt = make_node (code);
   15586         2154 :   TREE_TYPE (stmt) = void_type_node;
   15587         2154 :   OMP_BODY (stmt) = body;
   15588         2154 :   OMP_CLAUSES (stmt) = clauses;
   15589         2154 :   SET_EXPR_LOCATION (stmt, loc);
   15590              : 
   15591         2154 :   return add_stmt (stmt);
   15592              : }
   15593              : 
   15594              : /* Generate OACC_DATA, with CLAUSES and BLOCK as its compound
   15595              :    statement.  LOC is the location of the OACC_DATA.  */
   15596              : 
   15597              : tree
   15598          497 : c_finish_oacc_data (location_t loc, tree clauses, tree block)
   15599              : {
   15600          497 :   tree stmt;
   15601              : 
   15602          497 :   block = c_end_compound_stmt (loc, block, true);
   15603              : 
   15604          497 :   stmt = make_node (OACC_DATA);
   15605          497 :   TREE_TYPE (stmt) = void_type_node;
   15606          497 :   OACC_DATA_CLAUSES (stmt) = clauses;
   15607          497 :   OACC_DATA_BODY (stmt) = block;
   15608          497 :   SET_EXPR_LOCATION (stmt, loc);
   15609              : 
   15610          497 :   return add_stmt (stmt);
   15611              : }
   15612              : 
   15613              : /* Generate OACC_HOST_DATA, with CLAUSES and BLOCK as its compound
   15614              :    statement.  LOC is the location of the OACC_HOST_DATA.  */
   15615              : 
   15616              : tree
   15617           21 : c_finish_oacc_host_data (location_t loc, tree clauses, tree block)
   15618              : {
   15619           21 :   tree stmt;
   15620              : 
   15621           21 :   block = c_end_compound_stmt (loc, block, true);
   15622              : 
   15623           21 :   stmt = make_node (OACC_HOST_DATA);
   15624           21 :   TREE_TYPE (stmt) = void_type_node;
   15625           21 :   OACC_HOST_DATA_CLAUSES (stmt) = clauses;
   15626           21 :   OACC_HOST_DATA_BODY (stmt) = block;
   15627           21 :   SET_EXPR_LOCATION (stmt, loc);
   15628              : 
   15629           21 :   return add_stmt (stmt);
   15630              : }
   15631              : 
   15632              : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   15633              : 
   15634              : tree
   15635        12003 : c_begin_omp_parallel (void)
   15636              : {
   15637        12003 :   tree block;
   15638              : 
   15639        12003 :   keep_next_level ();
   15640        12003 :   block = c_begin_compound_stmt (true);
   15641              : 
   15642        12003 :   return block;
   15643              : }
   15644              : 
   15645              : /* Generate OMP_PARALLEL, with CLAUSES and BLOCK as its compound
   15646              :    statement.  LOC is the location of the OMP_PARALLEL.  */
   15647              : 
   15648              : tree
   15649         5677 : c_finish_omp_parallel (location_t loc, tree clauses, tree block)
   15650              : {
   15651         5677 :   tree stmt;
   15652              : 
   15653         5677 :   block = c_end_compound_stmt (loc, block, true);
   15654              : 
   15655         5677 :   stmt = make_node (OMP_PARALLEL);
   15656         5677 :   TREE_TYPE (stmt) = void_type_node;
   15657         5677 :   OMP_PARALLEL_CLAUSES (stmt) = clauses;
   15658         5677 :   OMP_PARALLEL_BODY (stmt) = block;
   15659         5677 :   SET_EXPR_LOCATION (stmt, loc);
   15660              : 
   15661         5677 :   return add_stmt (stmt);
   15662              : }
   15663              : 
   15664              : /* Like c_begin_compound_stmt, except force the retention of the BLOCK.  */
   15665              : 
   15666              : tree
   15667          898 : c_begin_omp_task (void)
   15668              : {
   15669          898 :   tree block;
   15670              : 
   15671          898 :   keep_next_level ();
   15672          898 :   block = c_begin_compound_stmt (true);
   15673              : 
   15674          898 :   return block;
   15675              : }
   15676              : 
   15677              : /* Generate OMP_TASK, with CLAUSES and BLOCK as its compound
   15678              :    statement.  LOC is the location of the #pragma.  */
   15679              : 
   15680              : tree
   15681          898 : c_finish_omp_task (location_t loc, tree clauses, tree block)
   15682              : {
   15683          898 :   tree stmt;
   15684              : 
   15685          898 :   block = c_end_compound_stmt (loc, block, true);
   15686              : 
   15687          898 :   stmt = make_node (OMP_TASK);
   15688          898 :   TREE_TYPE (stmt) = void_type_node;
   15689          898 :   OMP_TASK_CLAUSES (stmt) = clauses;
   15690          898 :   OMP_TASK_BODY (stmt) = block;
   15691          898 :   SET_EXPR_LOCATION (stmt, loc);
   15692              : 
   15693          898 :   return add_stmt (stmt);
   15694              : }
   15695              : 
   15696              : /* Generate GOMP_cancel call for #pragma omp cancel.  */
   15697              : 
   15698              : void
   15699          213 : c_finish_omp_cancel (location_t loc, tree clauses)
   15700              : {
   15701          213 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCEL);
   15702          213 :   int mask = 0;
   15703          213 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   15704              :     mask = 1;
   15705          150 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   15706              :     mask = 2;
   15707          101 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   15708              :     mask = 4;
   15709           58 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   15710              :     mask = 8;
   15711              :   else
   15712              :     {
   15713            0 :       error_at (loc, "%<#pragma omp cancel%> must specify one of "
   15714              :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   15715              :                      "clauses");
   15716            0 :       return;
   15717              :     }
   15718          213 :   tree ifc = omp_find_clause (clauses, OMP_CLAUSE_IF);
   15719          213 :   if (ifc != NULL_TREE)
   15720              :     {
   15721           31 :       if (OMP_CLAUSE_IF_MODIFIER (ifc) != ERROR_MARK
   15722           31 :           && OMP_CLAUSE_IF_MODIFIER (ifc) != VOID_CST)
   15723            2 :         error_at (OMP_CLAUSE_LOCATION (ifc),
   15724              :                   "expected %<cancel%> %<if%> clause modifier");
   15725              :       else
   15726              :         {
   15727           29 :           tree ifc2 = omp_find_clause (OMP_CLAUSE_CHAIN (ifc), OMP_CLAUSE_IF);
   15728           29 :           if (ifc2 != NULL_TREE)
   15729              :             {
   15730            1 :               gcc_assert (OMP_CLAUSE_IF_MODIFIER (ifc) == VOID_CST
   15731              :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != ERROR_MARK
   15732              :                           && OMP_CLAUSE_IF_MODIFIER (ifc2) != VOID_CST);
   15733            1 :               error_at (OMP_CLAUSE_LOCATION (ifc2),
   15734              :                         "expected %<cancel%> %<if%> clause modifier");
   15735              :             }
   15736              :         }
   15737              : 
   15738           31 :       tree type = TREE_TYPE (OMP_CLAUSE_IF_EXPR (ifc));
   15739           62 :       ifc = fold_build2_loc (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
   15740           31 :                              boolean_type_node, OMP_CLAUSE_IF_EXPR (ifc),
   15741              :                              build_zero_cst (type));
   15742              :     }
   15743              :   else
   15744          182 :     ifc = boolean_true_node;
   15745          213 :   tree stmt = build_call_expr_loc (loc, fn, 2,
   15746          213 :                                    build_int_cst (integer_type_node, mask),
   15747              :                                    ifc);
   15748          213 :   add_stmt (stmt);
   15749              : }
   15750              : 
   15751              : /* Generate GOMP_cancellation_point call for
   15752              :    #pragma omp cancellation point.  */
   15753              : 
   15754              : void
   15755          167 : c_finish_omp_cancellation_point (location_t loc, tree clauses)
   15756              : {
   15757          167 :   tree fn = builtin_decl_explicit (BUILT_IN_GOMP_CANCELLATION_POINT);
   15758          167 :   int mask = 0;
   15759          167 :   if (omp_find_clause (clauses, OMP_CLAUSE_PARALLEL))
   15760              :     mask = 1;
   15761          123 :   else if (omp_find_clause (clauses, OMP_CLAUSE_FOR))
   15762              :     mask = 2;
   15763           88 :   else if (omp_find_clause (clauses, OMP_CLAUSE_SECTIONS))
   15764              :     mask = 4;
   15765           53 :   else if (omp_find_clause (clauses, OMP_CLAUSE_TASKGROUP))
   15766              :     mask = 8;
   15767              :   else
   15768              :     {
   15769            1 :       error_at (loc, "%<#pragma omp cancellation point%> must specify one of "
   15770              :                      "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> "
   15771              :                      "clauses");
   15772            1 :       return;
   15773              :     }
   15774          166 :   tree stmt = build_call_expr_loc (loc, fn, 1,
   15775          166 :                                    build_int_cst (integer_type_node, mask));
   15776          166 :   add_stmt (stmt);
   15777              : }
   15778              : 
   15779              : /* Helper function for handle_omp_array_sections.  Called recursively
   15780              :    to handle multiple array-section-subscripts.  C is the clause,
   15781              :    T current expression (initially OMP_CLAUSE_DECL), which is either
   15782              :    a TREE_LIST for array-section-subscript (TREE_PURPOSE is low-bound
   15783              :    expression if specified, TREE_VALUE length expression if specified,
   15784              :    TREE_CHAIN is what it has been specified after, or some decl.
   15785              :    TYPES vector is populated with array section types, MAYBE_ZERO_LEN
   15786              :    set to true if any of the array-section-subscript could have length
   15787              :    of zero (explicit or implicit), FIRST_NON_ONE is the index of the
   15788              :    first array-section-subscript which is known not to have length
   15789              :    of one.  Given say:
   15790              :    map(a[:b][2:1][:c][:2][:d][e:f][2:5])
   15791              :    FIRST_NON_ONE will be 3, array-section-subscript [:b], [2:1] and [:c]
   15792              :    all are or may have length of 1, array-section-subscript [:2] is the
   15793              :    first one known not to have length 1.  For array-section-subscript
   15794              :    <= FIRST_NON_ONE we diagnose non-contiguous arrays if low bound isn't
   15795              :    0 or length isn't the array domain max + 1, for > FIRST_NON_ONE we
   15796              :    can if MAYBE_ZERO_LEN is false.  MAYBE_ZERO_LEN will be true in the above
   15797              :    case though, as some lengths could be zero.  */
   15798              : 
   15799              : static tree
   15800         6394 : handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
   15801              :                              bool &maybe_zero_len, unsigned int &first_non_one,
   15802              :                              enum c_omp_region_type ort)
   15803              : {
   15804         6394 :   tree ret, low_bound, length, type;
   15805         6394 :   bool openacc = (ort & C_ORT_ACC) != 0;
   15806         6394 :   if (TREE_CODE (t) != OMP_ARRAY_SECTION)
   15807              :     {
   15808         2978 :       if (error_operand_p (t))
   15809            2 :         return error_mark_node;
   15810         2976 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   15811         2976 :       ret = t;
   15812         2976 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15813         2877 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15814         5539 :           && TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   15815              :         {
   15816            6 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qE in %qs clause",
   15817            6 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15818            6 :           return error_mark_node;
   15819              :         }
   15820         2970 :       if (!ai.check_clause (c))
   15821            0 :         return error_mark_node;
   15822         2970 :       else if (ai.component_access_p ()
   15823         3271 :                && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15824           15 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO
   15825           11 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FROM))
   15826          301 :         t = ai.get_root_term (true);
   15827              :       else
   15828         2669 :         t = ai.unconverted_ref_origin ();
   15829         2970 :       if (t == error_mark_node)
   15830              :         return error_mark_node;
   15831         2970 :       if (!VAR_P (t)
   15832          741 :           && (ort == C_ORT_ACC || !EXPR_P (t))
   15833          738 :           && TREE_CODE (t) != PARM_DECL)
   15834              :         {
   15835            5 :           if (DECL_P (t))
   15836            5 :             error_at (OMP_CLAUSE_LOCATION (c),
   15837              :                       "%qD is not a variable in %qs clause", t,
   15838            5 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15839              :           else
   15840            0 :             error_at (OMP_CLAUSE_LOCATION (c),
   15841              :                       "%qE is not a variable in %qs clause", t,
   15842            0 :                       omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15843            5 :           return error_mark_node;
   15844              :         }
   15845         2965 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15846         2867 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15847         5519 :                && TYPE_ATOMIC (TREE_TYPE (t)))
   15848              :         {
   15849            0 :           error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qD in %qs clause",
   15850            0 :                     t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15851            0 :           return error_mark_node;
   15852              :         }
   15853         2965 :       else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   15854         2867 :                && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   15855         2554 :                && VAR_P (t)
   15856         4971 :                && DECL_THREAD_LOCAL_P (t))
   15857              :         {
   15858            3 :           error_at (OMP_CLAUSE_LOCATION (c),
   15859              :                     "%qD is threadprivate variable in %qs clause", t,
   15860            3 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15861            3 :           return error_mark_node;
   15862              :         }
   15863         2962 :       if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15864         2864 :            || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND)
   15865          411 :           && TYPE_ATOMIC (TREE_TYPE (t))
   15866         2964 :           && POINTER_TYPE_P (TREE_TYPE (t)))
   15867              :         {
   15868              :           /* If the array section is pointer based and the pointer
   15869              :              itself is _Atomic qualified, we need to atomically load
   15870              :              the pointer.  */
   15871            2 :           ret = convert_lvalue_to_rvalue (OMP_CLAUSE_LOCATION (c),
   15872              :                                           ret, false, false);
   15873              :         }
   15874         2962 :       return ret;
   15875         2976 :     }
   15876              : 
   15877         3416 :   ret = handle_omp_array_sections_1 (c, TREE_OPERAND (t, 0), types,
   15878              :                                      maybe_zero_len, first_non_one, ort);
   15879         3416 :   if (ret == error_mark_node || ret == NULL_TREE)
   15880              :     return ret;
   15881              : 
   15882         3351 :   type = TREE_TYPE (ret);
   15883         3351 :   low_bound = TREE_OPERAND (t, 1);
   15884         3351 :   length = TREE_OPERAND (t, 2);
   15885              : 
   15886         3351 :   if (low_bound == error_mark_node || length == error_mark_node)
   15887              :     return error_mark_node;
   15888              : 
   15889         3351 :   if (low_bound && !INTEGRAL_TYPE_P (TREE_TYPE (low_bound)))
   15890              :     {
   15891           13 :       error_at (OMP_CLAUSE_LOCATION (c),
   15892              :                 "low bound %qE of array section does not have integral type",
   15893              :                 low_bound);
   15894           13 :       return error_mark_node;
   15895              :     }
   15896         3338 :   if (length && !INTEGRAL_TYPE_P (TREE_TYPE (length)))
   15897              :     {
   15898           12 :       error_at (OMP_CLAUSE_LOCATION (c),
   15899              :                 "length %qE of array section does not have integral type",
   15900              :                 length);
   15901           12 :       return error_mark_node;
   15902              :     }
   15903         3326 :   if (low_bound
   15904         2742 :       && TREE_CODE (low_bound) == INTEGER_CST
   15905         5779 :       && TYPE_PRECISION (TREE_TYPE (low_bound))
   15906         2453 :          > TYPE_PRECISION (sizetype))
   15907            0 :     low_bound = fold_convert (sizetype, low_bound);
   15908         3326 :   if (length
   15909         3138 :       && TREE_CODE (length) == INTEGER_CST
   15910         5519 :       && TYPE_PRECISION (TREE_TYPE (length))
   15911         2193 :          > TYPE_PRECISION (sizetype))
   15912            0 :     length = fold_convert (sizetype, length);
   15913         3326 :   if (low_bound == NULL_TREE)
   15914          584 :     low_bound = integer_zero_node;
   15915         3326 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   15916         3326 :       && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   15917         1936 :           || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH))
   15918              :     {
   15919           10 :       if (length != integer_one_node)
   15920              :         {
   15921            6 :           error_at (OMP_CLAUSE_LOCATION (c),
   15922              :                     "expected single pointer in %qs clause",
   15923              :                     user_omp_clause_code_name (c, openacc));
   15924            6 :           return error_mark_node;
   15925              :         }
   15926              :     }
   15927         3320 :   if (length != NULL_TREE)
   15928              :     {
   15929         3136 :       if (!integer_nonzerop (length))
   15930              :         {
   15931          974 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   15932              :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   15933              :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   15934              :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   15935              :               || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   15936              :             {
   15937          180 :               if (integer_zerop (length))
   15938              :                 {
   15939           12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15940              :                             "zero length array section in %qs clause",
   15941           12 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15942           12 :                   return error_mark_node;
   15943              :                 }
   15944              :             }
   15945              :           else
   15946          794 :             maybe_zero_len = true;
   15947              :         }
   15948         3124 :       if (first_non_one == types.length ()
   15949         3124 :           && (TREE_CODE (length) != INTEGER_CST || integer_onep (length)))
   15950         1597 :         first_non_one++;
   15951              :     }
   15952         3308 :   if (TREE_CODE (type) == ARRAY_TYPE)
   15953              :     {
   15954         1496 :       if (length == NULL_TREE
   15955         1496 :           && (TYPE_DOMAIN (type) == NULL_TREE
   15956          168 :               || TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE))
   15957              :         {
   15958            8 :           error_at (OMP_CLAUSE_LOCATION (c),
   15959              :                     "for unknown bound array type length expression must "
   15960              :                     "be specified");
   15961            8 :           return error_mark_node;
   15962              :         }
   15963         1488 :       if (TREE_CODE (low_bound) == INTEGER_CST
   15964         1488 :           && tree_int_cst_sgn (low_bound) == -1)
   15965              :         {
   15966           35 :           error_at (OMP_CLAUSE_LOCATION (c),
   15967              :                     "negative low bound in array section in %qs clause",
   15968           35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15969           35 :           return error_mark_node;
   15970              :         }
   15971         1453 :       if (length != NULL_TREE
   15972         1297 :           && TREE_CODE (length) == INTEGER_CST
   15973         2310 :           && tree_int_cst_sgn (length) == -1)
   15974              :         {
   15975           35 :           error_at (OMP_CLAUSE_LOCATION (c),
   15976              :                     "negative length in array section in %qs clause",
   15977           35 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15978           35 :           return error_mark_node;
   15979              :         }
   15980         1418 :       if (TYPE_DOMAIN (type)
   15981         1407 :           && TYPE_MAX_VALUE (TYPE_DOMAIN (type))
   15982         2825 :           && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
   15983              :                         == INTEGER_CST)
   15984              :         {
   15985         1061 :           tree size
   15986         1061 :             = fold_convert (sizetype, TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
   15987         1061 :           size = size_binop (PLUS_EXPR, size, size_one_node);
   15988         1061 :           if (TREE_CODE (low_bound) == INTEGER_CST)
   15989              :             {
   15990          874 :               if (tree_int_cst_lt (size, low_bound))
   15991              :                 {
   15992           10 :                   error_at (OMP_CLAUSE_LOCATION (c),
   15993              :                             "low bound %qE above array section size "
   15994              :                             "in %qs clause", low_bound,
   15995           10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   15996           10 :                   return error_mark_node;
   15997              :                 }
   15998          864 :               if (tree_int_cst_equal (size, low_bound))
   15999              :                 {
   16000            5 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY
   16001              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16002              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16003              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16004              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   16005              :                     {
   16006            5 :                       error_at (OMP_CLAUSE_LOCATION (c),
   16007              :                                 "zero length array section in %qs clause",
   16008            5 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16009            5 :                       return error_mark_node;
   16010              :                     }
   16011            0 :                   maybe_zero_len = true;
   16012              :                 }
   16013          859 :               else if (length == NULL_TREE
   16014          256 :                        && first_non_one == types.length ()
   16015          914 :                        && tree_int_cst_equal
   16016           55 :                             (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
   16017              :                              low_bound))
   16018           30 :                 first_non_one++;
   16019              :             }
   16020          187 :           else if (length == NULL_TREE)
   16021              :             {
   16022            3 :               if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   16023              :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   16024              :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   16025              :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   16026              :                   && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   16027            0 :                 maybe_zero_len = true;
   16028            6 :               if (first_non_one == types.length ())
   16029            1 :                 first_non_one++;
   16030              :             }
   16031         1046 :           if (length && TREE_CODE (length) == INTEGER_CST)
   16032              :             {
   16033          799 :               if (tree_int_cst_lt (size, length))
   16034              :                 {
   16035           11 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16036              :                             "length %qE above array section size "
   16037              :                             "in %qs clause", length,
   16038           11 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16039           11 :                   return error_mark_node;
   16040              :                 }
   16041          788 :               if (TREE_CODE (low_bound) == INTEGER_CST)
   16042              :                 {
   16043          688 :                   tree lbpluslen
   16044          688 :                     = size_binop (PLUS_EXPR,
   16045              :                                   fold_convert (sizetype, low_bound),
   16046              :                                   fold_convert (sizetype, length));
   16047          688 :                   if (TREE_CODE (lbpluslen) == INTEGER_CST
   16048          688 :                       && tree_int_cst_lt (size, lbpluslen))
   16049              :                     {
   16050           10 :                       error_at (OMP_CLAUSE_LOCATION (c),
   16051              :                                 "high bound %qE above array section size "
   16052              :                                 "in %qs clause", lbpluslen,
   16053           10 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16054           10 :                       return error_mark_node;
   16055              :                     }
   16056              :                 }
   16057              :             }
   16058              :         }
   16059          357 :       else if (length == NULL_TREE)
   16060              :         {
   16061           10 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   16062              :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   16063              :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   16064              :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IN_REDUCTION
   16065              :               && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_TASK_REDUCTION)
   16066            0 :             maybe_zero_len = true;
   16067           20 :           if (first_non_one == types.length ())
   16068           10 :             first_non_one++;
   16069              :         }
   16070              : 
   16071              :       /* For [lb:] we will need to evaluate lb more than once.  */
   16072          929 :       if (length == NULL_TREE && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   16073              :         {
   16074          127 :           tree lb = save_expr (low_bound);
   16075          127 :           if (lb != low_bound)
   16076              :             {
   16077            2 :               TREE_OPERAND (t, 1) = lb;
   16078            2 :               low_bound = lb;
   16079              :             }
   16080              :         }
   16081              :     }
   16082         1812 :   else if (TREE_CODE (type) == POINTER_TYPE)
   16083              :     {
   16084         1801 :       if (length == NULL_TREE)
   16085              :         {
   16086           10 :           if (TREE_CODE (ret) == PARM_DECL && C_ARRAY_PARAMETER (ret))
   16087            8 :             error_at (OMP_CLAUSE_LOCATION (c),
   16088              :                       "for array function parameter length expression "
   16089              :                       "must be specified");
   16090              :           else
   16091            2 :             error_at (OMP_CLAUSE_LOCATION (c),
   16092              :                       "for pointer type length expression must be specified");
   16093           10 :           return error_mark_node;
   16094              :         }
   16095         1791 :       if (length != NULL_TREE
   16096         1791 :           && TREE_CODE (length) == INTEGER_CST
   16097         1286 :           && tree_int_cst_sgn (length) == -1)
   16098              :         {
   16099           20 :           error_at (OMP_CLAUSE_LOCATION (c),
   16100              :                     "negative length in array section in %qs clause",
   16101           20 :                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16102           20 :           return error_mark_node;
   16103              :         }
   16104              :       /* If there is a pointer type anywhere but in the very first
   16105              :          array-section-subscript, the array section could be non-contiguous.  */
   16106         1771 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND
   16107         1610 :           && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY
   16108         3352 :           && TREE_CODE (TREE_OPERAND (t, 0)) == OMP_ARRAY_SECTION)
   16109              :         {
   16110              :           /* If any prior dimension has a non-one length, then deem this
   16111              :              array section as non-contiguous.  */
   16112           42 :           for (tree d = TREE_OPERAND (t, 0);
   16113           82 :                TREE_CODE (d) == OMP_ARRAY_SECTION;
   16114           40 :                d = TREE_OPERAND (d, 0))
   16115              :             {
   16116           44 :               tree d_length = TREE_OPERAND (d, 2);
   16117           44 :               if (d_length == NULL_TREE || !integer_onep (d_length))
   16118              :                 {
   16119            4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16120              :                             "array section is not contiguous in %qs clause",
   16121            4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16122            4 :                   return error_mark_node;
   16123              :                 }
   16124              :             }
   16125              :         }
   16126              :     }
   16127              :   else
   16128              :     {
   16129           11 :       error_at (OMP_CLAUSE_LOCATION (c),
   16130              :                 "%qE does not have pointer or array type", ret);
   16131           11 :       return error_mark_node;
   16132              :     }
   16133         3149 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND)
   16134         2833 :     types.safe_push (TREE_TYPE (ret));
   16135              :   /* We will need to evaluate lb more than once.  */
   16136         3149 :   tree lb = save_expr (low_bound);
   16137         3149 :   if (lb != low_bound)
   16138              :     {
   16139          273 :       TREE_OPERAND (t, 1) = lb;
   16140          273 :       low_bound = lb;
   16141              :     }
   16142         3149 :   ret = build_array_ref (OMP_CLAUSE_LOCATION (c), ret, low_bound);
   16143         3149 :   return ret;
   16144              : }
   16145              : 
   16146              : /* Handle array sections for clause C.  */
   16147              : 
   16148              : static bool
   16149         2978 : handle_omp_array_sections (tree &c, enum c_omp_region_type ort)
   16150              : {
   16151         2978 :   bool maybe_zero_len = false;
   16152         2978 :   unsigned int first_non_one = 0;
   16153         2978 :   auto_vec<tree, 10> types;
   16154         2978 :   tree *tp = &OMP_CLAUSE_DECL (c);
   16155         2978 :   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16156         2664 :        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   16157         3077 :       && OMP_ITERATOR_DECL_P (*tp))
   16158           66 :     tp = &TREE_VALUE (*tp);
   16159         2978 :   tree first = handle_omp_array_sections_1 (c, *tp, types,
   16160              :                                             maybe_zero_len, first_non_one,
   16161              :                                             ort);
   16162         2978 :   if (first == error_mark_node)
   16163              :     return true;
   16164         2760 :   if (first == NULL_TREE)
   16165              :     return false;
   16166         2760 :   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   16167         2760 :       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY)
   16168              :     {
   16169          336 :       tree t = *tp;
   16170          336 :       tree tem = NULL_TREE;
   16171              :       /* Need to evaluate side effects in the length expressions
   16172              :          if any.  */
   16173          336 :       while (TREE_CODE (t) == TREE_LIST)
   16174              :         {
   16175            0 :           if (TREE_VALUE (t) && TREE_SIDE_EFFECTS (TREE_VALUE (t)))
   16176              :             {
   16177            0 :               if (tem == NULL_TREE)
   16178              :                 tem = TREE_VALUE (t);
   16179              :               else
   16180            0 :                 tem = build2 (COMPOUND_EXPR, TREE_TYPE (tem),
   16181            0 :                               TREE_VALUE (t), tem);
   16182              :             }
   16183            0 :           t = TREE_CHAIN (t);
   16184              :         }
   16185          336 :       if (tem)
   16186            0 :         first = build2 (COMPOUND_EXPR, TREE_TYPE (first), tem, first);
   16187          336 :       first = c_fully_fold (first, false, NULL, true);
   16188          336 :       *tp = first;
   16189              :     }
   16190              :   else
   16191              :     {
   16192         2424 :       unsigned int num = types.length (), i;
   16193         2424 :       tree t, side_effects = NULL_TREE, size = NULL_TREE;
   16194         2424 :       tree condition = NULL_TREE;
   16195              : 
   16196         2424 :       if (int_size_in_bytes (TREE_TYPE (first)) <= 0)
   16197            3 :         maybe_zero_len = true;
   16198              : 
   16199         5048 :       for (i = num, t = OMP_CLAUSE_DECL (c); i > 0;
   16200         2624 :            t = TREE_OPERAND (t, 0))
   16201              :         {
   16202         2639 :           tree low_bound = TREE_OPERAND (t, 1);
   16203         2639 :           tree length = TREE_OPERAND (t, 2);
   16204              : 
   16205         2639 :           i--;
   16206         2639 :           if (low_bound
   16207         2175 :               && TREE_CODE (low_bound) == INTEGER_CST
   16208         4628 :               && TYPE_PRECISION (TREE_TYPE (low_bound))
   16209         1989 :                  > TYPE_PRECISION (sizetype))
   16210            0 :             low_bound = fold_convert (sizetype, low_bound);
   16211         2639 :           if (length
   16212         2547 :               && TREE_CODE (length) == INTEGER_CST
   16213         4259 :               && TYPE_PRECISION (TREE_TYPE (length))
   16214         1620 :                  > TYPE_PRECISION (sizetype))
   16215            0 :             length = fold_convert (sizetype, length);
   16216         2639 :           if (low_bound == NULL_TREE)
   16217          464 :             low_bound = integer_zero_node;
   16218         2639 :           if (!maybe_zero_len && i > first_non_one)
   16219              :             {
   16220          109 :               if (integer_nonzerop (low_bound))
   16221            6 :                 goto do_warn_noncontiguous;
   16222          103 :               if (length != NULL_TREE
   16223           50 :                   && TREE_CODE (length) == INTEGER_CST
   16224           50 :                   && TYPE_DOMAIN (types[i])
   16225           50 :                   && TYPE_MAX_VALUE (TYPE_DOMAIN (types[i]))
   16226          153 :                   && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])))
   16227              :                      == INTEGER_CST)
   16228              :                 {
   16229           50 :                   tree size;
   16230           50 :                   size = size_binop (PLUS_EXPR,
   16231              :                                      TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   16232              :                                      size_one_node);
   16233           50 :                   if (!tree_int_cst_equal (length, size))
   16234              :                     {
   16235            7 :                      do_warn_noncontiguous:
   16236           26 :                       error_at (OMP_CLAUSE_LOCATION (c),
   16237              :                                 "array section is not contiguous in %qs "
   16238              :                                 "clause",
   16239           13 :                                 omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16240         2424 :                       return true;
   16241              :                     }
   16242              :                 }
   16243           96 :               if (length != NULL_TREE
   16244           96 :                   && TREE_SIDE_EFFECTS (length))
   16245              :                 {
   16246            0 :                   if (side_effects == NULL_TREE)
   16247              :                     side_effects = length;
   16248              :                   else
   16249            0 :                     side_effects = build2 (COMPOUND_EXPR,
   16250            0 :                                            TREE_TYPE (side_effects),
   16251              :                                            length, side_effects);
   16252              :                 }
   16253              :             }
   16254              :           else
   16255              :             {
   16256         2530 :               tree l;
   16257              : 
   16258         2530 :               if (i > first_non_one
   16259         2530 :                   && ((length && integer_nonzerop (length))
   16260            0 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16261              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16262              :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION))
   16263            0 :                 continue;
   16264         2530 :               if (length)
   16265         2497 :                 l = fold_convert (sizetype, length);
   16266              :               else
   16267              :                 {
   16268           33 :                   l = size_binop (PLUS_EXPR,
   16269              :                                   TYPE_MAX_VALUE (TYPE_DOMAIN (types[i])),
   16270              :                                   size_one_node);
   16271           33 :                   l = size_binop (MINUS_EXPR, l,
   16272              :                                   fold_convert (sizetype, low_bound));
   16273              :                 }
   16274         2530 :               if (i > first_non_one)
   16275              :                 {
   16276            0 :                   l = fold_build2 (NE_EXPR, boolean_type_node, l,
   16277              :                                    size_zero_node);
   16278            0 :                   if (condition == NULL_TREE)
   16279              :                     condition = l;
   16280              :                   else
   16281            0 :                     condition = fold_build2 (BIT_AND_EXPR, boolean_type_node,
   16282              :                                              l, condition);
   16283              :                 }
   16284         2530 :               else if (size == NULL_TREE)
   16285              :                 {
   16286         2411 :                   size = size_in_bytes (TREE_TYPE (types[i]));
   16287         2411 :                   tree eltype = TREE_TYPE (types[num - 1]);
   16288         2431 :                   while (TREE_CODE (eltype) == ARRAY_TYPE)
   16289           20 :                     eltype = TREE_TYPE (eltype);
   16290         2411 :                   if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16291         2176 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16292         4327 :                       || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   16293              :                     {
   16294          539 :                       if (integer_zerop (size)
   16295         1076 :                           || integer_zerop (size_in_bytes (eltype)))
   16296              :                         {
   16297            4 :                           error_at (OMP_CLAUSE_LOCATION (c),
   16298              :                                     "zero length array section in %qs clause",
   16299            2 :                                     omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16300            2 :                           return error_mark_node;
   16301              :                         }
   16302          537 :                       size = size_binop (EXACT_DIV_EXPR, size,
   16303              :                                          size_in_bytes (eltype));
   16304              :                     }
   16305         2409 :                   size = size_binop (MULT_EXPR, size, l);
   16306         2409 :                   if (condition)
   16307            0 :                     size = fold_build3 (COND_EXPR, sizetype, condition,
   16308              :                                         size, size_zero_node);
   16309              :                 }
   16310              :               else
   16311          119 :                 size = size_binop (MULT_EXPR, size, l);
   16312              :             }
   16313              :         }
   16314         2409 :       if (side_effects)
   16315            0 :         size = build2 (COMPOUND_EXPR, sizetype, side_effects, size);
   16316         2409 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16317         2176 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   16318         4325 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TASK_REDUCTION)
   16319              :         {
   16320          537 :           size = size_binop (MINUS_EXPR, size, size_one_node);
   16321          537 :           size = c_fully_fold (size, false, NULL);
   16322          537 :           size = save_expr (size);
   16323          537 :           tree index_type = build_index_type (size);
   16324          537 :           tree eltype = TREE_TYPE (first);
   16325          549 :           while (TREE_CODE (eltype) == ARRAY_TYPE)
   16326           12 :             eltype = TREE_TYPE (eltype);
   16327          537 :           tree type = c_build_array_type (eltype, index_type);
   16328          537 :           tree ptype = c_build_pointer_type (eltype);
   16329          537 :           if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   16330          296 :             t = build_fold_addr_expr (t);
   16331          537 :           tree t2 = build_fold_addr_expr (first);
   16332          537 :           t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   16333              :                                  ptrdiff_type_node, t2);
   16334          537 :           t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   16335              :                                 ptrdiff_type_node, t2,
   16336          537 :                                 fold_convert_loc (OMP_CLAUSE_LOCATION (c),
   16337              :                                                   ptrdiff_type_node, t));
   16338          537 :           t2 = c_fully_fold (t2, false, NULL);
   16339          537 :           if (tree_fits_shwi_p (t2))
   16340          398 :             t = build2 (MEM_REF, type, t,
   16341          398 :                         build_int_cst (ptype, tree_to_shwi (t2)));
   16342              :           else
   16343              :             {
   16344          139 :               t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, t2);
   16345          139 :               t = build2_loc (OMP_CLAUSE_LOCATION (c), POINTER_PLUS_EXPR,
   16346          139 :                               TREE_TYPE (t), t, t2);
   16347          139 :               t = build2 (MEM_REF, type, t, build_int_cst (ptype, 0));
   16348              :             }
   16349          537 :           OMP_CLAUSE_DECL (c) = t;
   16350          537 :           return false;
   16351              :         }
   16352         1872 :       first = c_fully_fold (first, false, NULL);
   16353         1872 :       OMP_CLAUSE_DECL (c) = first;
   16354         1872 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
   16355              :         return false;
   16356              :       /* Don't set OMP_CLAUSE_SIZE for bare attach/detach clauses.  */
   16357         1861 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   16358         1861 :           || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   16359         1721 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH
   16360         1719 :               && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FORCE_DETACH))
   16361              :         {
   16362         1857 :           if (size)
   16363         1857 :             size = c_fully_fold (size, false, NULL);
   16364         1857 :           OMP_CLAUSE_SIZE (c) = size;
   16365              :         }
   16366              : 
   16367         1861 :       if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   16368              :         return false;
   16369              : 
   16370         1723 :       auto_vec<omp_addr_token *, 10> addr_tokens;
   16371              : 
   16372         1723 :       if (!omp_parse_expr (addr_tokens, first))
   16373         1723 :         return true;
   16374              : 
   16375         1723 :       c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   16376              : 
   16377         1723 :       tree nc = ai.expand_map_clause (c, first, addr_tokens, ort);
   16378         1723 :       if (nc != error_mark_node)
   16379              :         {
   16380         1723 :           using namespace omp_addr_tokenizer;
   16381              : 
   16382         1723 :           if (ai.maybe_zero_length_array_section (c))
   16383         1719 :             OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1;
   16384              : 
   16385              :           /* !!! If we're accessing a base decl via chained access
   16386              :              methods (e.g. multiple indirections), duplicate clause
   16387              :              detection won't work properly.  Skip it in that case.  */
   16388         1723 :           if ((addr_tokens[0]->type == STRUCTURE_BASE
   16389         1436 :                || addr_tokens[0]->type == ARRAY_BASE)
   16390         1723 :               && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   16391         1723 :               && addr_tokens[1]->type == ACCESS_METHOD
   16392         3446 :               && omp_access_chain_p (addr_tokens, 1))
   16393           34 :             c = nc;
   16394              : 
   16395         1723 :           return false;
   16396              :         }
   16397              :     }
   16398              :   return false;
   16399         2978 : }
   16400              : 
   16401              : /* Helper function of finish_omp_clauses.  Clone STMT as if we were making
   16402              :    an inline call.  But, remap
   16403              :    the OMP_DECL1 VAR_DECL (omp_out resp. omp_orig) to PLACEHOLDER
   16404              :    and OMP_DECL2 VAR_DECL (omp_in resp. omp_priv) to DECL.  */
   16405              : 
   16406              : static tree
   16407          510 : c_clone_omp_udr (tree stmt, tree omp_decl1, tree omp_decl2,
   16408              :                  tree decl, tree placeholder)
   16409              : {
   16410          510 :   copy_body_data id;
   16411          510 :   hash_map<tree, tree> decl_map;
   16412              : 
   16413          510 :   decl_map.put (omp_decl1, placeholder);
   16414          510 :   decl_map.put (omp_decl2, decl);
   16415          510 :   memset (&id, 0, sizeof (id));
   16416          510 :   id.src_fn = DECL_CONTEXT (omp_decl1);
   16417          510 :   id.dst_fn = current_function_decl;
   16418          510 :   id.src_cfun = DECL_STRUCT_FUNCTION (id.src_fn);
   16419          510 :   id.decl_map = &decl_map;
   16420              : 
   16421          510 :   id.copy_decl = copy_decl_no_change;
   16422          510 :   id.transform_call_graph_edges = CB_CGE_DUPLICATE;
   16423          510 :   id.transform_new_cfg = true;
   16424          510 :   id.transform_return_to_modify = false;
   16425          510 :   id.eh_lp_nr = 0;
   16426          510 :   walk_tree (&stmt, copy_tree_body_r, &id, NULL);
   16427          510 :   return stmt;
   16428          510 : }
   16429              : 
   16430              : /* Helper function of c_finish_omp_clauses, called via walk_tree.
   16431              :    Find OMP_CLAUSE_PLACEHOLDER (passed in DATA) in *TP.  */
   16432              : 
   16433              : static tree
   16434         1123 : c_find_omp_placeholder_r (tree *tp, int *, void *data)
   16435              : {
   16436         1123 :   if (*tp == (tree) data)
   16437           28 :     return *tp;
   16438              :   return NULL_TREE;
   16439              : }
   16440              : 
   16441              : /* Similarly, but also walk aggregate fields.  */
   16442              : 
   16443              : struct c_find_omp_var_s { tree var; hash_set<tree> *pset; };
   16444              : 
   16445              : static tree
   16446          288 : c_find_omp_var_r (tree *tp, int *, void *data)
   16447              : {
   16448          288 :   if (*tp == ((struct c_find_omp_var_s *) data)->var)
   16449              :     return *tp;
   16450          280 :   if (RECORD_OR_UNION_TYPE_P (*tp))
   16451              :     {
   16452            2 :       tree field;
   16453            2 :       hash_set<tree> *pset = ((struct c_find_omp_var_s *) data)->pset;
   16454              : 
   16455            2 :       for (field = TYPE_FIELDS (*tp); field;
   16456            0 :            field = DECL_CHAIN (field))
   16457            2 :         if (TREE_CODE (field) == FIELD_DECL)
   16458              :           {
   16459            2 :             tree ret = walk_tree (&DECL_FIELD_OFFSET (field),
   16460              :                                   c_find_omp_var_r, data, pset);
   16461            2 :             if (ret)
   16462              :               return ret;
   16463            2 :             ret = walk_tree (&DECL_SIZE (field), c_find_omp_var_r, data, pset);
   16464            2 :             if (ret)
   16465              :               return ret;
   16466            2 :             ret = walk_tree (&DECL_SIZE_UNIT (field), c_find_omp_var_r, data,
   16467              :                              pset);
   16468            2 :             if (ret)
   16469              :               return ret;
   16470            2 :             ret = walk_tree (&TREE_TYPE (field), c_find_omp_var_r, data, pset);
   16471            2 :             if (ret)
   16472              :               return ret;
   16473              :           }
   16474              :     }
   16475          278 :   else if (INTEGRAL_TYPE_P (*tp))
   16476           45 :     return walk_tree (&TYPE_MAX_VALUE (*tp), c_find_omp_var_r, data,
   16477              :                       ((struct c_find_omp_var_s *) data)->pset);
   16478              :   return NULL_TREE;
   16479              : }
   16480              : 
   16481              : /* Finish OpenMP iterators ITER.  Return true if they are erroneous
   16482              :    and clauses containing them should be removed.  */
   16483              : 
   16484              : static bool
   16485          143 : c_omp_finish_iterators (tree iter)
   16486              : {
   16487          143 :   bool ret = false;
   16488          325 :   for (tree it = iter; it; it = TREE_CHAIN (it))
   16489              :     {
   16490          182 :       tree var = TREE_VEC_ELT (it, 0);
   16491          182 :       tree begin = TREE_VEC_ELT (it, 1);
   16492          182 :       tree end = TREE_VEC_ELT (it, 2);
   16493          182 :       tree step = TREE_VEC_ELT (it, 3);
   16494          182 :       tree orig_step;
   16495          182 :       tree type = TREE_TYPE (var);
   16496          182 :       location_t loc = DECL_SOURCE_LOCATION (var);
   16497          182 :       if (type == error_mark_node)
   16498              :         {
   16499            0 :           ret = true;
   16500           34 :           continue;
   16501              :         }
   16502          182 :       if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
   16503              :         {
   16504            6 :           error_at (loc, "iterator %qD has neither integral nor pointer type",
   16505              :                     var);
   16506            6 :           ret = true;
   16507            6 :           continue;
   16508              :         }
   16509          176 :       else if (TYPE_ATOMIC (type))
   16510              :         {
   16511            2 :           error_at (loc, "iterator %qD has %<_Atomic%> qualified type", var);
   16512            2 :           ret = true;
   16513            2 :           continue;
   16514              :         }
   16515          174 :       else if (TYPE_READONLY (type))
   16516              :         {
   16517            4 :           error_at (loc, "iterator %qD has const qualified type", var);
   16518            4 :           ret = true;
   16519            4 :           continue;
   16520              :         }
   16521          170 :       else if (step == error_mark_node
   16522          170 :                || TREE_TYPE (step) == error_mark_node)
   16523              :         {
   16524            0 :           ret = true;
   16525            0 :           continue;
   16526              :         }
   16527          170 :       else if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
   16528              :         {
   16529            6 :           error_at (EXPR_LOC_OR_LOC (step, loc),
   16530              :                     "iterator step with non-integral type");
   16531            4 :           ret = true;
   16532            4 :           continue;
   16533              :         }
   16534          166 :       begin = c_fully_fold (build_c_cast (loc, type, begin), false, NULL);
   16535          166 :       end = c_fully_fold (build_c_cast (loc, type, end), false, NULL);
   16536          166 :       orig_step = save_expr (c_fully_fold (step, false, NULL));
   16537          166 :       tree stype = POINTER_TYPE_P (type) ? sizetype : type;
   16538          166 :       step = c_fully_fold (build_c_cast (loc, stype, orig_step), false, NULL);
   16539          166 :       if (POINTER_TYPE_P (type))
   16540              :         {
   16541           14 :           begin = save_expr (begin);
   16542           14 :           step = pointer_int_sum (loc, PLUS_EXPR, begin, step);
   16543           14 :           step = fold_build2_loc (loc, MINUS_EXPR, sizetype,
   16544              :                                   fold_convert (sizetype, step),
   16545              :                                   fold_convert (sizetype, begin));
   16546           14 :           step = fold_convert (ssizetype, step);
   16547              :         }
   16548          166 :       if (integer_zerop (step))
   16549              :         {
   16550            6 :           error_at (loc, "iterator %qD has zero step", var);
   16551            6 :           ret = true;
   16552            6 :           continue;
   16553              :         }
   16554              : 
   16555          160 :       if (begin == error_mark_node
   16556          158 :           || end == error_mark_node
   16557          156 :           || step == error_mark_node
   16558          156 :           || orig_step == error_mark_node)
   16559              :         {
   16560            4 :           ret = true;
   16561            4 :           continue;
   16562              :         }
   16563          156 :       hash_set<tree> pset;
   16564          156 :       tree it2;
   16565          197 :       for (it2 = TREE_CHAIN (it); it2; it2 = TREE_CHAIN (it2))
   16566              :         {
   16567           49 :           tree var2 = TREE_VEC_ELT (it2, 0);
   16568           49 :           tree begin2 = TREE_VEC_ELT (it2, 1);
   16569           49 :           tree end2 = TREE_VEC_ELT (it2, 2);
   16570           49 :           tree step2 = TREE_VEC_ELT (it2, 3);
   16571           49 :           tree type2 = TREE_TYPE (var2);
   16572           49 :           location_t loc2 = DECL_SOURCE_LOCATION (var2);
   16573           49 :           struct c_find_omp_var_s data = { var, &pset };
   16574           49 :           if (walk_tree (&type2, c_find_omp_var_r, &data, &pset))
   16575              :             {
   16576            2 :               error_at (loc2,
   16577              :                         "type of iterator %qD refers to outer iterator %qD",
   16578              :                         var2, var);
   16579           10 :               break;
   16580              :             }
   16581           47 :           else if (walk_tree (&begin2, c_find_omp_var_r, &data, &pset))
   16582              :             {
   16583            2 :               error_at (EXPR_LOC_OR_LOC (begin2, loc2),
   16584              :                         "begin expression refers to outer iterator %qD", var);
   16585            2 :               break;
   16586              :             }
   16587           45 :           else if (walk_tree (&end2, c_find_omp_var_r, &data, &pset))
   16588              :             {
   16589            2 :               error_at (EXPR_LOC_OR_LOC (end2, loc2),
   16590              :                         "end expression refers to outer iterator %qD", var);
   16591            2 :               break;
   16592              :             }
   16593           43 :           else if (walk_tree (&step2, c_find_omp_var_r, &data, &pset))
   16594              :             {
   16595            2 :               error_at (EXPR_LOC_OR_LOC (step2, loc2),
   16596              :                         "step expression refers to outer iterator %qD", var);
   16597            2 :               break;
   16598              :             }
   16599              :         }
   16600          156 :       if (it2)
   16601              :         {
   16602            8 :           ret = true;
   16603            8 :           continue;
   16604              :         }
   16605          148 :       TREE_VEC_ELT (it, 1) = begin;
   16606          148 :       TREE_VEC_ELT (it, 2) = end;
   16607          148 :       TREE_VEC_ELT (it, 3) = step;
   16608          148 :       TREE_VEC_ELT (it, 4) = orig_step;
   16609          156 :     }
   16610          143 :   return ret;
   16611              : }
   16612              : 
   16613              : /* Ensure that pointers are used in OpenACC attach and detach clauses.
   16614              :    Return true if an error has been detected.  */
   16615              : 
   16616              : static bool
   16617         9615 : c_oacc_check_attachments (tree c)
   16618              : {
   16619         9615 :   if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   16620              :     return false;
   16621              : 
   16622              :   /* OpenACC attach / detach clauses must be pointers.  */
   16623         6592 :   if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   16624         6592 :       || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   16625              :     {
   16626           71 :       tree t = OMP_CLAUSE_DECL (c);
   16627              : 
   16628           77 :       while (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16629            6 :         t = TREE_OPERAND (t, 0);
   16630              : 
   16631           71 :       if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   16632              :         {
   16633            6 :           error_at (OMP_CLAUSE_LOCATION (c), "expected pointer in %qs clause",
   16634              :                     user_omp_clause_code_name (c, true));
   16635            6 :           return true;
   16636              :         }
   16637              :     }
   16638              : 
   16639              :   return false;
   16640              : }
   16641              : 
   16642              : /* For all elements of CLAUSES, validate them against their constraints.
   16643              :    Remove any elements from the list that are invalid.  */
   16644              : 
   16645              : tree
   16646        29559 : c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
   16647              : {
   16648        29559 :   bitmap_head generic_head, firstprivate_head, lastprivate_head;
   16649        29559 :   bitmap_head aligned_head, map_head, map_field_head, map_firstprivate_head;
   16650        29559 :   bitmap_head oacc_reduction_head, is_on_device_head;
   16651        29559 :   tree c, t, type, *pc;
   16652        29559 :   tree simdlen = NULL_TREE, safelen = NULL_TREE;
   16653        29559 :   bool branch_seen = false;
   16654        29559 :   bool copyprivate_seen = false;
   16655        29559 :   bool mergeable_seen = false;
   16656        29559 :   tree *detach_seen = NULL;
   16657        29559 :   bool linear_variable_step_check = false;
   16658        29559 :   tree *nowait_clause = NULL;
   16659        29559 :   tree *grainsize_seen = NULL;
   16660        29559 :   bool num_tasks_seen = false;
   16661        29559 :   tree ordered_clause = NULL_TREE;
   16662        29559 :   tree schedule_clause = NULL_TREE;
   16663        29559 :   bool oacc_async = false;
   16664        29559 :   tree last_iterators = NULL_TREE;
   16665        29559 :   bool last_iterators_remove = false;
   16666        29559 :   tree *nogroup_seen = NULL;
   16667        29559 :   tree *order_clause = NULL;
   16668              :   /* 1 if normal/task reduction has been seen, -1 if inscan reduction
   16669              :      has been seen, -2 if mixed inscan/normal reduction diagnosed.  */
   16670        29559 :   int reduction_seen = 0;
   16671        29559 :   bool allocate_seen = false;
   16672        29559 :   bool implicit_moved = false;
   16673        29559 :   bool target_in_reduction_seen = false;
   16674        29559 :   tree *full_seen = NULL;
   16675        29559 :   bool partial_seen = false;
   16676        29559 :   bool openacc = (ort & C_ORT_ACC) != 0;
   16677        29559 :   bool init_seen = false;
   16678        29559 :   bool init_use_destroy_seen = false;
   16679        29559 :   tree init_no_targetsync_clause = NULL_TREE;
   16680        29559 :   tree depend_clause = NULL_TREE;
   16681              : 
   16682        29559 :   if (!openacc)
   16683        24322 :     clauses = omp_remove_duplicate_maps (clauses, true);
   16684              : 
   16685        29559 :   bitmap_obstack_initialize (NULL);
   16686        29559 :   bitmap_initialize (&generic_head, &bitmap_default_obstack);
   16687        29559 :   bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
   16688        29559 :   bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
   16689        29559 :   bitmap_initialize (&aligned_head, &bitmap_default_obstack);
   16690              :   /* If ort == C_ORT_OMP_DECLARE_SIMD used as uniform_head instead.  */
   16691        29559 :   bitmap_initialize (&map_head, &bitmap_default_obstack);
   16692        29559 :   bitmap_initialize (&map_field_head, &bitmap_default_obstack);
   16693        29559 :   bitmap_initialize (&map_firstprivate_head, &bitmap_default_obstack);
   16694              :   /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head
   16695              :      instead and for ort == C_ORT_OMP_TARGET used as in_reduction_head.  */
   16696        29559 :   bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack);
   16697        29559 :   bitmap_initialize (&is_on_device_head, &bitmap_default_obstack);
   16698              : 
   16699        29559 :   if (openacc)
   16700        12269 :     for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   16701         7258 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ASYNC)
   16702              :         {
   16703              :           oacc_async = true;
   16704              :           break;
   16705              :         }
   16706              : 
   16707        29559 :   tree *grp_start_p = NULL, grp_sentinel = NULL_TREE;
   16708              : 
   16709        77599 :   for (pc = &clauses, c = clauses; c ; c = *pc)
   16710              :     {
   16711        48040 :       bool remove = false;
   16712        48040 :       bool need_complete = false;
   16713        48040 :       bool need_implicitly_determined = false;
   16714              : 
   16715              :       /* We've reached the end of a list of expanded nodes.  Reset the group
   16716              :          start pointer.  */
   16717        48040 :       if (c == grp_sentinel)
   16718              :         {
   16719         2507 :           if (grp_start_p
   16720         2507 :               && OMP_CLAUSE_HAS_ITERATORS (*grp_start_p))
   16721           32 :             for (tree gc = *grp_start_p; gc != grp_sentinel;
   16722           22 :                  gc = OMP_CLAUSE_CHAIN (gc))
   16723           22 :               OMP_CLAUSE_ITERATORS (gc) = OMP_CLAUSE_ITERATORS (*grp_start_p);
   16724              :           grp_start_p = NULL;
   16725              :         }
   16726              : 
   16727        48040 :       switch (OMP_CLAUSE_CODE (c))
   16728              :         {
   16729         1139 :         case OMP_CLAUSE_SHARED:
   16730         1139 :           need_implicitly_determined = true;
   16731         1139 :           goto check_dup_generic;
   16732              : 
   16733          847 :         case OMP_CLAUSE_PRIVATE:
   16734          847 :           need_complete = true;
   16735          847 :           need_implicitly_determined = true;
   16736          847 :           goto check_dup_generic;
   16737              : 
   16738         3519 :         case OMP_CLAUSE_REDUCTION:
   16739         3519 :           if (reduction_seen == 0)
   16740         2920 :             reduction_seen = OMP_CLAUSE_REDUCTION_INSCAN (c) ? -1 : 1;
   16741          599 :           else if (reduction_seen != -2
   16742         1198 :                    && reduction_seen != (OMP_CLAUSE_REDUCTION_INSCAN (c)
   16743          599 :                                          ? -1 : 1))
   16744              :             {
   16745            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16746              :                         "%<inscan%> and non-%<inscan%> %<reduction%> clauses "
   16747              :                         "on the same construct");
   16748            2 :               reduction_seen = -2;
   16749              :             }
   16750              :           /* FALLTHRU */
   16751         4183 :         case OMP_CLAUSE_IN_REDUCTION:
   16752         4183 :         case OMP_CLAUSE_TASK_REDUCTION:
   16753         4183 :           need_implicitly_determined = true;
   16754         4183 :           t = OMP_CLAUSE_DECL (c);
   16755         4183 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   16756              :             {
   16757          553 :               if (handle_omp_array_sections (c, ort))
   16758              :                 {
   16759              :                   remove = true;
   16760              :                   break;
   16761              :                 }
   16762              : 
   16763          537 :               t = OMP_CLAUSE_DECL (c);
   16764          537 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   16765          537 :                   && OMP_CLAUSE_REDUCTION_INSCAN (c))
   16766              :                 {
   16767            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16768              :                             "%<inscan%> %<reduction%> clause with array "
   16769              :                             "section");
   16770            1 :                   remove = true;
   16771            1 :                   break;
   16772              :                 }
   16773              :             }
   16774         4166 :           t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   16775         4166 :           if (t == error_mark_node)
   16776              :             {
   16777              :               remove = true;
   16778              :               break;
   16779              :             }
   16780         4164 :           if (oacc_async)
   16781            3 :             c_mark_addressable (t);
   16782         4164 :           type = TREE_TYPE (t);
   16783         4164 :           if (TREE_CODE (t) == MEM_REF)
   16784          536 :             type = TREE_TYPE (type);
   16785         4164 :           if (TREE_CODE (type) == ARRAY_TYPE)
   16786              :             {
   16787           74 :               tree oatype = type;
   16788           74 :               gcc_assert (TREE_CODE (t) != MEM_REF);
   16789          148 :               while (TREE_CODE (type) == ARRAY_TYPE)
   16790           74 :                 type = TREE_TYPE (type);
   16791           74 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   16792              :                 {
   16793            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16794              :                             "%qD in %<reduction%> clause is a zero size array",
   16795              :                             t);
   16796            1 :                   remove = true;
   16797            1 :                   break;
   16798              :                 }
   16799           73 :               tree size = size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (oatype),
   16800              :                                       TYPE_SIZE_UNIT (type));
   16801           73 :               if (integer_zerop (size))
   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           72 :               size = size_binop (MINUS_EXPR, size, size_one_node);
   16810           72 :               size = save_expr (size);
   16811           72 :               tree index_type = build_index_type (size);
   16812           72 :               tree atype = c_build_array_type (TYPE_MAIN_VARIANT (type),
   16813              :                                                index_type);
   16814           72 :               atype = c_build_qualified_type (atype, TYPE_QUALS (type));
   16815           72 :               tree ptype = c_build_pointer_type (type);
   16816           72 :               if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
   16817           72 :                 t = build_fold_addr_expr (t);
   16818           72 :               t = build2 (MEM_REF, atype, t, build_int_cst (ptype, 0));
   16819           72 :               OMP_CLAUSE_DECL (c) = t;
   16820              :             }
   16821         4162 :           if (TYPE_ATOMIC (type))
   16822              :             {
   16823            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   16824              :                         "%<_Atomic%> %qE in %<reduction%> clause", t);
   16825            3 :               remove = true;
   16826            3 :               break;
   16827              :             }
   16828         4159 :           if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION
   16829         4159 :               || OMP_CLAUSE_REDUCTION_TASK (c))
   16830              :             {
   16831              :               /* Disallow zero sized or potentially zero sized task
   16832              :                  reductions.  */
   16833          871 :               if (integer_zerop (TYPE_SIZE_UNIT (type)))
   16834              :                 {
   16835            6 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16836              :                             "zero sized type %qT in %qs clause", type,
   16837            3 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16838            3 :                   remove = true;
   16839            3 :                   break;
   16840              :                 }
   16841          868 :               else if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST)
   16842              :                 {
   16843            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16844              :                             "variable sized type %qT in %qs clause", type,
   16845            0 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   16846            0 :                   remove = true;
   16847            0 :                   break;
   16848              :                 }
   16849              :             }
   16850         4156 :           if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE
   16851         4156 :               && (FLOAT_TYPE_P (type)
   16852         3604 :                   || TREE_CODE (type) == COMPLEX_TYPE))
   16853              :             {
   16854          340 :               enum tree_code r_code = OMP_CLAUSE_REDUCTION_CODE (c);
   16855          340 :               const char *r_name = NULL;
   16856              : 
   16857          340 :               switch (r_code)
   16858              :                 {
   16859              :                 case PLUS_EXPR:
   16860              :                 case MULT_EXPR:
   16861              :                 case MINUS_EXPR:
   16862              :                 case TRUTH_ANDIF_EXPR:
   16863              :                 case TRUTH_ORIF_EXPR:
   16864              :                   break;
   16865           13 :                 case MIN_EXPR:
   16866           13 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   16867              :                     r_name = "min";
   16868              :                   break;
   16869           38 :                 case MAX_EXPR:
   16870           38 :                   if (TREE_CODE (type) == COMPLEX_TYPE)
   16871              :                     r_name = "max";
   16872              :                   break;
   16873            3 :                 case BIT_AND_EXPR:
   16874            3 :                   r_name = "&";
   16875            3 :                   break;
   16876            2 :                 case BIT_XOR_EXPR:
   16877            2 :                   r_name = "^";
   16878            2 :                   break;
   16879              :                 case BIT_IOR_EXPR:
   16880              :                   r_name = "|";
   16881              :                   break;
   16882            0 :                 default:
   16883            0 :                   gcc_unreachable ();
   16884              :                 }
   16885            5 :               if (r_name)
   16886              :                 {
   16887           12 :                   error_at (OMP_CLAUSE_LOCATION (c),
   16888              :                             "%qE has invalid type for %<reduction(%s)%>",
   16889              :                             t, r_name);
   16890           12 :                   remove = true;
   16891           12 :                   break;
   16892              :                 }
   16893              :             }
   16894         3816 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == error_mark_node)
   16895              :             {
   16896            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   16897              :                         "user defined reduction not found for %qE", t);
   16898            2 :               remove = true;
   16899            2 :               break;
   16900              :             }
   16901         3814 :           else if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
   16902              :             {
   16903          277 :               tree list = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c);
   16904          277 :               type = TYPE_MAIN_VARIANT (type);
   16905          277 :               tree placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   16906              :                                              VAR_DECL, NULL_TREE, type);
   16907          277 :               tree decl_placeholder = NULL_TREE;
   16908          277 :               OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = placeholder;
   16909          277 :               DECL_ARTIFICIAL (placeholder) = 1;
   16910          277 :               DECL_IGNORED_P (placeholder) = 1;
   16911          277 :               if (TREE_CODE (t) == MEM_REF)
   16912              :                 {
   16913           56 :                   decl_placeholder = build_decl (OMP_CLAUSE_LOCATION (c),
   16914              :                                                  VAR_DECL, NULL_TREE, type);
   16915           56 :                   OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) = decl_placeholder;
   16916           56 :                   DECL_ARTIFICIAL (decl_placeholder) = 1;
   16917           56 :                   DECL_IGNORED_P (decl_placeholder) = 1;
   16918              :                 }
   16919          277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 0)))
   16920           42 :                 c_mark_addressable (placeholder);
   16921          277 :               if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 1)))
   16922           76 :                 c_mark_addressable (decl_placeholder ? decl_placeholder
   16923           34 :                                     : OMP_CLAUSE_DECL (c));
   16924          277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   16925          775 :                 = c_clone_omp_udr (TREE_VEC_ELT (list, 2),
   16926          277 :                                    TREE_VEC_ELT (list, 0),
   16927          277 :                                    TREE_VEC_ELT (list, 1),
   16928              :                                    decl_placeholder ? decl_placeholder
   16929          221 :                                    : OMP_CLAUSE_DECL (c), placeholder);
   16930          277 :               OMP_CLAUSE_REDUCTION_MERGE (c)
   16931          277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   16932              :                               void_type_node, NULL_TREE,
   16933          277 :                               OMP_CLAUSE_REDUCTION_MERGE (c), NULL_TREE);
   16934          277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_MERGE (c)) = 1;
   16935          277 :               if (TREE_VEC_LENGTH (list) == 6)
   16936              :                 {
   16937          233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 3)))
   16938           70 :                     c_mark_addressable (decl_placeholder ? decl_placeholder
   16939           33 :                                         : OMP_CLAUSE_DECL (c));
   16940          233 :                   if (TREE_ADDRESSABLE (TREE_VEC_ELT (list, 4)))
   16941           27 :                     c_mark_addressable (placeholder);
   16942          233 :                   tree init = TREE_VEC_ELT (list, 5);
   16943          233 :                   if (init == error_mark_node)
   16944          197 :                     init = DECL_INITIAL (TREE_VEC_ELT (list, 3));
   16945          233 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   16946          651 :                     = c_clone_omp_udr (init, TREE_VEC_ELT (list, 4),
   16947          233 :                                        TREE_VEC_ELT (list, 3),
   16948              :                                        decl_placeholder ? decl_placeholder
   16949          185 :                                        : OMP_CLAUSE_DECL (c), placeholder);
   16950          233 :                   if (TREE_VEC_ELT (list, 5) == error_mark_node)
   16951              :                     {
   16952          197 :                       tree v = decl_placeholder ? decl_placeholder : t;
   16953          197 :                       OMP_CLAUSE_REDUCTION_INIT (c)
   16954          394 :                         = build2 (INIT_EXPR, TREE_TYPE (v), v,
   16955          197 :                                   OMP_CLAUSE_REDUCTION_INIT (c));
   16956              :                     }
   16957          233 :                   if (walk_tree (&OMP_CLAUSE_REDUCTION_INIT (c),
   16958              :                                  c_find_omp_placeholder_r,
   16959              :                                  placeholder, NULL))
   16960           28 :                     OMP_CLAUSE_REDUCTION_OMP_ORIG_REF (c) = 1;
   16961              :                 }
   16962              :               else
   16963              :                 {
   16964           44 :                   tree init;
   16965           44 :                   tree v = decl_placeholder ? decl_placeholder : t;
   16966           44 :                   if (AGGREGATE_TYPE_P (TREE_TYPE (v)))
   16967           34 :                     init = build_constructor (TREE_TYPE (v), NULL);
   16968              :                   else
   16969           10 :                     init = fold_convert (TREE_TYPE (v), integer_zero_node);
   16970           44 :                   OMP_CLAUSE_REDUCTION_INIT (c)
   16971           88 :                     = build2 (INIT_EXPR, TREE_TYPE (v), v, init);
   16972              :                 }
   16973          277 :               OMP_CLAUSE_REDUCTION_INIT (c)
   16974          277 :                 = build3_loc (OMP_CLAUSE_LOCATION (c), BIND_EXPR,
   16975              :                               void_type_node, NULL_TREE,
   16976          277 :                                OMP_CLAUSE_REDUCTION_INIT (c), NULL_TREE);
   16977          277 :               TREE_SIDE_EFFECTS (OMP_CLAUSE_REDUCTION_INIT (c)) = 1;
   16978              :             }
   16979         4142 :           if (TREE_CODE (t) == MEM_REF)
   16980              :             {
   16981          607 :               if (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))) == NULL_TREE
   16982          607 :                   || TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (t))))
   16983              :                      != INTEGER_CST)
   16984              :                 {
   16985            0 :                   sorry ("variable length element type in array "
   16986              :                          "%<reduction%> clause");
   16987            0 :                   remove = true;
   16988            0 :                   break;
   16989              :                 }
   16990          607 :               t = TREE_OPERAND (t, 0);
   16991          607 :               if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   16992          139 :                 t = TREE_OPERAND (t, 0);
   16993          607 :               if (TREE_CODE (t) == ADDR_EXPR)
   16994          367 :                 t = TREE_OPERAND (t, 0);
   16995              :             }
   16996         4142 :           goto check_dup_generic_t;
   16997              : 
   16998           24 :         case OMP_CLAUSE_COPYPRIVATE:
   16999           24 :           copyprivate_seen = true;
   17000           24 :           if (nowait_clause)
   17001              :             {
   17002            1 :               error_at (OMP_CLAUSE_LOCATION (*nowait_clause),
   17003              :                         "%<nowait%> clause must not be used together "
   17004              :                         "with %<copyprivate%> clause");
   17005            1 :               *nowait_clause = OMP_CLAUSE_CHAIN (*nowait_clause);
   17006            1 :               nowait_clause = NULL;
   17007              :             }
   17008           24 :           goto check_dup_generic;
   17009              : 
   17010           99 :         case OMP_CLAUSE_COPYIN:
   17011           99 :           t = OMP_CLAUSE_DECL (c);
   17012           99 :           if (!VAR_P (t) || !DECL_THREAD_LOCAL_P (t))
   17013              :             {
   17014            5 :               error_at (OMP_CLAUSE_LOCATION (c),
   17015              :                         "%qE must be %<threadprivate%> for %<copyin%>", t);
   17016            5 :               remove = true;
   17017            5 :               break;
   17018              :             }
   17019           94 :           goto check_dup_generic;
   17020              : 
   17021          480 :         case OMP_CLAUSE_LINEAR:
   17022          480 :           if (ort != C_ORT_OMP_DECLARE_SIMD)
   17023          327 :             need_implicitly_determined = true;
   17024          480 :           t = OMP_CLAUSE_DECL (c);
   17025          480 :           if (ort != C_ORT_OMP_DECLARE_SIMD
   17026          327 :               && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT
   17027          485 :               && OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c))
   17028              :             {
   17029            5 :               error_at (OMP_CLAUSE_LOCATION (c),
   17030              :                         "modifier should not be specified in %<linear%> "
   17031              :                         "clause on %<simd%> or %<for%> constructs when not "
   17032              :                         "using OpenMP 5.2 modifiers");
   17033            5 :               OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
   17034              :             }
   17035          960 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
   17036          503 :               && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   17037              :             {
   17038            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17039              :                         "linear clause applied to non-integral non-pointer "
   17040            1 :                         "variable with type %qT", TREE_TYPE (t));
   17041            1 :               remove = true;
   17042            1 :               break;
   17043              :             }
   17044          479 :           if (TYPE_ATOMIC (TREE_TYPE (t)))
   17045              :             {
   17046            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   17047              :                         "%<_Atomic%> %qD in %<linear%> clause", t);
   17048            3 :               remove = true;
   17049            3 :               break;
   17050              :             }
   17051          476 :           if (ort == C_ORT_OMP_DECLARE_SIMD)
   17052              :             {
   17053          152 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   17054          152 :               if (TREE_CODE (s) == PARM_DECL)
   17055              :                 {
   17056            9 :                   OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c) = 1;
   17057              :                   /* map_head bitmap is used as uniform_head if
   17058              :                      declare_simd.  */
   17059            9 :                   if (!bitmap_bit_p (&map_head, DECL_UID (s)))
   17060            5 :                     linear_variable_step_check = true;
   17061            9 :                   goto check_dup_generic;
   17062              :                 }
   17063          143 :               if (TREE_CODE (s) != INTEGER_CST)
   17064              :                 {
   17065            7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17066              :                             "%<linear%> clause step %qE is neither constant "
   17067              :                             "nor a parameter", s);
   17068            7 :                   remove = true;
   17069            7 :                   break;
   17070              :                 }
   17071              :             }
   17072          460 :           if (TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == POINTER_TYPE)
   17073              :             {
   17074           20 :               tree s = OMP_CLAUSE_LINEAR_STEP (c);
   17075           20 :               s = pointer_int_sum (OMP_CLAUSE_LOCATION (c), PLUS_EXPR,
   17076           20 :                                    OMP_CLAUSE_DECL (c), s);
   17077           20 :               s = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   17078              :                                    sizetype, fold_convert (sizetype, s),
   17079           20 :                                    fold_convert
   17080              :                                      (sizetype, OMP_CLAUSE_DECL (c)));
   17081           20 :               if (s == error_mark_node)
   17082            0 :                 s = size_one_node;
   17083           20 :               OMP_CLAUSE_LINEAR_STEP (c) = s;
   17084              :             }
   17085              :           else
   17086          440 :             OMP_CLAUSE_LINEAR_STEP (c)
   17087          880 :               = fold_convert (TREE_TYPE (t), OMP_CLAUSE_LINEAR_STEP (c));
   17088          460 :           goto check_dup_generic;
   17089              : 
   17090         2887 :         check_dup_generic:
   17091         2887 :           t = OMP_CLAUSE_DECL (c);
   17092         7118 :         check_dup_generic_t:
   17093         7118 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17094              :             {
   17095            4 :               error_at (OMP_CLAUSE_LOCATION (c),
   17096              :                         "%qE is not a variable in clause %qs", t,
   17097            2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17098            2 :               remove = true;
   17099              :             }
   17100         1149 :           else if ((openacc && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
   17101         6077 :                    || (ort == C_ORT_OMP
   17102         5358 :                        && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   17103         5347 :                            || (OMP_CLAUSE_CODE (c)
   17104              :                                == OMP_CLAUSE_USE_DEVICE_ADDR)))
   17105        13146 :                    || (ort == C_ORT_OMP_TARGET
   17106          347 :                        && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION))
   17107              :             {
   17108         1196 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION
   17109         1196 :                   && (bitmap_bit_p (&generic_head, DECL_UID (t))
   17110          109 :                       || bitmap_bit_p (&firstprivate_head, DECL_UID (t))))
   17111              :                 {
   17112            2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17113              :                             "%qD appears more than once in data-sharing "
   17114              :                             "clauses", t);
   17115            2 :                   remove = true;
   17116            2 :                   break;
   17117              :                 }
   17118         1194 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION)
   17119          108 :                 target_in_reduction_seen = true;
   17120         1194 :               if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   17121              :                 {
   17122            4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17123              :                             openacc
   17124              :                             ? "%qD appears more than once in reduction clauses"
   17125              :                             : "%qD appears more than once in data clauses",
   17126              :                             t);
   17127            2 :                   remove = true;
   17128              :                 }
   17129              :               else
   17130         1192 :                 bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   17131              :             }
   17132         5920 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17133         5897 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17134         5896 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t))
   17135        11816 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17136              :             {
   17137           24 :               error_at (OMP_CLAUSE_LOCATION (c),
   17138              :                         "%qE appears more than once in data clauses", t);
   17139           24 :               remove = true;
   17140              :             }
   17141         5896 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   17142              :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR
   17143              :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   17144         1047 :                    && bitmap_bit_p (&map_head, DECL_UID (t)))
   17145              :             {
   17146            3 :               if (openacc)
   17147            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17148              :                           "%qD appears more than once in data clauses", t);
   17149              :               else
   17150            3 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17151              :                           "%qD appears both in data and map clauses", t);
   17152              :               remove = true;
   17153              :             }
   17154              :           else
   17155         5893 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   17156              :           break;
   17157              : 
   17158         1333 :         case OMP_CLAUSE_FIRSTPRIVATE:
   17159         1333 :           if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c) && !implicit_moved)
   17160              :             {
   17161          153 :             move_implicit:
   17162          153 :               implicit_moved = true;
   17163              :               /* Move firstprivate and map clauses with
   17164              :                  OMP_CLAUSE_{FIRSTPRIVATE,MAP}_IMPLICIT set to the end of
   17165              :                  clauses chain.  */
   17166          153 :               tree cl1 = NULL_TREE, cl2 = NULL_TREE;
   17167          153 :               tree *pc1 = pc, *pc2 = &cl1, *pc3 = &cl2;
   17168          972 :               while (*pc1)
   17169          819 :                 if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_FIRSTPRIVATE
   17170          819 :                     && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (*pc1))
   17171              :                   {
   17172          113 :                     *pc3 = *pc1;
   17173          113 :                     pc3 = &OMP_CLAUSE_CHAIN (*pc3);
   17174          113 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   17175              :                   }
   17176          706 :                 else if (OMP_CLAUSE_CODE (*pc1) == OMP_CLAUSE_MAP
   17177          706 :                          && OMP_CLAUSE_MAP_IMPLICIT (*pc1))
   17178              :                   {
   17179          131 :                     *pc2 = *pc1;
   17180          131 :                     pc2 = &OMP_CLAUSE_CHAIN (*pc2);
   17181          131 :                     *pc1 = OMP_CLAUSE_CHAIN (*pc1);
   17182              :                   }
   17183              :                 else
   17184          575 :                   pc1 = &OMP_CLAUSE_CHAIN (*pc1);
   17185          153 :               *pc3 = NULL;
   17186          153 :               *pc2 = cl2;
   17187          153 :               *pc1 = cl1;
   17188          153 :               continue;
   17189          153 :             }
   17190         1238 :           t = OMP_CLAUSE_DECL (c);
   17191         1238 :           need_complete = true;
   17192         1238 :           need_implicitly_determined = true;
   17193         1238 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17194              :             {
   17195            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17196              :                         "%qE is not a variable in clause %<firstprivate%>", t);
   17197            1 :               remove = true;
   17198              :             }
   17199         1237 :           else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   17200          113 :                    && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c)
   17201         1343 :                    && bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17202              :             remove = true;
   17203         1237 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17204         1235 :                    || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17205         2471 :                    || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17206              :             {
   17207            4 :               error_at (OMP_CLAUSE_LOCATION (c),
   17208              :                         "%qE appears more than once in data clauses", t);
   17209            4 :               remove = true;
   17210              :             }
   17211         1233 :           else if (bitmap_bit_p (&map_head, DECL_UID (t))
   17212         1233 :                    || bitmap_bit_p (&map_field_head, DECL_UID (t)))
   17213              :             {
   17214            7 :               if (openacc)
   17215            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17216              :                           "%qD appears more than once in data clauses", t);
   17217            7 :               else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c)
   17218            7 :                        && !OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT_TARGET (c))
   17219              :                 /* Silently drop the clause.  */;
   17220              :               else
   17221            6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17222              :                           "%qD appears both in data and map clauses", t);
   17223              :               remove = true;
   17224              :             }
   17225              :           else
   17226         1226 :             bitmap_set_bit (&firstprivate_head, DECL_UID (t));
   17227              :           break;
   17228              : 
   17229         1523 :         case OMP_CLAUSE_LASTPRIVATE:
   17230         1523 :           t = OMP_CLAUSE_DECL (c);
   17231         1523 :           need_complete = true;
   17232         1523 :           need_implicitly_determined = true;
   17233         1523 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17234              :             {
   17235            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17236              :                         "%qE is not a variable in clause %<lastprivate%>", t);
   17237            0 :               remove = true;
   17238              :             }
   17239         1523 :           else if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17240         1523 :                    || bitmap_bit_p (&lastprivate_head, DECL_UID (t)))
   17241              :             {
   17242            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   17243              :                      "%qE appears more than once in data clauses", t);
   17244            3 :               remove = true;
   17245              :             }
   17246              :           else
   17247         1520 :             bitmap_set_bit (&lastprivate_head, DECL_UID (t));
   17248              :           break;
   17249              : 
   17250          253 :         case OMP_CLAUSE_ALIGNED:
   17251          253 :           t = OMP_CLAUSE_DECL (c);
   17252          253 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17253              :             {
   17254            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17255              :                         "%qE is not a variable in %<aligned%> clause", t);
   17256            0 :               remove = true;
   17257              :             }
   17258          289 :           else if (!POINTER_TYPE_P (TREE_TYPE (t))
   17259          289 :                    && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   17260              :             {
   17261            7 :               error_at (OMP_CLAUSE_LOCATION (c),
   17262              :                         "%qE in %<aligned%> clause is neither a pointer nor "
   17263              :                         "an array", t);
   17264            7 :               remove = true;
   17265              :             }
   17266          246 :           else if (TYPE_ATOMIC (TREE_TYPE (t)))
   17267              :             {
   17268            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17269              :                         "%<_Atomic%> %qD in %<aligned%> clause", t);
   17270            1 :               remove = true;
   17271            1 :               break;
   17272              :             }
   17273          245 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   17274              :             {
   17275            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17276              :                         "%qE appears more than once in %<aligned%> clauses",
   17277              :                         t);
   17278            0 :               remove = true;
   17279              :             }
   17280              :           else
   17281          245 :             bitmap_set_bit (&aligned_head, DECL_UID (t));
   17282              :           break;
   17283              : 
   17284          125 :         case OMP_CLAUSE_NONTEMPORAL:
   17285          125 :           t = OMP_CLAUSE_DECL (c);
   17286          125 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17287              :             {
   17288            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17289              :                         "%qE is not a variable in %<nontemporal%> clause", t);
   17290            0 :               remove = true;
   17291              :             }
   17292          125 :           else if (bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   17293              :             {
   17294            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17295              :                         "%qE appears more than once in %<nontemporal%> "
   17296              :                         "clauses", t);
   17297            2 :               remove = true;
   17298              :             }
   17299              :           else
   17300          123 :             bitmap_set_bit (&oacc_reduction_head, DECL_UID (t));
   17301              :           break;
   17302              : 
   17303          802 :         case OMP_CLAUSE_ALLOCATE:
   17304          802 :           t = OMP_CLAUSE_DECL (c);
   17305          802 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17306              :             {
   17307            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17308              :                         "%qE is not a variable in %<allocate%> clause", t);
   17309            1 :               remove = true;
   17310              :             }
   17311          801 :           else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
   17312              :             {
   17313            2 :               warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
   17314              :                           "%qE appears more than once in %<allocate%> clauses",
   17315              :                           t);
   17316            2 :               remove = true;
   17317              :             }
   17318              :           else
   17319              :             {
   17320          799 :               bitmap_set_bit (&aligned_head, DECL_UID (t));
   17321          799 :               if (!OMP_CLAUSE_ALLOCATE_COMBINED (c))
   17322          700 :                 allocate_seen = true;
   17323              :             }
   17324              :           break;
   17325              : 
   17326          357 :         case OMP_CLAUSE_DOACROSS:
   17327          357 :           t = OMP_CLAUSE_DECL (c);
   17328          357 :           if (t == NULL_TREE)
   17329              :             break;
   17330          169 :           if (OMP_CLAUSE_DOACROSS_KIND (c) == OMP_CLAUSE_DOACROSS_SINK)
   17331              :             {
   17332          169 :               gcc_assert (TREE_CODE (t) == TREE_LIST);
   17333         1315 :               for (; t; t = TREE_CHAIN (t))
   17334              :                 {
   17335         1146 :                   tree decl = TREE_VALUE (t);
   17336         1146 :                   if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
   17337              :                     {
   17338            3 :                       tree offset = TREE_PURPOSE (t);
   17339            3 :                       bool neg = wi::neg_p (wi::to_wide (offset));
   17340            3 :                       offset = fold_unary (ABS_EXPR, TREE_TYPE (offset), offset);
   17341            6 :                       tree t2 = pointer_int_sum (OMP_CLAUSE_LOCATION (c),
   17342              :                                                  neg ? MINUS_EXPR : PLUS_EXPR,
   17343              :                                                  decl, offset);
   17344            3 :                       t2 = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR,
   17345              :                                             sizetype,
   17346              :                                             fold_convert (sizetype, t2),
   17347              :                                             fold_convert (sizetype, decl));
   17348            3 :                       if (t2 == error_mark_node)
   17349              :                         {
   17350              :                           remove = true;
   17351              :                           break;
   17352              :                         }
   17353            3 :                       TREE_PURPOSE (t) = t2;
   17354              :                     }
   17355              :                 }
   17356              :               break;
   17357              :             }
   17358            0 :           gcc_unreachable ();
   17359              : 
   17360           36 :         case OMP_CLAUSE_USES_ALLOCATORS:
   17361           36 :           t = OMP_CLAUSE_USES_ALLOCATORS_ALLOCATOR (c);
   17362           36 :           if (t == error_mark_node)
   17363              :             {
   17364              :               remove = true;
   17365              :               break;
   17366              :             }
   17367            6 :           if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   17368           33 :               && (bitmap_bit_p (&generic_head, DECL_UID (t))
   17369           27 :                   || bitmap_bit_p (&map_head, DECL_UID (t))
   17370           27 :                   || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17371           26 :                   || bitmap_bit_p (&lastprivate_head, DECL_UID (t))))
   17372              :             {
   17373            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   17374              :                         "%qE appears more than once in data clauses", t);
   17375            1 :               remove = true;
   17376            1 :               break;
   17377              :             }
   17378              :           else
   17379           31 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   17380           31 :           if (TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE
   17381           59 :               || strcmp (IDENTIFIER_POINTER (TYPE_IDENTIFIER (TREE_TYPE (t))),
   17382              :                          "omp_allocator_handle_t") != 0)
   17383              :             {
   17384            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   17385              :                         "allocator %qE must be of %<omp_allocator_handle_t%> "
   17386              :                         "type", t);
   17387            3 :               remove = true;
   17388            3 :               break;
   17389              :             }
   17390           28 :           tree init;
   17391           28 :           if (!DECL_P (t)
   17392           28 :               || (TREE_CODE (t) == CONST_DECL
   17393            5 :                   && ((init = DECL_INITIAL(t)) == nullptr
   17394            5 :                       || TREE_CODE (init) != INTEGER_CST
   17395            5 :                       || ((wi::to_widest (init) < 0
   17396            5 :                            || wi::to_widest (init) > GOMP_OMP_PREDEF_ALLOC_MAX)
   17397            0 :                           && (wi::to_widest (init) < GOMP_OMPX_PREDEF_ALLOC_MIN
   17398            0 :                               || (wi::to_widest (init)
   17399            0 :                                   > GOMP_OMPX_PREDEF_ALLOC_MAX))))))
   17400              :             {
   17401            0 :               remove = true;
   17402            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   17403              :                         "allocator %qE must be either a variable or a "
   17404              :                         "predefined allocator", t);
   17405            0 :               break;
   17406              :             }
   17407           28 :           else if (TREE_CODE (t) == CONST_DECL)
   17408              :             {
   17409              :               /* omp_null_allocator is ignored and for predefined allocators,
   17410              :                  not special handling is required; thus, remove them removed. */
   17411            5 :               remove = true;
   17412              : 
   17413            5 :               if (OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE (c)
   17414            5 :                   || OMP_CLAUSE_USES_ALLOCATORS_TRAITS (c))
   17415              :                 {
   17416            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17417              :                             "modifiers cannot be used with predefined "
   17418              :                             "allocator %qE", t);
   17419            0 :                   break;
   17420              :                 }
   17421              :             }
   17422           28 :           t = OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE (c);
   17423           28 :           if (t == error_mark_node)
   17424              :             {
   17425              :               remove = true;
   17426              :               break;
   17427              :             }
   17428           28 :           if (t != NULL_TREE
   17429           28 :               && ((TREE_CODE (t) != CONST_DECL && TREE_CODE (t) != INTEGER_CST)
   17430            5 :                   || TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE
   17431            8 :                   || strcmp (IDENTIFIER_POINTER (TYPE_IDENTIFIER (TREE_TYPE (t))),
   17432              :                              "omp_memspace_handle_t") != 0))
   17433              :             {
   17434            1 :               error_at (OMP_CLAUSE_LOCATION (c), "memspace modifier %qE must be"
   17435              :                         " constant enum of %<omp_memspace_handle_t%> type", t);
   17436            1 :               remove = true;
   17437            1 :               break;
   17438              :             }
   17439           27 :           t = OMP_CLAUSE_USES_ALLOCATORS_TRAITS (c);
   17440           27 :           if (t == error_mark_node)
   17441              :             {
   17442              :               remove = true;
   17443              :               break;
   17444              :             }
   17445           27 :           if (t != NULL_TREE
   17446              :               && t != error_mark_node
   17447           27 :               && (DECL_EXTERNAL (t)
   17448            9 :                   || TREE_CODE (t) == PARM_DECL))
   17449              :             {
   17450            3 :               error_at (OMP_CLAUSE_LOCATION (c), "traits array %qE must be "
   17451              :                         "defined in same scope as the construct on which the "
   17452              :                         "clause appears", t);
   17453            3 :               remove = true;
   17454              :             }
   17455           27 :           if (t != NULL_TREE)
   17456              :             {
   17457           11 :               bool type_err = false;
   17458              : 
   17459           11 :               if (TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE
   17460           10 :                   || DECL_SIZE (t) == NULL_TREE
   17461           20 :                   || !COMPLETE_TYPE_P (TREE_TYPE (t)))
   17462              :                 type_err = true;
   17463              :               else
   17464              :                 {
   17465            9 :                   tree elem_t = TREE_TYPE (TREE_TYPE (t));
   17466            9 :                   if (TREE_CODE (elem_t) != RECORD_TYPE
   17467           18 :                       || strcmp (IDENTIFIER_POINTER (TYPE_IDENTIFIER (elem_t)),
   17468              :                                  "omp_alloctrait_t") != 0
   17469           18 :                       || !TYPE_READONLY (elem_t))
   17470              :                     type_err = true;
   17471              :                 }
   17472            8 :               if (type_err)
   17473              :                 {
   17474            3 :                   if (t != error_mark_node)
   17475            3 :                     error_at (OMP_CLAUSE_LOCATION (c), "traits array %qE must "
   17476              :                               "be of %<const omp_alloctrait_t []%> type", t);
   17477              :                   else
   17478            0 :                     error_at (OMP_CLAUSE_LOCATION (c), "traits array must "
   17479              :                               "be of %<const omp_alloctrait_t []%> type");
   17480              :                   remove = true;
   17481              :                 }
   17482              :               else
   17483              :                 {
   17484            8 :                   tree cst_val = decl_constant_value_1 (t, true);
   17485            8 :                   if (cst_val == t)
   17486              :                     {
   17487            1 :                       error_at (OMP_CLAUSE_LOCATION (c), "traits array must be "
   17488              :                                 "initialized with constants");
   17489              : 
   17490            1 :                       remove = true;
   17491              :                     }
   17492              :                 }
   17493              :             }
   17494           24 :           if (remove)
   17495              :             break;
   17496           18 :           pc = &OMP_CLAUSE_CHAIN (c);
   17497           18 :           continue;
   17498          713 :         case OMP_CLAUSE_DEPEND:
   17499          713 :           depend_clause = c;
   17500              :           /* FALLTHRU */
   17501          870 :         case OMP_CLAUSE_AFFINITY:
   17502          870 :           t = OMP_CLAUSE_DECL (c);
   17503          870 :           if (OMP_ITERATOR_DECL_P (t))
   17504              :             {
   17505          131 :               if (TREE_PURPOSE (t) != last_iterators)
   17506          111 :                 last_iterators_remove
   17507          111 :                   = c_omp_finish_iterators (TREE_PURPOSE (t));
   17508          131 :               last_iterators = TREE_PURPOSE (t);
   17509          131 :               t = TREE_VALUE (t);
   17510          131 :               if (last_iterators_remove)
   17511           34 :                 t = error_mark_node;
   17512              :             }
   17513              :           else
   17514              :             last_iterators = NULL_TREE;
   17515          870 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   17516              :             {
   17517          413 :               if (handle_omp_array_sections (c, ort))
   17518              :                 remove = true;
   17519          336 :               else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17520          336 :                        && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   17521              :                 {
   17522            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17523              :                             "%<depend%> clause with %<depobj%> dependence "
   17524              :                             "type on array section");
   17525            1 :                   remove = true;
   17526              :                 }
   17527              :               break;
   17528              :             }
   17529          457 :           if (t == error_mark_node)
   17530              :             remove = true;
   17531          423 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17532          423 :                    && t == ridpointers[RID_OMP_ALL_MEMORY])
   17533              :             {
   17534           15 :               if (OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_OUT
   17535           15 :                   && OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_INOUT)
   17536              :                 {
   17537            3 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17538              :                             "%<omp_all_memory%> used with %<depend%> kind "
   17539              :                             "other than %<out%> or %<inout%>");
   17540            3 :                   remove = true;
   17541              :                 }
   17542              :             }
   17543          408 :           else if (!lvalue_p (t))
   17544              :             {
   17545            6 :               error_at (OMP_CLAUSE_LOCATION (c),
   17546              :                         "%qE is not lvalue expression nor array section in "
   17547              :                         "%qs clause", t,
   17548            3 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17549            3 :               remove = true;
   17550              :             }
   17551          405 :           else if (TREE_CODE (t) == COMPONENT_REF
   17552          405 :                    && DECL_C_BIT_FIELD (TREE_OPERAND (t, 1)))
   17553              :             {
   17554            2 :               gcc_assert (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17555              :                           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_AFFINITY);
   17556            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17557              :                         "bit-field %qE in %qs clause", t,
   17558            2 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17559            2 :               remove = true;
   17560              :             }
   17561          403 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17562          403 :                    && OMP_CLAUSE_DEPEND_KIND (c) == OMP_CLAUSE_DEPEND_DEPOBJ)
   17563              :             {
   17564           20 :               if (!c_omp_depend_t_p (TREE_TYPE (t)))
   17565              :                 {
   17566            2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17567              :                             "%qE does not have %<omp_depend_t%> type in "
   17568              :                             "%<depend%> clause with %<depobj%> dependence "
   17569              :                             "type", t);
   17570            2 :                   remove = true;
   17571              :                 }
   17572              :             }
   17573          383 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
   17574          383 :                    && c_omp_depend_t_p (TREE_TYPE (t)))
   17575              :             {
   17576            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17577              :                         "%qE should not have %<omp_depend_t%> type in "
   17578              :                         "%<depend%> clause with dependence type other than "
   17579              :                         "%<depobj%>", t);
   17580            2 :               remove = true;
   17581              :             }
   17582           12 :           if (!remove)
   17583              :             {
   17584          411 :               if (t == ridpointers[RID_OMP_ALL_MEMORY])
   17585           12 :                 t = null_pointer_node;
   17586              :               else
   17587              :                 {
   17588          399 :                   tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c),
   17589              :                                               ADDR_EXPR, t, false);
   17590          399 :                   if (addr == error_mark_node)
   17591              :                     {
   17592              :                       remove = true;
   17593              :                       break;
   17594              :                     }
   17595          399 :                   t = build_indirect_ref (OMP_CLAUSE_LOCATION (c), addr,
   17596              :                                           RO_UNARY_STAR);
   17597          399 :                   if (t == error_mark_node)
   17598              :                     {
   17599              :                       remove = true;
   17600              :                       break;
   17601              :                     }
   17602              :                 }
   17603          411 :               if (OMP_ITERATOR_DECL_P (OMP_CLAUSE_DECL (c)))
   17604           31 :                 TREE_VALUE (OMP_CLAUSE_DECL (c)) = t;
   17605              :               else
   17606          380 :                 OMP_CLAUSE_DECL (c) = t;
   17607              :             }
   17608              :           break;
   17609              : 
   17610         6694 :         case OMP_CLAUSE_MAP:
   17611         6694 :           if (OMP_CLAUSE_MAP_IMPLICIT (c) && !implicit_moved)
   17612           58 :             goto move_implicit;
   17613         6636 :           if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_PUSH_MAPPER_NAME
   17614         6636 :               || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POP_MAPPER_NAME)
   17615              :             {
   17616              :               remove = true;
   17617              :               break;
   17618              :             }
   17619              :           /* FALLTHRU */
   17620         9509 :         case OMP_CLAUSE_TO:
   17621         9509 :         case OMP_CLAUSE_FROM:
   17622         9509 :           if (OMP_CLAUSE_ITERATORS (c)
   17623         9509 :               && c_omp_finish_iterators (OMP_CLAUSE_ITERATORS (c)))
   17624              :             {
   17625        22935 :               t = error_mark_node;
   17626              :               break;
   17627              :             }
   17628              :           /* FALLTHRU */
   17629         9645 :         case OMP_CLAUSE__CACHE_:
   17630         9645 :           {
   17631         9645 :             using namespace omp_addr_tokenizer;
   17632         9645 :             auto_vec<omp_addr_token *, 10> addr_tokens;
   17633              : 
   17634         9645 :             t = OMP_CLAUSE_DECL (c);
   17635         9645 :             if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   17636              :               {
   17637         2001 :                 grp_start_p = pc;
   17638         2001 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   17639              : 
   17640         2001 :                 if (handle_omp_array_sections (c, ort))
   17641              :                   remove = true;
   17642              :                 else
   17643              :                   {
   17644         1861 :                     t = OMP_CLAUSE_DECL (c);
   17645         1861 :                     if (!omp_mappable_type (TREE_TYPE (t)))
   17646              :                       {
   17647            2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   17648              :                                   "array section does not have mappable type "
   17649              :                                   "in %qs clause",
   17650            1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17651            1 :                         remove = true;
   17652              :                       }
   17653         1860 :                     else if (TYPE_ATOMIC (TREE_TYPE (t)))
   17654              :                       {
   17655            2 :                         error_at (OMP_CLAUSE_LOCATION (c),
   17656              :                                   "%<_Atomic%> %qE in %qs clause", t,
   17657            1 :                                   omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17658            1 :                         remove = true;
   17659              :                       }
   17660         2510 :                     while (TREE_CODE (t) == ARRAY_REF)
   17661          649 :                       t = TREE_OPERAND (t, 0);
   17662              : 
   17663         1861 :                     c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   17664              : 
   17665         1861 :                     if (!omp_parse_expr (addr_tokens, t))
   17666              :                       {
   17667            0 :                         sorry_at (OMP_CLAUSE_LOCATION (c),
   17668              :                                   "unsupported map expression %qE",
   17669            0 :                                   OMP_CLAUSE_DECL (c));
   17670            0 :                         remove = true;
   17671            0 :                         break;
   17672              :                       }
   17673              : 
   17674              :                     /* This check is to determine if this will be the only map
   17675              :                        node created for this clause.  Otherwise, we'll check
   17676              :                        the following FIRSTPRIVATE_POINTER or ATTACH_DETACH
   17677              :                        node on the next iteration(s) of the loop.   */
   17678         3704 :                     if (addr_tokens.length () >= 4
   17679          304 :                         && addr_tokens[0]->type == STRUCTURE_BASE
   17680          302 :                         && addr_tokens[0]->u.structure_base_kind == BASE_DECL
   17681          302 :                         && addr_tokens[1]->type == ACCESS_METHOD
   17682          302 :                         && addr_tokens[2]->type == COMPONENT_SELECTOR
   17683          302 :                         && addr_tokens[3]->type == ACCESS_METHOD
   17684         2102 :                         && (addr_tokens[3]->u.access_kind == ACCESS_DIRECT
   17685          188 :                             || (addr_tokens[3]->u.access_kind
   17686              :                                 == ACCESS_INDEXED_ARRAY)))
   17687              :                       {
   17688           55 :                         tree rt = addr_tokens[1]->expr;
   17689              : 
   17690           55 :                         gcc_assert (DECL_P (rt));
   17691              : 
   17692           55 :                         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17693           50 :                             && OMP_CLAUSE_MAP_IMPLICIT (c)
   17694           55 :                             && (bitmap_bit_p (&map_head, DECL_UID (rt))
   17695            0 :                                 || bitmap_bit_p (&map_field_head, DECL_UID (rt))
   17696            0 :                                 || bitmap_bit_p (&map_firstprivate_head,
   17697            0 :                                                  DECL_UID (rt))))
   17698              :                           {
   17699              :                             remove = true;
   17700              :                             break;
   17701              :                           }
   17702           55 :                         if (bitmap_bit_p (&map_field_head, DECL_UID (rt)))
   17703              :                           break;
   17704           37 :                         if (bitmap_bit_p (&map_head, DECL_UID (rt)))
   17705              :                           {
   17706            0 :                             if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   17707            0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17708              :                                         "%qD appears more than once in motion "
   17709              :                                         "clauses", rt);
   17710            0 :                             else if (openacc)
   17711            0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17712              :                                         "%qD appears more than once in data "
   17713              :                                         "clauses", rt);
   17714              :                             else
   17715            0 :                               error_at (OMP_CLAUSE_LOCATION (c),
   17716              :                                         "%qD appears more than once in map "
   17717              :                                         "clauses", rt);
   17718              :                             remove = true;
   17719              :                           }
   17720              :                         else
   17721              :                           {
   17722           37 :                             bitmap_set_bit (&map_head, DECL_UID (rt));
   17723           37 :                             bitmap_set_bit (&map_field_head, DECL_UID (rt));
   17724              :                           }
   17725              :                       }
   17726         1861 :                   }
   17727         1983 :                 if (c_oacc_check_attachments (c))
   17728            2 :                   remove = true;
   17729         1983 :                 if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17730         1807 :                     && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   17731         1789 :                         || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   17732         2008 :                     && !OMP_CLAUSE_SIZE (c))
   17733              :                   /* In this case, we have a single array element which is a
   17734              :                      pointer, and we already set OMP_CLAUSE_SIZE in
   17735              :                      handle_omp_array_sections above.  For attach/detach
   17736              :                      clauses, reset the OMP_CLAUSE_SIZE (representing a bias)
   17737              :                      to zero here.  */
   17738           10 :                   OMP_CLAUSE_SIZE (c) = size_zero_node;
   17739              :                 break;
   17740              :               }
   17741         7644 :             else if (!omp_parse_expr (addr_tokens, t))
   17742              :               {
   17743            0 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   17744              :                           "unsupported map expression %qE",
   17745            0 :                           OMP_CLAUSE_DECL (c));
   17746            0 :                 remove = true;
   17747            0 :                 break;
   17748              :               }
   17749         7644 :             if (t == error_mark_node)
   17750              :               {
   17751              :                 remove = true;
   17752              :                 break;
   17753              :               }
   17754              :             /* OpenACC attach / detach clauses must be pointers.  */
   17755         7632 :             if (c_oacc_check_attachments (c))
   17756              :               {
   17757              :                 remove = true;
   17758              :                 break;
   17759              :               }
   17760         7628 :             if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17761         4781 :                 && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
   17762         4754 :                     || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
   17763         7670 :                 && !OMP_CLAUSE_SIZE (c))
   17764              :               /* For attach/detach clauses, set OMP_CLAUSE_SIZE (representing a
   17765              :                  bias) to zero here, so it is not set erroneously to the pointer
   17766              :                  size later on in gimplify.cc.  */
   17767           28 :               OMP_CLAUSE_SIZE (c) = size_zero_node;
   17768              : 
   17769         7628 :             c_omp_address_inspector ai (OMP_CLAUSE_LOCATION (c), t);
   17770              : 
   17771         7628 :             if (!ai.check_clause (c))
   17772              :               {
   17773              :                 remove = true;
   17774              :                 break;
   17775              :               }
   17776              : 
   17777         7620 :             if (!ai.map_supported_p ())
   17778              :               {
   17779           14 :                 sorry_at (OMP_CLAUSE_LOCATION (c),
   17780              :                           "unsupported map expression %qE",
   17781            7 :                           OMP_CLAUSE_DECL (c));
   17782            7 :                 remove = true;
   17783            7 :                 break;
   17784              :               }
   17785              : 
   17786        15226 :             gcc_assert ((addr_tokens[0]->type == ARRAY_BASE
   17787              :                          || addr_tokens[0]->type == STRUCTURE_BASE)
   17788              :                         && addr_tokens[1]->type == ACCESS_METHOD);
   17789              : 
   17790         7613 :             t = addr_tokens[1]->expr;
   17791              : 
   17792         7613 :             if (addr_tokens[0]->u.structure_base_kind != BASE_DECL)
   17793            0 :               goto skip_decl_checks;
   17794              : 
   17795              :             /* For OpenMP, we can access a struct "t" and "t.d" on the same
   17796              :                mapping.  OpenACC allows multiple fields of the same structure
   17797              :                to be written.  */
   17798         7613 :             if (addr_tokens[0]->type == STRUCTURE_BASE
   17799         7613 :                 && (bitmap_bit_p (&map_field_head, DECL_UID (t))
   17800          260 :                     || (!openacc && bitmap_bit_p (&map_head, DECL_UID (t)))))
   17801          307 :               goto skip_decl_checks;
   17802              : 
   17803         7306 :             if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   17804              :               {
   17805            3 :                 if (ort != C_ORT_ACC && EXPR_P (t))
   17806              :                   break;
   17807              : 
   17808            6 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17809              :                           "%qE is not a variable in %qs clause", t,
   17810            3 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17811            3 :                 remove = true;
   17812              :               }
   17813         7303 :             else if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   17814              :               {
   17815            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17816              :                           "%qD is threadprivate variable in %qs clause", t,
   17817            0 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17818            0 :                 remove = true;
   17819              :               }
   17820         7303 :             else if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   17821         4483 :                       || (OMP_CLAUSE_MAP_KIND (c)
   17822              :                           != GOMP_MAP_FIRSTPRIVATE_POINTER))
   17823        10743 :                      && !c_mark_addressable (t))
   17824              :               remove = true;
   17825         7303 :             else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17826         4483 :                        && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER
   17827         4483 :                            || (OMP_CLAUSE_MAP_KIND (c)
   17828              :                                == GOMP_MAP_FIRSTPRIVATE_POINTER)
   17829         3440 :                            || (OMP_CLAUSE_MAP_KIND (c)
   17830              :                                == GOMP_MAP_FORCE_DEVICEPTR)))
   17831         6202 :                      && t == OMP_CLAUSE_DECL (c)
   17832        13247 :                      && !omp_mappable_type (TREE_TYPE (t)))
   17833              :               {
   17834           16 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17835              :                           "%qD does not have a mappable type in %qs clause", t,
   17836            8 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17837            8 :                 remove = true;
   17838              :               }
   17839         7295 :             else if (TREE_TYPE (t) == error_mark_node)
   17840              :               remove = true;
   17841         7294 :             else if (TYPE_ATOMIC (strip_array_types (TREE_TYPE (t))))
   17842              :               {
   17843            8 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17844              :                           "%<_Atomic%> %qE in %qs clause", t,
   17845            4 :                           omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   17846            4 :                 remove = true;
   17847              :               }
   17848         7290 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17849         4473 :                      && OMP_CLAUSE_MAP_IMPLICIT (c)
   17850         7421 :                      && (bitmap_bit_p (&map_head, DECL_UID (t))
   17851          130 :                          || bitmap_bit_p (&map_field_head, DECL_UID (t))
   17852          130 :                          || bitmap_bit_p (&map_firstprivate_head,
   17853          130 :                                           DECL_UID (t))))
   17854              :               remove = true;
   17855         7288 :             else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
   17856         7288 :                      && (OMP_CLAUSE_MAP_KIND (c)
   17857              :                          == GOMP_MAP_FIRSTPRIVATE_POINTER))
   17858              :               {
   17859         1041 :                 if (bitmap_bit_p (&generic_head, DECL_UID (t))
   17860         1041 :                     || bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17861         2081 :                     || bitmap_bit_p (&map_firstprivate_head, DECL_UID (t)))
   17862              :                   {
   17863            4 :                     error_at (OMP_CLAUSE_LOCATION (c),
   17864              :                               "%qD appears more than once in data clauses", t);
   17865            4 :                     remove = true;
   17866              :                   }
   17867         1037 :                 else if (bitmap_bit_p (&map_head, DECL_UID (t))
   17868            4 :                          && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   17869         1039 :                          && openacc)
   17870              :                   {
   17871            1 :                     error_at (OMP_CLAUSE_LOCATION (c),
   17872              :                               "%qD appears more than once in data clauses", t);
   17873            1 :                     remove = true;
   17874              :                   }
   17875              :                 else
   17876         1036 :                   bitmap_set_bit (&map_firstprivate_head, DECL_UID (t));
   17877              :               }
   17878         6247 :             else if (bitmap_bit_p (&map_head, DECL_UID (t))
   17879           64 :                      && !bitmap_bit_p (&map_field_head, DECL_UID (t))
   17880           18 :                      && ort != C_ORT_OMP
   17881           18 :                      && ort != C_ORT_OMP_TARGET
   17882         6257 :                      && ort != C_ORT_OMP_EXIT_DATA)
   17883              :               {
   17884            7 :                 if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
   17885            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17886              :                             "%qD appears more than once in motion clauses", t);
   17887            7 :                 else if (openacc)
   17888            7 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17889              :                             "%qD appears more than once in data clauses", t);
   17890              :                 else
   17891            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17892              :                             "%qD appears more than once in map clauses", t);
   17893              :                 remove = true;
   17894              :               }
   17895         6240 :             else if (openacc && bitmap_bit_p (&generic_head, DECL_UID (t)))
   17896              :               {
   17897            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17898              :                           "%qD appears more than once in data clauses", t);
   17899            0 :                 remove = true;
   17900              :               }
   17901         6240 :             else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t))
   17902         6240 :                      || bitmap_bit_p (&is_on_device_head, DECL_UID (t)))
   17903              :               {
   17904            9 :                 if (openacc)
   17905            0 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17906              :                             "%qD appears more than once in data clauses", t);
   17907              :                 else
   17908            9 :                   error_at (OMP_CLAUSE_LOCATION (c),
   17909              :                             "%qD appears both in data and map clauses", t);
   17910              :                 remove = true;
   17911              :               }
   17912         6231 :             else if (!omp_access_chain_p (addr_tokens, 1))
   17913              :               {
   17914         6231 :                 bitmap_set_bit (&map_head, DECL_UID (t));
   17915         6231 :                 if (t != OMP_CLAUSE_DECL (c)
   17916         6231 :                     && TREE_CODE (OMP_CLAUSE_DECL (c)) == COMPONENT_REF)
   17917          254 :                   bitmap_set_bit (&map_field_head, DECL_UID (t));
   17918              :               }
   17919              : 
   17920            0 :           skip_decl_checks:
   17921              :             /* If we call omp_expand_map_clause in handle_omp_array_sections,
   17922              :                the containing loop (here) iterates through the new nodes
   17923              :                created by that expansion.  Avoid expanding those again (just
   17924              :                by checking the node type).  */
   17925         7613 :             if (!remove
   17926         7613 :                 && ort != C_ORT_DECLARE_SIMD
   17927         7613 :                 && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP
   17928         4731 :                     || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER
   17929         3695 :                         && (OMP_CLAUSE_MAP_KIND (c)
   17930              :                             != GOMP_MAP_FIRSTPRIVATE_REFERENCE)
   17931         3695 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ALWAYS_POINTER
   17932         3695 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH
   17933         3395 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH
   17934         3368 :                         && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_DETACH)))
   17935              :               {
   17936         6196 :                 grp_start_p = pc;
   17937         6196 :                 grp_sentinel = OMP_CLAUSE_CHAIN (c);
   17938         6196 :                 tree nc = ai.expand_map_clause (c, OMP_CLAUSE_DECL (c),
   17939              :                                                 addr_tokens, ort);
   17940         6196 :                 if (nc != error_mark_node)
   17941         6196 :                   c = nc;
   17942              :               }
   17943         9660 :           }
   17944         7613 :           break;
   17945              : 
   17946          232 :         case OMP_CLAUSE_ENTER:
   17947          232 :         case OMP_CLAUSE_LINK:
   17948          232 :           t = OMP_CLAUSE_DECL (c);
   17949          232 :           const char *cname;
   17950          232 :           cname = omp_clause_code_name[OMP_CLAUSE_CODE (c)];
   17951          232 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER
   17952          232 :               && OMP_CLAUSE_ENTER_TO (c))
   17953              :             cname = "to";
   17954          232 :           if (TREE_CODE (t) == FUNCTION_DECL
   17955          232 :               && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   17956              :             ;
   17957          151 :           else if (!VAR_P (t))
   17958              :             {
   17959            1 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   17960            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17961              :                           "%qE is neither a variable nor a function name in "
   17962              :                           "clause %qs", t, cname);
   17963              :               else
   17964            1 :                 error_at (OMP_CLAUSE_LOCATION (c),
   17965              :                           "%qE is not a variable in clause %qs", t, cname);
   17966              :               remove = true;
   17967              :             }
   17968          150 :           else if (DECL_THREAD_LOCAL_P (t))
   17969              :             {
   17970            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   17971              :                         "%qD is threadprivate variable in %qs clause", t,
   17972              :                         cname);
   17973            2 :               remove = true;
   17974              :             }
   17975          148 :           else if (!omp_mappable_type (TREE_TYPE (t)))
   17976              :             {
   17977            6 :               error_at (OMP_CLAUSE_LOCATION (c),
   17978              :                         "%qD does not have a mappable type in %qs clause", t,
   17979              :                         cname);
   17980            6 :               remove = true;
   17981              :             }
   17982            8 :           if (remove)
   17983              :             break;
   17984          223 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   17985              :             {
   17986            8 :               error_at (OMP_CLAUSE_LOCATION (c),
   17987              :                         "%qE appears more than once on the same "
   17988              :                         "%<declare target%> directive", t);
   17989            8 :               remove = true;
   17990              :             }
   17991              :           else
   17992          215 :             bitmap_set_bit (&generic_head, DECL_UID (t));
   17993              :           break;
   17994              : 
   17995          117 :         case OMP_CLAUSE_UNIFORM:
   17996          117 :           t = OMP_CLAUSE_DECL (c);
   17997          117 :           if (TREE_CODE (t) != PARM_DECL)
   17998              :             {
   17999            0 :               if (DECL_P (t))
   18000            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   18001              :                           "%qD is not an argument in %<uniform%> clause", t);
   18002              :               else
   18003            0 :                 error_at (OMP_CLAUSE_LOCATION (c),
   18004              :                           "%qE is not an argument in %<uniform%> clause", t);
   18005              :               remove = true;
   18006              :               break;
   18007              :             }
   18008              :           /* map_head bitmap is used as uniform_head if declare_simd.  */
   18009          117 :           bitmap_set_bit (&map_head, DECL_UID (t));
   18010          117 :           goto check_dup_generic;
   18011              : 
   18012          161 :         case OMP_CLAUSE_IS_DEVICE_PTR:
   18013          161 :         case OMP_CLAUSE_USE_DEVICE_PTR:
   18014          161 :           t = OMP_CLAUSE_DECL (c);
   18015          161 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR)
   18016          123 :             bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   18017          161 :           if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
   18018              :             {
   18019           21 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
   18020           21 :                   && !openacc)
   18021              :                 {
   18022            1 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18023              :                             "%qs variable is not a pointer",
   18024            1 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   18025            1 :                   remove = true;
   18026              :                 }
   18027           20 :               else if (TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
   18028              :                 {
   18029            4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18030              :                             "%qs variable is neither a pointer nor an array",
   18031            4 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   18032            4 :                   remove = true;
   18033              :                 }
   18034              :             }
   18035          161 :           goto check_dup_generic;
   18036              : 
   18037           89 :         case OMP_CLAUSE_HAS_DEVICE_ADDR:
   18038           89 :           t = OMP_CLAUSE_DECL (c);
   18039           89 :           if (TREE_CODE (t) == OMP_ARRAY_SECTION)
   18040              :             {
   18041           11 :               if (handle_omp_array_sections (c, ort))
   18042              :                 remove = true;
   18043              :               else
   18044              :                 {
   18045           11 :                   t = OMP_CLAUSE_DECL (c);
   18046           24 :                   while (TREE_CODE (t) == ARRAY_REF)
   18047           13 :                     t = TREE_OPERAND (t, 0);
   18048              :                 }
   18049              :             }
   18050           89 :           bitmap_set_bit (&is_on_device_head, DECL_UID (t));
   18051           89 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   18052           89 :             c_mark_addressable (t);
   18053           89 :           goto check_dup_generic_t;
   18054              : 
   18055           36 :         case OMP_CLAUSE_USE_DEVICE_ADDR:
   18056           36 :           t = OMP_CLAUSE_DECL (c);
   18057           36 :           if (VAR_P (t) || TREE_CODE (t) == PARM_DECL)
   18058           36 :             c_mark_addressable (t);
   18059           36 :           goto check_dup_generic;
   18060              : 
   18061         4791 :         case OMP_CLAUSE_NOWAIT:
   18062         4791 :           if (copyprivate_seen)
   18063              :             {
   18064            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   18065              :                         "%<nowait%> clause must not be used together "
   18066              :                         "with %<copyprivate%> clause");
   18067            1 :               remove = true;
   18068            1 :               break;
   18069              :             }
   18070         4790 :           nowait_clause = pc;
   18071         4790 :           pc = &OMP_CLAUSE_CHAIN (c);
   18072         4790 :           continue;
   18073              : 
   18074          523 :         case OMP_CLAUSE_ORDER:
   18075          523 :           if (ordered_clause)
   18076              :             {
   18077            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   18078              :                         "%<order%> clause must not be used together "
   18079              :                         "with %<ordered%> clause");
   18080            2 :               remove = true;
   18081            2 :               break;
   18082              :             }
   18083          521 :           else if (order_clause)
   18084              :             {
   18085              :               /* Silently remove duplicates.  */
   18086              :               remove = true;
   18087              :               break;
   18088              :             }
   18089          513 :           order_clause = pc;
   18090          513 :           pc = &OMP_CLAUSE_CHAIN (c);
   18091          513 :           continue;
   18092              : 
   18093           32 :         case OMP_CLAUSE_DETACH:
   18094           32 :           t = OMP_CLAUSE_DECL (c);
   18095           32 :           if (detach_seen)
   18096              :             {
   18097            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   18098              :                         "too many %qs clauses on a task construct",
   18099              :                         "detach");
   18100            1 :               remove = true;
   18101            1 :               break;
   18102              :             }
   18103           31 :           detach_seen = pc;
   18104           31 :           pc = &OMP_CLAUSE_CHAIN (c);
   18105           31 :           c_mark_addressable (t);
   18106           31 :           continue;
   18107              : 
   18108        14583 :         case OMP_CLAUSE_IF:
   18109        14583 :         case OMP_CLAUSE_SELF:
   18110        14583 :         case OMP_CLAUSE_NUM_THREADS:
   18111        14583 :         case OMP_CLAUSE_NUM_TEAMS:
   18112        14583 :         case OMP_CLAUSE_THREAD_LIMIT:
   18113        14583 :         case OMP_CLAUSE_DEFAULT:
   18114        14583 :         case OMP_CLAUSE_UNTIED:
   18115        14583 :         case OMP_CLAUSE_COLLAPSE:
   18116        14583 :         case OMP_CLAUSE_FINAL:
   18117        14583 :         case OMP_CLAUSE_DEVICE:
   18118        14583 :         case OMP_CLAUSE_DIST_SCHEDULE:
   18119        14583 :         case OMP_CLAUSE_DYN_GROUPPRIVATE:
   18120        14583 :         case OMP_CLAUSE_PARALLEL:
   18121        14583 :         case OMP_CLAUSE_FOR:
   18122        14583 :         case OMP_CLAUSE_SECTIONS:
   18123        14583 :         case OMP_CLAUSE_TASKGROUP:
   18124        14583 :         case OMP_CLAUSE_PROC_BIND:
   18125        14583 :         case OMP_CLAUSE_DEVICE_TYPE:
   18126        14583 :         case OMP_CLAUSE_PRIORITY:
   18127        14583 :         case OMP_CLAUSE_THREADS:
   18128        14583 :         case OMP_CLAUSE_SIMD:
   18129        14583 :         case OMP_CLAUSE_HINT:
   18130        14583 :         case OMP_CLAUSE_FILTER:
   18131        14583 :         case OMP_CLAUSE_DEFAULTMAP:
   18132        14583 :         case OMP_CLAUSE_BIND:
   18133        14583 :         case OMP_CLAUSE_NUM_GANGS:
   18134        14583 :         case OMP_CLAUSE_NUM_WORKERS:
   18135        14583 :         case OMP_CLAUSE_VECTOR_LENGTH:
   18136        14583 :         case OMP_CLAUSE_ASYNC:
   18137        14583 :         case OMP_CLAUSE_WAIT:
   18138        14583 :         case OMP_CLAUSE_AUTO:
   18139        14583 :         case OMP_CLAUSE_INDEPENDENT:
   18140        14583 :         case OMP_CLAUSE_SEQ:
   18141        14583 :         case OMP_CLAUSE_GANG:
   18142        14583 :         case OMP_CLAUSE_WORKER:
   18143        14583 :         case OMP_CLAUSE_VECTOR:
   18144        14583 :         case OMP_CLAUSE_TILE:
   18145        14583 :         case OMP_CLAUSE_IF_PRESENT:
   18146        14583 :         case OMP_CLAUSE_FINALIZE:
   18147        14583 :         case OMP_CLAUSE_NOHOST:
   18148        14583 :         case OMP_CLAUSE_INDIRECT:
   18149        14583 :         case OMP_CLAUSE_NOVARIANTS:
   18150        14583 :         case OMP_CLAUSE_NOCONTEXT:
   18151        14583 :           pc = &OMP_CLAUSE_CHAIN (c);
   18152        14583 :           continue;
   18153              : 
   18154           62 :         case OMP_CLAUSE_GRAINSIZE:
   18155           62 :           grainsize_seen = pc;
   18156           62 :           pc = &OMP_CLAUSE_CHAIN (c);
   18157           62 :           continue;
   18158              : 
   18159           50 :         case OMP_CLAUSE_NUM_TASKS:
   18160           50 :           num_tasks_seen = true;
   18161           50 :           pc = &OMP_CLAUSE_CHAIN (c);
   18162           50 :           continue;
   18163              : 
   18164           79 :         case OMP_CLAUSE_MERGEABLE:
   18165           79 :           mergeable_seen = true;
   18166           79 :           pc = &OMP_CLAUSE_CHAIN (c);
   18167           79 :           continue;
   18168              : 
   18169           18 :         case OMP_CLAUSE_NOGROUP:
   18170           18 :           nogroup_seen = pc;
   18171           18 :           pc = &OMP_CLAUSE_CHAIN (c);
   18172           18 :           continue;
   18173              : 
   18174         3465 :         case OMP_CLAUSE_SCHEDULE:
   18175         3465 :           schedule_clause = c;
   18176         3465 :           pc = &OMP_CLAUSE_CHAIN (c);
   18177         3465 :           continue;
   18178              : 
   18179          304 :         case OMP_CLAUSE_ORDERED:
   18180          304 :           ordered_clause = c;
   18181          304 :           if (order_clause)
   18182              :             {
   18183            2 :               error_at (OMP_CLAUSE_LOCATION (*order_clause),
   18184              :                         "%<order%> clause must not be used together "
   18185              :                         "with %<ordered%> clause");
   18186            2 :               *order_clause = OMP_CLAUSE_CHAIN (*order_clause);
   18187            2 :               order_clause = NULL;
   18188              :             }
   18189          304 :           pc = &OMP_CLAUSE_CHAIN (c);
   18190          304 :           continue;
   18191              : 
   18192          223 :         case OMP_CLAUSE_SAFELEN:
   18193          223 :           safelen = c;
   18194          223 :           pc = &OMP_CLAUSE_CHAIN (c);
   18195          223 :           continue;
   18196          320 :         case OMP_CLAUSE_SIMDLEN:
   18197          320 :           simdlen = c;
   18198          320 :           pc = &OMP_CLAUSE_CHAIN (c);
   18199          320 :           continue;
   18200              : 
   18201           69 :         case OMP_CLAUSE_FULL:
   18202           69 :           full_seen = pc;
   18203           69 :           pc = &OMP_CLAUSE_CHAIN (c);
   18204           69 :           continue;
   18205              : 
   18206          223 :         case OMP_CLAUSE_PARTIAL:
   18207          223 :           partial_seen = true;
   18208          223 :           pc = &OMP_CLAUSE_CHAIN (c);
   18209          223 :           continue;
   18210              : 
   18211            0 :         case OMP_CLAUSE_SIZES:
   18212            0 :           pc = &OMP_CLAUSE_CHAIN (c);
   18213            0 :           continue;
   18214              : 
   18215          205 :         case OMP_CLAUSE_INBRANCH:
   18216          205 :         case OMP_CLAUSE_NOTINBRANCH:
   18217          205 :           if (branch_seen)
   18218              :             {
   18219            1 :               error_at (OMP_CLAUSE_LOCATION (c),
   18220              :                         "%<inbranch%> clause is incompatible with "
   18221              :                         "%<notinbranch%>");
   18222            1 :               remove = true;
   18223            1 :               break;
   18224              :             }
   18225          204 :           branch_seen = true;
   18226          204 :           pc = &OMP_CLAUSE_CHAIN (c);
   18227          204 :           continue;
   18228              : 
   18229          367 :         case OMP_CLAUSE_INCLUSIVE:
   18230          367 :         case OMP_CLAUSE_EXCLUSIVE:
   18231          367 :           need_complete = true;
   18232          367 :           need_implicitly_determined = true;
   18233          367 :           t = OMP_CLAUSE_DECL (c);
   18234          367 :           if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL)
   18235              :             {
   18236            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   18237              :                         "%qE is not a variable in clause %qs", t,
   18238            0 :                         omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   18239            0 :               remove = true;
   18240              :             }
   18241              :           break;
   18242              : 
   18243          152 :         case OMP_CLAUSE_INIT:
   18244          152 :           init_seen = true;
   18245          152 :           if (!OMP_CLAUSE_INIT_TARGETSYNC (c))
   18246           71 :             init_no_targetsync_clause = c;
   18247              :           /* FALLTHRU */
   18248          242 :         case OMP_CLAUSE_DESTROY:
   18249          242 :         case OMP_CLAUSE_USE:
   18250          242 :           init_use_destroy_seen = true;
   18251          242 :           t = OMP_CLAUSE_DECL (c);
   18252          242 :           if (bitmap_bit_p (&generic_head, DECL_UID (t)))
   18253              :             {
   18254            3 :               error_at (OMP_CLAUSE_LOCATION (c),
   18255              :                         "%qD appears more than once in action clauses", t);
   18256            3 :               remove = true;
   18257            3 :               break;
   18258              :             }
   18259          239 :           bitmap_set_bit (&generic_head, DECL_UID (t));
   18260              :           /* FALLTHRU */
   18261          298 :         case OMP_CLAUSE_INTEROP:
   18262          298 :           if (/* ort == C_ORT_OMP_INTEROP [uncomment for depobj init]  */
   18263          298 :                    !c_omp_interop_t_p (TREE_TYPE (OMP_CLAUSE_DECL (c))))
   18264              :             {
   18265           40 :               error_at (OMP_CLAUSE_LOCATION (c),
   18266              :                         "%qD must be of %<omp_interop_t%>",
   18267           20 :                         OMP_CLAUSE_DECL (c));
   18268           20 :               remove = true;
   18269              :             }
   18270          278 :           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_INIT
   18271          133 :                     || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DESTROY)
   18272          318 :                    && TREE_READONLY (OMP_CLAUSE_DECL (c)))
   18273              :             {
   18274           12 :               error_at (OMP_CLAUSE_LOCATION (c),
   18275            6 :                       "%qD shall not be const", OMP_CLAUSE_DECL (c));
   18276            6 :               remove = true;
   18277              :             }
   18278          298 :           pc = &OMP_CLAUSE_CHAIN (c);
   18279          298 :           break;
   18280            0 :         default:
   18281            0 :           gcc_unreachable ();
   18282        24952 :         }
   18283              : 
   18284        22935 :       if (!remove)
   18285              :         {
   18286        22381 :           t = OMP_CLAUSE_DECL (c);
   18287              : 
   18288        22381 :           if (need_complete)
   18289              :             {
   18290         3953 :               t = require_complete_type (OMP_CLAUSE_LOCATION (c), t);
   18291         3953 :               if (t == error_mark_node)
   18292            7 :                 remove = true;
   18293              :             }
   18294              : 
   18295        22381 :           if (need_implicitly_determined)
   18296              :             {
   18297         9552 :               const char *share_name = NULL;
   18298              : 
   18299         9552 :               if (VAR_P (t) && DECL_THREAD_LOCAL_P (t))
   18300              :                 share_name = "threadprivate";
   18301         9546 :               else switch (c_omp_predetermined_sharing (t))
   18302              :                 {
   18303              :                 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
   18304              :                   break;
   18305           20 :                 case OMP_CLAUSE_DEFAULT_SHARED:
   18306           20 :                   if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   18307           12 :                        || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
   18308           28 :                       && c_omp_predefined_variable (t))
   18309              :                     /* The __func__ variable and similar function-local
   18310              :                        predefined variables may be listed in a shared or
   18311              :                        firstprivate clause.  */
   18312              :                     break;
   18313              :                   share_name = "shared";
   18314              :                   break;
   18315              :                 case OMP_CLAUSE_DEFAULT_PRIVATE:
   18316              :                   share_name = "private";
   18317              :                   break;
   18318            0 :                 default:
   18319            0 :                   gcc_unreachable ();
   18320              :                 }
   18321              :               if (share_name)
   18322              :                 {
   18323           20 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18324              :                             "%qE is predetermined %qs for %qs",
   18325              :                             t, share_name,
   18326           10 :                             omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
   18327           10 :                   remove = true;
   18328              :                 }
   18329         9542 :               else if (TREE_READONLY (t)
   18330           23 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_SHARED
   18331         9555 :                        && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE)
   18332              :                 {
   18333            4 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18334              :                             "%<const%> qualified %qE may appear only in "
   18335              :                             "%<shared%> or %<firstprivate%> clauses", t);
   18336            4 :                   remove = true;
   18337              :                 }
   18338              :             }
   18339              :         }
   18340              : 
   18341        22381 :       if (remove)
   18342              :         {
   18343          575 :           if (grp_start_p)
   18344              :             {
   18345              :               /* If we found a clause to remove, we want to remove the whole
   18346              :                  expanded group, otherwise gimplify
   18347              :                  (omp_resolve_clause_dependencies) can get confused.  */
   18348          153 :               *grp_start_p = grp_sentinel;
   18349          153 :               pc = grp_start_p;
   18350          153 :               grp_start_p = NULL;
   18351              :             }
   18352              :           else
   18353          422 :             *pc = OMP_CLAUSE_CHAIN (c);
   18354              :         }
   18355              :       else
   18356        22360 :         pc = &OMP_CLAUSE_CHAIN (c);
   18357              :     }
   18358              : 
   18359        29559 :   if (grp_start_p
   18360        29559 :       && OMP_CLAUSE_HAS_ITERATORS (*grp_start_p))
   18361           52 :     for (tree gc = *grp_start_p; gc; gc = OMP_CLAUSE_CHAIN (gc))
   18362           32 :       OMP_CLAUSE_ITERATORS (gc) = OMP_CLAUSE_ITERATORS (*grp_start_p);
   18363              : 
   18364        29559 :   if (simdlen
   18365        29559 :       && safelen
   18366        29676 :       && tree_int_cst_lt (OMP_CLAUSE_SAFELEN_EXPR (safelen),
   18367          117 :                           OMP_CLAUSE_SIMDLEN_EXPR (simdlen)))
   18368              :     {
   18369            0 :       error_at (OMP_CLAUSE_LOCATION (simdlen),
   18370              :                 "%<simdlen%> clause value is bigger than "
   18371              :                 "%<safelen%> clause value");
   18372            0 :       OMP_CLAUSE_SIMDLEN_EXPR (simdlen)
   18373            0 :         = OMP_CLAUSE_SAFELEN_EXPR (safelen);
   18374              :     }
   18375              : 
   18376        29559 :   if (ordered_clause
   18377        29559 :       && schedule_clause
   18378        29559 :       && (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   18379              :           & OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
   18380              :     {
   18381            7 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   18382              :                 "%<nonmonotonic%> schedule modifier specified together "
   18383              :                 "with %<ordered%> clause");
   18384           14 :       OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   18385            7 :         = (enum omp_clause_schedule_kind)
   18386            7 :           (OMP_CLAUSE_SCHEDULE_KIND (schedule_clause)
   18387              :            & ~OMP_CLAUSE_SCHEDULE_NONMONOTONIC);
   18388              :     }
   18389              : 
   18390        29559 :   if (reduction_seen < 0 && ordered_clause)
   18391              :     {
   18392            2 :       error_at (OMP_CLAUSE_LOCATION (ordered_clause),
   18393              :                 "%qs clause specified together with %<inscan%> "
   18394              :                 "%<reduction%> clause", "ordered");
   18395            2 :       reduction_seen = -2;
   18396              :     }
   18397              : 
   18398        29559 :   if (reduction_seen < 0 && schedule_clause)
   18399              :     {
   18400            3 :       error_at (OMP_CLAUSE_LOCATION (schedule_clause),
   18401              :                 "%qs clause specified together with %<inscan%> "
   18402              :                 "%<reduction%> clause", "schedule");
   18403            3 :       reduction_seen = -2;
   18404              :     }
   18405              : 
   18406        29559 :   if (linear_variable_step_check
   18407        29559 :       || reduction_seen == -2
   18408              :       || allocate_seen
   18409        29547 :       || target_in_reduction_seen)
   18410         5190 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   18411              :       {
   18412         4589 :         bool remove = false;
   18413         4589 :         if (allocate_seen)
   18414         4431 :           switch (OMP_CLAUSE_CODE (c))
   18415              :             {
   18416          430 :             case OMP_CLAUSE_REDUCTION:
   18417          430 :             case OMP_CLAUSE_IN_REDUCTION:
   18418          430 :             case OMP_CLAUSE_TASK_REDUCTION:
   18419          430 :               if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF)
   18420              :                 {
   18421           23 :                   t = TREE_OPERAND (OMP_CLAUSE_DECL (c), 0);
   18422           23 :                   if (TREE_CODE (t) == POINTER_PLUS_EXPR)
   18423            0 :                     t = TREE_OPERAND (t, 0);
   18424           23 :                   if (TREE_CODE (t) == ADDR_EXPR
   18425           10 :                       || INDIRECT_REF_P (t))
   18426           13 :                     t = TREE_OPERAND (t, 0);
   18427           23 :                   if (DECL_P (t))
   18428           23 :                     bitmap_clear_bit (&aligned_head, DECL_UID (t));
   18429              :                   break;
   18430              :                 }
   18431              :               /* FALLTHRU */
   18432         1318 :             case OMP_CLAUSE_PRIVATE:
   18433         1318 :             case OMP_CLAUSE_FIRSTPRIVATE:
   18434         1318 :             case OMP_CLAUSE_LASTPRIVATE:
   18435         1318 :             case OMP_CLAUSE_LINEAR:
   18436         1318 :               if (DECL_P (OMP_CLAUSE_DECL (c)))
   18437         2636 :                 bitmap_clear_bit (&aligned_head,
   18438         1318 :                                   DECL_UID (OMP_CLAUSE_DECL (c)));
   18439              :               break;
   18440              :             default:
   18441              :               break;
   18442              :             }
   18443         4589 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR
   18444           29 :             && OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c)
   18445         4596 :             && !bitmap_bit_p (&map_head,
   18446            7 :                               DECL_UID (OMP_CLAUSE_LINEAR_STEP (c))))
   18447              :           {
   18448            2 :             error_at (OMP_CLAUSE_LOCATION (c),
   18449              :                       "%<linear%> clause step is a parameter %qD not "
   18450              :                       "specified in %<uniform%> clause",
   18451            2 :                       OMP_CLAUSE_LINEAR_STEP (c));
   18452            2 :             remove = true;
   18453              :           }
   18454         4587 :         else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
   18455         4587 :                  && reduction_seen == -2)
   18456            9 :           OMP_CLAUSE_REDUCTION_INSCAN (c) = 0;
   18457         4589 :         if (target_in_reduction_seen
   18458         4589 :             && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP)
   18459              :           {
   18460          256 :             tree t = OMP_CLAUSE_DECL (c);
   18461          256 :             while (handled_component_p (t)
   18462              :                    || INDIRECT_REF_P (t)
   18463              :                    || TREE_CODE (t) == ADDR_EXPR
   18464              :                    || TREE_CODE (t) == MEM_REF
   18465          288 :                    || TREE_CODE (t) == NON_LVALUE_EXPR)
   18466           32 :               t = TREE_OPERAND (t, 0);
   18467          256 :             if (DECL_P (t)
   18468          256 :                 && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
   18469          138 :               OMP_CLAUSE_MAP_IN_REDUCTION (c) = 1;
   18470              :           }
   18471              : 
   18472         4589 :         if (remove)
   18473            2 :           *pc = OMP_CLAUSE_CHAIN (c);
   18474              :         else
   18475         4587 :           pc = &OMP_CLAUSE_CHAIN (c);
   18476              :       }
   18477              : 
   18478          601 :   if (allocate_seen)
   18479         5006 :     for (pc = &clauses, c = clauses; c ; c = *pc)
   18480              :       {
   18481         4431 :         bool remove = false;
   18482         4431 :         if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ALLOCATE
   18483          720 :             && !OMP_CLAUSE_ALLOCATE_COMBINED (c)
   18484         5131 :             && bitmap_bit_p (&aligned_head, DECL_UID (OMP_CLAUSE_DECL (c))))
   18485              :           {
   18486            3 :             error_at (OMP_CLAUSE_LOCATION (c),
   18487              :                       "%qD specified in %<allocate%> clause but not in "
   18488            3 :                       "an explicit privatization clause", OMP_CLAUSE_DECL (c));
   18489            3 :             remove = true;
   18490              :           }
   18491         4431 :         if (remove)
   18492            3 :           *pc = OMP_CLAUSE_CHAIN (c);
   18493              :         else
   18494         4428 :           pc = &OMP_CLAUSE_CHAIN (c);
   18495              :       }
   18496              : 
   18497        29559 :   if (nogroup_seen && reduction_seen)
   18498              :     {
   18499            1 :       error_at (OMP_CLAUSE_LOCATION (*nogroup_seen),
   18500              :                 "%<nogroup%> clause must not be used together with "
   18501              :                 "%<reduction%> clause");
   18502            1 :       *nogroup_seen = OMP_CLAUSE_CHAIN (*nogroup_seen);
   18503              :     }
   18504              : 
   18505        29559 :   if (grainsize_seen && num_tasks_seen)
   18506              :     {
   18507            2 :       error_at (OMP_CLAUSE_LOCATION (*grainsize_seen),
   18508              :                 "%<grainsize%> clause must not be used together with "
   18509              :                 "%<num_tasks%> clause");
   18510            2 :       *grainsize_seen = OMP_CLAUSE_CHAIN (*grainsize_seen);
   18511              :     }
   18512              : 
   18513        29559 :   if (full_seen && partial_seen)
   18514              :     {
   18515            4 :       error_at (OMP_CLAUSE_LOCATION (*full_seen),
   18516              :                 "%<full%> clause must not be used together with "
   18517              :                 "%<partial%> clause");
   18518            4 :       *full_seen = OMP_CLAUSE_CHAIN (*full_seen);
   18519              :     }
   18520              : 
   18521        29559 :   if (detach_seen)
   18522              :     {
   18523           31 :       if (mergeable_seen)
   18524              :         {
   18525            2 :           error_at (OMP_CLAUSE_LOCATION (*detach_seen),
   18526              :                     "%<detach%> clause must not be used together with "
   18527              :                     "%<mergeable%> clause");
   18528            2 :           *detach_seen = OMP_CLAUSE_CHAIN (*detach_seen);
   18529              :         }
   18530              :       else
   18531              :         {
   18532           29 :           tree detach_decl = OMP_CLAUSE_DECL (*detach_seen);
   18533              : 
   18534           79 :           for (pc = &clauses, c = clauses; c ; c = *pc)
   18535              :             {
   18536           50 :               bool remove = false;
   18537           50 :               if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED
   18538           48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
   18539           48 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE
   18540           44 :                    || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE)
   18541           54 :                   && OMP_CLAUSE_DECL (c) == detach_decl)
   18542              :                 {
   18543            2 :                   error_at (OMP_CLAUSE_LOCATION (c),
   18544              :                             "the event handle of a %<detach%> clause "
   18545              :                             "should not be in a data-sharing clause");
   18546            2 :                   remove = true;
   18547              :                 }
   18548           50 :               if (remove)
   18549            2 :                 *pc = OMP_CLAUSE_CHAIN (c);
   18550              :               else
   18551           48 :                 pc = &OMP_CLAUSE_CHAIN (c);
   18552              :             }
   18553              :         }
   18554              :     }
   18555              : 
   18556        29559 :   if (ort == C_ORT_OMP_INTEROP
   18557        29559 :       && depend_clause
   18558           21 :       && (!init_use_destroy_seen
   18559           20 :           || (init_seen && init_no_targetsync_clause)))
   18560              :     {
   18561            3 :       error_at (OMP_CLAUSE_LOCATION (depend_clause),
   18562              :                 "%<depend%> clause requires action clauses with "
   18563              :                 "%<targetsync%> interop-type");
   18564            3 :       if (init_no_targetsync_clause)
   18565            2 :         inform (OMP_CLAUSE_LOCATION (init_no_targetsync_clause),
   18566              :                 "%<init%> clause lacks the %<targetsync%> modifier");
   18567              :     }
   18568              : 
   18569        29559 :   bitmap_obstack_release (NULL);
   18570        29559 :   return clauses;
   18571              : }
   18572              : 
   18573              : /* Do processing necessary to make CLAUSES well-formed, where CLAUSES result
   18574              :    from implicit instantiation of user-defined mappers (in gimplify.cc).  */
   18575              : 
   18576              : tree
   18577           15 : c_omp_finish_mapper_clauses (tree clauses)
   18578              : {
   18579           15 :   return c_finish_omp_clauses (clauses, C_ORT_OMP);
   18580              : }
   18581              : 
   18582              : /* Return code to initialize DST with a copy constructor from SRC.
   18583              :    C doesn't have copy constructors nor assignment operators, only for
   18584              :    _Atomic vars we need to perform __atomic_load from src into a temporary
   18585              :    followed by __atomic_store of the temporary to dst.  */
   18586              : 
   18587              : tree
   18588        18735 : c_omp_clause_copy_ctor (tree clause, tree dst, tree src)
   18589              : {
   18590        18735 :   if (!really_atomic_lvalue (dst) && !really_atomic_lvalue (src))
   18591        18731 :     return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
   18592              : 
   18593            4 :   location_t loc = OMP_CLAUSE_LOCATION (clause);
   18594            4 :   tree type = TREE_TYPE (dst);
   18595            4 :   tree nonatomic_type = build_qualified_type (type, TYPE_UNQUALIFIED);
   18596            4 :   tree tmp = create_tmp_var (nonatomic_type);
   18597            4 :   tree tmp_addr = build_fold_addr_expr (tmp);
   18598            4 :   TREE_ADDRESSABLE (tmp) = 1;
   18599            4 :   suppress_warning (tmp);
   18600            4 :   tree src_addr = build_fold_addr_expr (src);
   18601            4 :   tree dst_addr = build_fold_addr_expr (dst);
   18602            4 :   tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);
   18603            4 :   vec<tree, va_gc> *params;
   18604              :   /* Expansion of a generic atomic load may require an addition
   18605              :      element, so allocate enough to prevent a resize.  */
   18606            4 :   vec_alloc (params, 4);
   18607              : 
   18608              :   /* Build __atomic_load (&src, &tmp, SEQ_CST);  */
   18609            4 :   tree fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
   18610            4 :   params->quick_push (src_addr);
   18611            4 :   params->quick_push (tmp_addr);
   18612            4 :   params->quick_push (seq_cst);
   18613            4 :   tree load = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   18614              : 
   18615            4 :   vec_alloc (params, 4);
   18616              : 
   18617              :   /* Build __atomic_store (&dst, &tmp, SEQ_CST);  */
   18618            4 :   fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE);
   18619            4 :   params->quick_push (dst_addr);
   18620            4 :   params->quick_push (tmp_addr);
   18621            4 :   params->quick_push (seq_cst);
   18622            4 :   tree store = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL);
   18623            4 :   return build2 (COMPOUND_EXPR, void_type_node, load, store);
   18624              : }
   18625              : 
   18626              : /* Create a transaction node.  */
   18627              : 
   18628              : tree
   18629          135 : c_finish_transaction (location_t loc, tree block, int flags)
   18630              : {
   18631          135 :   tree stmt = build_stmt (loc, TRANSACTION_EXPR, block);
   18632          135 :   if (flags & TM_STMT_ATTR_OUTER)
   18633           10 :     TRANSACTION_EXPR_OUTER (stmt) = 1;
   18634          135 :   if (flags & TM_STMT_ATTR_RELAXED)
   18635           31 :     TRANSACTION_EXPR_RELAXED (stmt) = 1;
   18636          135 :   return add_stmt (stmt);
   18637              : }
   18638              : 
   18639              : /* Make a variant type in the proper way for C/C++, propagating qualifiers
   18640              :    down to the element type of an array.  If ORIG_QUAL_TYPE is not
   18641              :    NULL, then it should be used as the qualified type
   18642              :    ORIG_QUAL_INDIRECT levels down in array type derivation (to
   18643              :    preserve information about the typedef name from which an array
   18644              :    type was derived).  */
   18645              : 
   18646              : tree
   18647     74883797 : c_build_qualified_type (tree type, int type_quals, tree orig_qual_type,
   18648              :                         size_t orig_qual_indirect)
   18649              : {
   18650     74883797 :   if (type == error_mark_node)
   18651              :     return type;
   18652              : 
   18653     74883645 :   if (TREE_CODE (type) == ARRAY_TYPE)
   18654              :     {
   18655      3148786 :       tree t;
   18656      3148786 :       tree element_type = c_build_qualified_type (TREE_TYPE (type),
   18657              :                                                   type_quals, orig_qual_type,
   18658              :                                                   orig_qual_indirect - 1);
   18659              : 
   18660              :       /* See if we already have an identically qualified type.  */
   18661      3148786 :       if (orig_qual_type && orig_qual_indirect == 0)
   18662              :         t = orig_qual_type;
   18663              :       else
   18664      4591821 :         for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
   18665              :           {
   18666      4452124 :             if (TYPE_QUALS (strip_array_types (t)) == type_quals
   18667      3030002 :                 && TYPE_NAME (t) == TYPE_NAME (type)
   18668      3009048 :                 && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
   18669      7461172 :                 && attribute_list_equal (TYPE_ATTRIBUTES (t),
   18670      3009048 :                                          TYPE_ATTRIBUTES (type)))
   18671              :               break;
   18672              :           }
   18673      3148745 :       if (!t)
   18674              :         {
   18675       139697 :           tree domain = TYPE_DOMAIN (type);
   18676              : 
   18677       139697 :           t = build_variant_type_copy (type);
   18678       139697 :           TREE_TYPE (t) = element_type;
   18679       139697 :           TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (element_type);
   18680              : 
   18681       139697 :           if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
   18682       139697 :               || (domain && TYPE_STRUCTURAL_EQUALITY_P (domain)))
   18683          196 :             SET_TYPE_STRUCTURAL_EQUALITY (t);
   18684       139501 :           else if (TYPE_CANONICAL (element_type) != element_type
   18685       139501 :                    || (domain && TYPE_CANONICAL (domain) != domain))
   18686              :             {
   18687         2757 :               tree unqualified_canon
   18688         5288 :                 = c_build_array_type (TYPE_CANONICAL (element_type),
   18689         2531 :                                       domain ? TYPE_CANONICAL (domain)
   18690              :                                              : NULL_TREE);
   18691         2757 :               if (TYPE_REVERSE_STORAGE_ORDER (type))
   18692              :                 {
   18693            0 :                   unqualified_canon
   18694            0 :                     = build_distinct_type_copy (unqualified_canon);
   18695            0 :                   TYPE_REVERSE_STORAGE_ORDER (unqualified_canon) = 1;
   18696              :                 }
   18697         2757 :               TYPE_CANONICAL (t)
   18698         5514 :                 = c_build_qualified_type (unqualified_canon, type_quals);
   18699              :             }
   18700              :           else
   18701       136744 :             TYPE_CANONICAL (t) = t;
   18702              :         }
   18703      3148786 :       return t;
   18704              :     }
   18705              : 
   18706              :   /* A restrict-qualified pointer type must be a pointer to object or
   18707              :      incomplete type.  Note that the use of POINTER_TYPE_P also allows
   18708              :      REFERENCE_TYPEs, which is appropriate for C++.  */
   18709     71734859 :   if ((type_quals & TYPE_QUAL_RESTRICT)
   18710     71734859 :       && (!POINTER_TYPE_P (type)
   18711      3403969 :           || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type))))
   18712              :     {
   18713            3 :       error ("invalid use of %<restrict%>");
   18714            3 :       type_quals &= ~TYPE_QUAL_RESTRICT;
   18715              :     }
   18716              : 
   18717     71734859 :   tree var_type = (orig_qual_type && orig_qual_indirect == 0
   18718     71734859 :                    ? orig_qual_type
   18719     71734828 :                    : build_qualified_type (type, type_quals));
   18720              : 
   18721     71734859 :   gcc_checking_assert (C_TYPE_VARIABLE_SIZE (var_type)
   18722              :                        == C_TYPE_VARIABLE_SIZE (type));
   18723     71734859 :   gcc_checking_assert (c_type_variably_modified_p (var_type)
   18724              :                        == c_type_variably_modified_p (type));
   18725              : 
   18726              :   /* A variant type does not inherit the list of incomplete vars from the
   18727              :      type main variant.  */
   18728     71734859 :   if ((RECORD_OR_UNION_TYPE_P (var_type)
   18729     69652401 :        || TREE_CODE (var_type) == ENUMERAL_TYPE)
   18730     71840093 :       && TYPE_MAIN_VARIANT (var_type) != var_type)
   18731      1412230 :     C_TYPE_INCOMPLETE_VARS (var_type) = 0;
   18732              :   return var_type;
   18733              : }
   18734              : 
   18735              : /* Build a VA_ARG_EXPR for the C parser.  */
   18736              : 
   18737              : tree
   18738        19918 : c_build_va_arg (location_t loc1, tree expr, location_t loc2, tree type,
   18739              :                 tree type_expr)
   18740              : {
   18741        19918 :   if (error_operand_p (type))
   18742            2 :     return error_mark_node;
   18743              :   /* VA_ARG_EXPR cannot be used for a scalar va_list with reverse storage
   18744              :      order because it takes the address of the expression.  */
   18745        19916 :   else if (handled_component_p (expr)
   18746           31 :            && reverse_storage_order_for_component_p (expr))
   18747              :     {
   18748            0 :       error_at (loc1, "cannot use %<va_arg%> with reverse storage order");
   18749            0 :       return error_mark_node;
   18750              :     }
   18751        19916 :   else if (!COMPLETE_TYPE_P (type))
   18752              :     {
   18753           11 :       error_at (loc2, "second argument to %<va_arg%> is of incomplete "
   18754              :                 "type %qT", type);
   18755           11 :       return error_mark_node;
   18756              :     }
   18757        19905 :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   18758              :     {
   18759            1 :       error_at (loc2, "second argument to %<va_arg%> is a function type %qT",
   18760              :                 type);
   18761            1 :       return error_mark_node;
   18762              :     }
   18763            6 :   else if (TREE_CODE (type) == ARRAY_TYPE && C_TYPE_VARIABLE_SIZE (type)
   18764        19907 :            && !flag_isoc99)
   18765              :     {
   18766            1 :       error_at (loc2, "second argument to %<va_arg%> is an array type %qT",
   18767              :                 type);
   18768            1 :       return error_mark_node;
   18769              :     }
   18770        19903 :   else if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
   18771            1 :     warning_at (loc2, OPT_Wc___compat,
   18772              :                 "C++ requires promoted type, not enum type, in %<va_arg%>");
   18773              : 
   18774        19903 :   if (flag_isoc99 && TREE_CODE (type) == ARRAY_TYPE)
   18775              :     {
   18776            3 :       warning_at (loc2, 0, "second argument to %<va_arg%> is an array type %qT",
   18777              :                   type);
   18778              :       /* We create a trap but evaluate side effects first.  */
   18779            3 :       tree trapfn = builtin_decl_explicit (BUILT_IN_TRAP);
   18780            3 :       trapfn = build_call_expr_loc (loc2, trapfn, 0);
   18781            3 :       tree e2 = build2 (COMPOUND_EXPR, void_type_node, expr, trapfn);
   18782              :       /* Return a compound literal of the right type.  */
   18783            3 :       tree e1 = build_compound_literal (loc2, type, NULL, true, 0, NULL);
   18784            3 :       expr = build2 (COMPOUND_EXPR, type, e2, e1);
   18785            3 :     }
   18786              :   else
   18787        19900 :     expr = build_va_arg (loc2, expr, type);
   18788              : 
   18789        19903 :   if (type_expr)
   18790           26 :     expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), type_expr, expr);
   18791              : 
   18792              :   return expr;
   18793              : }
   18794              : 
   18795              : /* Return truthvalue of whether T1 is the same tree structure as T2.
   18796              :    Return 1 if they are the same. Return false if they are different.  */
   18797              : 
   18798              : bool
   18799         1854 : c_tree_equal (tree t1, tree t2)
   18800              : {
   18801         1883 :   enum tree_code code1, code2;
   18802              : 
   18803         1883 :   if (t1 == t2)
   18804              :     return true;
   18805          661 :   if (!t1 || !t2)
   18806              :     return false;
   18807              : 
   18808          681 :   for (code1 = TREE_CODE (t1); code1 == NON_LVALUE_EXPR;
   18809           20 :        code1 = TREE_CODE (t1))
   18810           20 :     t1 = TREE_OPERAND (t1, 0);
   18811          682 :   for (code2 = TREE_CODE (t2); code2 == NON_LVALUE_EXPR;
   18812           21 :        code2 = TREE_CODE (t2))
   18813           21 :     t2 = TREE_OPERAND (t2, 0);
   18814              : 
   18815              :   /* They might have become equal now.  */
   18816          661 :   if (t1 == t2)
   18817              :     return true;
   18818              : 
   18819          640 :   if (code1 != code2)
   18820              :     return false;
   18821              : 
   18822          379 :   if (CONSTANT_CLASS_P (t1) && !comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   18823              :     return false;
   18824              : 
   18825          379 :   switch (code1)
   18826              :     {
   18827            2 :     case INTEGER_CST:
   18828            2 :       return wi::to_wide (t1) == wi::to_wide (t2);
   18829              : 
   18830           10 :     case REAL_CST:
   18831           10 :       return real_equal (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
   18832              : 
   18833            0 :     case STRING_CST:
   18834            0 :       return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
   18835            0 :         && !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
   18836            0 :                     TREE_STRING_LENGTH (t1));
   18837              : 
   18838            0 :     case FIXED_CST:
   18839            0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1),
   18840              :                                      TREE_FIXED_CST (t2));
   18841              : 
   18842            0 :     case COMPLEX_CST:
   18843            0 :       return c_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
   18844            0 :              && c_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
   18845              : 
   18846            0 :     case VECTOR_CST:
   18847            0 :       return operand_equal_p (t1, t2, OEP_ONLY_CONST);
   18848              : 
   18849            0 :     case CONSTRUCTOR:
   18850              :       /* We need to do this when determining whether or not two
   18851              :          non-type pointer to member function template arguments
   18852              :          are the same.  */
   18853            0 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2))
   18854            0 :           || CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2))
   18855              :         return false;
   18856              :       {
   18857              :         tree field, value;
   18858              :         unsigned int i;
   18859            0 :         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t1), i, field, value)
   18860              :           {
   18861            0 :             constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i);
   18862            0 :             if (!c_tree_equal (field, elt2->index)
   18863            0 :                 || !c_tree_equal (value, elt2->value))
   18864            0 :               return false;
   18865              :           }
   18866              :       }
   18867              :       return true;
   18868              : 
   18869            0 :     case TREE_LIST:
   18870            0 :       if (!c_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))
   18871              :         return false;
   18872            0 :       if (!c_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2)))
   18873              :         return false;
   18874            0 :       return c_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
   18875              : 
   18876            0 :     case SAVE_EXPR:
   18877            0 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   18878              : 
   18879           25 :     case CALL_EXPR:
   18880           25 :       {
   18881           25 :         tree arg1, arg2;
   18882           25 :         call_expr_arg_iterator iter1, iter2;
   18883           25 :         if (!c_tree_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
   18884              :           return false;
   18885           50 :         for (arg1 = first_call_expr_arg (t1, &iter1),
   18886           25 :                arg2 = first_call_expr_arg (t2, &iter2);
   18887           25 :              arg1 && arg2;
   18888            0 :              arg1 = next_call_expr_arg (&iter1),
   18889            0 :                arg2 = next_call_expr_arg (&iter2))
   18890            0 :           if (!c_tree_equal (arg1, arg2))
   18891              :             return false;
   18892           25 :         if (arg1 || arg2)
   18893              :           return false;
   18894              :         return true;
   18895              :       }
   18896              : 
   18897            0 :     case TARGET_EXPR:
   18898            0 :       {
   18899            0 :         tree o1 = TREE_OPERAND (t1, 0);
   18900            0 :         tree o2 = TREE_OPERAND (t2, 0);
   18901              : 
   18902              :         /* Special case: if either target is an unallocated VAR_DECL,
   18903              :            it means that it's going to be unified with whatever the
   18904              :            TARGET_EXPR is really supposed to initialize, so treat it
   18905              :            as being equivalent to anything.  */
   18906            0 :         if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
   18907            0 :             && !DECL_RTL_SET_P (o1))
   18908              :           /*Nop*/;
   18909            0 :         else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
   18910            0 :                  && !DECL_RTL_SET_P (o2))
   18911              :           /*Nop*/;
   18912            0 :         else if (!c_tree_equal (o1, o2))
   18913              :           return false;
   18914              : 
   18915            0 :         return c_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
   18916              :       }
   18917              : 
   18918           29 :     case COMPONENT_REF:
   18919           29 :       if (TREE_OPERAND (t1, 1) != TREE_OPERAND (t2, 1))
   18920              :         return false;
   18921           29 :       return c_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
   18922              : 
   18923              :     case PARM_DECL:
   18924              :     case VAR_DECL:
   18925              :     case CONST_DECL:
   18926              :     case FIELD_DECL:
   18927              :     case FUNCTION_DECL:
   18928              :     case IDENTIFIER_NODE:
   18929              :     case SSA_NAME:
   18930              :       return false;
   18931              : 
   18932            0 :     case TREE_VEC:
   18933            0 :       {
   18934            0 :         unsigned ix;
   18935            0 :         if (TREE_VEC_LENGTH (t1) != TREE_VEC_LENGTH (t2))
   18936              :           return false;
   18937            0 :         for (ix = TREE_VEC_LENGTH (t1); ix--;)
   18938            0 :           if (!c_tree_equal (TREE_VEC_ELT (t1, ix),
   18939            0 :                              TREE_VEC_ELT (t2, ix)))
   18940              :             return false;
   18941              :         return true;
   18942              :       }
   18943              : 
   18944           22 :     CASE_CONVERT:
   18945           22 :       if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
   18946              :         return false;
   18947              :       break;
   18948              : 
   18949              :     default:
   18950              :       break;
   18951              :     }
   18952              : 
   18953          131 :   switch (TREE_CODE_CLASS (code1))
   18954              :     {
   18955          131 :     case tcc_unary:
   18956          131 :     case tcc_binary:
   18957          131 :     case tcc_comparison:
   18958          131 :     case tcc_expression:
   18959          131 :     case tcc_vl_exp:
   18960          131 :     case tcc_reference:
   18961          131 :     case tcc_statement:
   18962          131 :       {
   18963          131 :         int i, n = TREE_OPERAND_LENGTH (t1);
   18964              : 
   18965          131 :         switch (code1)
   18966              :           {
   18967            0 :           case PREINCREMENT_EXPR:
   18968            0 :           case PREDECREMENT_EXPR:
   18969            0 :           case POSTINCREMENT_EXPR:
   18970            0 :           case POSTDECREMENT_EXPR:
   18971            0 :             n = 1;
   18972            0 :             break;
   18973           16 :           case ARRAY_REF:
   18974           16 :             n = 2;
   18975           16 :             break;
   18976              :           default:
   18977              :             break;
   18978              :           }
   18979              : 
   18980          131 :         if (TREE_CODE_CLASS (code1) == tcc_vl_exp
   18981          131 :             && n != TREE_OPERAND_LENGTH (t2))
   18982              :           return false;
   18983              : 
   18984          305 :         for (i = 0; i < n; ++i)
   18985          186 :           if (!c_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i)))
   18986              :             return false;
   18987              : 
   18988              :         return true;
   18989              :       }
   18990              : 
   18991            0 :     case tcc_type:
   18992            0 :       return comptypes (t1, t2);
   18993            0 :     default:
   18994            0 :       gcc_unreachable ();
   18995              :     }
   18996              : }
   18997              : 
   18998              : /* Returns true when the function declaration FNDECL is implicit,
   18999              :    introduced as a result of a call to an otherwise undeclared
   19000              :    function, and false otherwise.  */
   19001              : 
   19002              : bool
   19003         2013 : c_decl_implicit (const_tree fndecl)
   19004              : {
   19005         2013 :   return C_DECL_IMPLICIT (fndecl);
   19006              : }
        

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.