LCOV - code coverage report
Current view: top level - gcc/cp - tree.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.0 % 3083 2867
Test Date: 2026-03-28 14:25:54 Functions: 95.1 % 183 174
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Language-dependent node constructors for parse phase of GNU compiler.
       2              :    Copyright (C) 1987-2026 Free Software Foundation, Inc.
       3              :    Hacked by Michael Tiemann (tiemann@cygnus.com)
       4              : 
       5              : This file is part of GCC.
       6              : 
       7              : GCC is free software; you can redistribute it and/or modify
       8              : it under the terms of the GNU General Public License as published by
       9              : the Free Software Foundation; either version 3, or (at your option)
      10              : any later version.
      11              : 
      12              : GCC is distributed in the hope that it will be useful,
      13              : but WITHOUT ANY WARRANTY; without even the implied warranty of
      14              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15              : GNU General Public License for more details.
      16              : 
      17              : You should have received a copy of the GNU General Public License
      18              : along with GCC; see the file COPYING3.  If not see
      19              : <http://www.gnu.org/licenses/>.  */
      20              : 
      21              : #include "config.h"
      22              : #include "system.h"
      23              : #include "coretypes.h"
      24              : #include "tree.h"
      25              : #include "cp-tree.h"
      26              : #include "gimple-expr.h"
      27              : #include "cgraph.h"
      28              : #include "stor-layout.h"
      29              : #include "print-tree.h"
      30              : #include "tree-iterator.h"
      31              : #include "tree-inline.h"
      32              : #include "debug.h"
      33              : #include "convert.h"
      34              : #include "gimplify.h"
      35              : #include "stringpool.h"
      36              : #include "attribs.h"
      37              : #include "flags.h"
      38              : #include "selftest.h"
      39              : 
      40              : static tree bot_manip (tree *, int *, void *);
      41              : static tree bot_replace (tree *, int *, void *);
      42              : static hashval_t list_hash_pieces (tree, tree, tree);
      43              : static tree build_target_expr (tree, tree, tsubst_flags_t);
      44              : static tree count_trees_r (tree *, int *, void *);
      45              : static tree verify_stmt_tree_r (tree *, int *, void *);
      46              : 
      47              : static tree handle_init_priority_attribute (tree *, tree, tree, int, bool *);
      48              : static tree handle_abi_tag_attribute (tree *, tree, tree, int, bool *);
      49              : static tree handle_no_dangling_attribute (tree *, tree, tree, int, bool *);
      50              : static tree handle_annotation_attribute (tree *, tree, tree, int, bool *);
      51              : 
      52              : /* If REF is an lvalue, returns the kind of lvalue that REF is.
      53              :    Otherwise, returns clk_none.  */
      54              : 
      55              : cp_lvalue_kind
      56   3339892106 : lvalue_kind (const_tree ref)
      57              : {
      58   3701602977 :   cp_lvalue_kind op1_lvalue_kind = clk_none;
      59   3701602977 :   cp_lvalue_kind op2_lvalue_kind = clk_none;
      60              : 
      61              :   /* Expressions of reference type are sometimes wrapped in
      62              :      INDIRECT_REFs.  INDIRECT_REFs are just internal compiler
      63              :      representation, not part of the language, so we have to look
      64              :      through them.  */
      65   3701602977 :   if (REFERENCE_REF_P (ref))
      66    346172655 :     return lvalue_kind (TREE_OPERAND (ref, 0));
      67              : 
      68   3355430322 :   if (TREE_TYPE (ref)
      69   3355430322 :       && TYPE_REF_P (TREE_TYPE (ref)))
      70              :     {
      71              :       /* unnamed rvalue references are rvalues */
      72    351118969 :       if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref))
      73              :           && TREE_CODE (ref) != PARM_DECL
      74              :           && !VAR_P (ref)
      75              :           && TREE_CODE (ref) != COMPONENT_REF
      76              :           /* Functions are always lvalues.  */
      77    411501665 :           && TREE_CODE (TREE_TYPE (TREE_TYPE (ref))) != FUNCTION_TYPE)
      78              :         {
      79     60381996 :           op1_lvalue_kind = clk_rvalueref;
      80     60381996 :           if (implicit_rvalue_p (ref))
      81      8657342 :             op1_lvalue_kind |= clk_implicit_rval;
      82     60381996 :           return op1_lvalue_kind;
      83              :         }
      84              : 
      85              :       /* lvalue references and named rvalue references are lvalues.  */
      86              :       return clk_ordinary;
      87              :     }
      88              : 
      89   3004311353 :   if (ref == current_class_ptr)
      90              :     return clk_none;
      91              : 
      92              :   /* Expressions with cv void type are prvalues.  */
      93   3001415368 :   if (TREE_TYPE (ref) && VOID_TYPE_P (TREE_TYPE (ref)))
      94              :     return clk_none;
      95              : 
      96   3000634028 :   switch (TREE_CODE (ref))
      97              :     {
      98              :     case SAVE_EXPR:
      99              :       return clk_none;
     100              : 
     101              :       /* preincrements and predecrements are valid lvals, provided
     102              :          what they refer to are valid lvals.  */
     103    417369247 :     case PREINCREMENT_EXPR:
     104    417369247 :     case PREDECREMENT_EXPR:
     105    417369247 :     case TRY_CATCH_EXPR:
     106    417369247 :     case REALPART_EXPR:
     107    417369247 :     case IMAGPART_EXPR:
     108    417369247 :     case VIEW_CONVERT_EXPR:
     109    417369247 :       op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
     110              :       /* As for ARRAY_REF and COMPONENT_REF, these codes turn a class prvalue
     111              :          into an xvalue: we need to materialize the temporary before we mess
     112              :          with it.  Except VIEW_CONVERT_EXPR that doesn't actually change the
     113              :          type, as in location wrapper and REF_PARENTHESIZED_P.  */
     114    417369247 :       if (op1_lvalue_kind == clk_class
     115    417369261 :           && !(TREE_CODE (ref) == VIEW_CONVERT_EXPR
     116              :                && (same_type_ignoring_top_level_qualifiers_p
     117           14 :                    (TREE_TYPE (ref), TREE_TYPE (TREE_OPERAND (ref, 0))))))
     118           14 :         return clk_rvalueref;
     119              :       return op1_lvalue_kind;
     120              : 
     121      3319589 :     case ARRAY_REF:
     122      3319589 :       {
     123      3319589 :         tree op1 = TREE_OPERAND (ref, 0);
     124      3319589 :         if (TREE_CODE (TREE_TYPE (op1)) == ARRAY_TYPE)
     125              :           {
     126      2859552 :             op1_lvalue_kind = lvalue_kind (op1);
     127      2859552 :             if (op1_lvalue_kind == clk_class)
     128              :               /* in the case of an array operand, the result is an lvalue if
     129              :                  that operand is an lvalue and an xvalue otherwise */
     130         2190 :               op1_lvalue_kind = clk_rvalueref;
     131      2859552 :             return op1_lvalue_kind;
     132              :           }
     133              :         else
     134              :           return clk_ordinary;
     135              :       }
     136              : 
     137           21 :     case MEMBER_REF:
     138           21 :     case DOTSTAR_EXPR:
     139           21 :       if (TREE_CODE (ref) == MEMBER_REF)
     140              :         op1_lvalue_kind = clk_ordinary;
     141              :       else
     142            9 :         op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
     143           21 :       if (TYPE_PTRMEMFUNC_P (TREE_TYPE (TREE_OPERAND (ref, 1))))
     144              :         op1_lvalue_kind = clk_none;
     145           21 :       else if (op1_lvalue_kind == clk_class)
     146              :         /* The result of a .* expression whose second operand is a pointer to a
     147              :            data member is an lvalue if the first operand is an lvalue and an
     148              :            xvalue otherwise.  */
     149           14 :         op1_lvalue_kind = clk_rvalueref;
     150              :       return op1_lvalue_kind;
     151              : 
     152    250710851 :     case COMPONENT_REF:
     153    250710851 :       if (BASELINK_P (TREE_OPERAND (ref, 1)))
     154              :         {
     155          118 :           tree fn = BASELINK_FUNCTIONS (TREE_OPERAND (ref, 1));
     156              : 
     157              :           /* For static member function recurse on the BASELINK, we can get
     158              :              here e.g. from reference_binding.  If BASELINK_FUNCTIONS is
     159              :              OVERLOAD, the overload is resolved first if possible through
     160              :              resolve_address_of_overloaded_function.  */
     161          118 :           if (TREE_CODE (fn) == FUNCTION_DECL && DECL_STATIC_FUNCTION_P (fn))
     162           27 :             return lvalue_kind (TREE_OPERAND (ref, 1));
     163              :         }
     164    250710824 :       op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
     165    250710824 :       if (op1_lvalue_kind == clk_class)
     166              :         /* If E1 is an lvalue, then E1.E2 is an lvalue;
     167              :            otherwise E1.E2 is an xvalue.  */
     168              :         op1_lvalue_kind = clk_rvalueref;
     169              : 
     170              :       /* Look at the member designator.  */
     171    250536773 :       if (!op1_lvalue_kind)
     172              :         ;
     173    250710800 :       else if (is_overloaded_fn (TREE_OPERAND (ref, 1)))
     174              :         /* The "field" can be a FUNCTION_DECL or an OVERLOAD in some
     175              :            situations.  If we're seeing a COMPONENT_REF, it's a non-static
     176              :            member, so it isn't an lvalue. */
     177              :         op1_lvalue_kind = clk_none;
     178    250710709 :       else if (TREE_CODE (TREE_OPERAND (ref, 1)) != FIELD_DECL)
     179              :         /* This can be IDENTIFIER_NODE in a template.  */;
     180    243181297 :       else if (DECL_C_BIT_FIELD (TREE_OPERAND (ref, 1)))
     181              :         {
     182              :           /* Clear the ordinary bit.  If this object was a class
     183              :              rvalue we want to preserve that information.  */
     184     31901211 :           op1_lvalue_kind &= ~clk_ordinary;
     185              :           /* The lvalue is for a bitfield.  */
     186     31901211 :           op1_lvalue_kind |= clk_bitfield;
     187              :         }
     188    211280086 :       else if (DECL_PACKED (TREE_OPERAND (ref, 1)))
     189        15177 :         op1_lvalue_kind |= clk_packed;
     190              : 
     191              :       return op1_lvalue_kind;
     192              : 
     193              :     case STRING_CST:
     194              :       return clk_ordinary | clk_mergeable;
     195              : 
     196              :     case COMPOUND_LITERAL_EXPR:
     197              :       return clk_ordinary;
     198              : 
     199      4023526 :     case CONST_DECL:
     200              :       /* CONST_DECL without TREE_STATIC are enumeration values and
     201              :          thus not lvalues.  With TREE_STATIC they are used by ObjC++
     202              :          in objc_build_string_object and need to be considered as
     203              :          lvalues.  */
     204      4023526 :       if (! TREE_STATIC (ref))
     205              :         return clk_none;
     206              :       /* FALLTHRU */
     207    348671723 :     case VAR_DECL:
     208    348671723 :       if (VAR_P (ref) && DECL_HAS_VALUE_EXPR_P (ref))
     209       835622 :         return lvalue_kind (DECL_VALUE_EXPR (const_cast<tree> (ref)));
     210              : 
     211    488215690 :       if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
     212     24922043 :           && DECL_LANG_SPECIFIC (ref)
     213    348961859 :           && DECL_IN_AGGR_P (ref))
     214              :         return clk_none;
     215              : 
     216    347836101 :       if (TREE_CODE (ref) == CONST_DECL || DECL_MERGEABLE (ref))
     217              :         return clk_ordinary | clk_mergeable;
     218              : 
     219              :       /* FALLTHRU */
     220              :     case INDIRECT_REF:
     221              :     case ARROW_EXPR:
     222              :     case PARM_DECL:
     223              :     case RESULT_DECL:
     224              :     case PLACEHOLDER_EXPR:
     225              :       return clk_ordinary;
     226              : 
     227              :       /* A scope ref in a template, left as SCOPE_REF to support later
     228              :          access checking.  */
     229     11056295 :     case SCOPE_REF:
     230     11056295 :       gcc_assert (!type_dependent_expression_p (const_cast<tree> (ref)));
     231     11056295 :       {
     232     11056295 :         tree op = TREE_OPERAND (ref, 1);
     233     11056295 :         if (TREE_CODE (op) == FIELD_DECL)
     234        17901 :           return (DECL_C_BIT_FIELD (op) ? clk_bitfield : clk_ordinary);
     235              :         else
     236              :           return lvalue_kind (op);
     237              :       }
     238              : 
     239          485 :     case MAX_EXPR:
     240          485 :     case MIN_EXPR:
     241              :       /* Disallow <? and >? as lvalues if either argument side-effects.  */
     242          485 :       if (TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 0))
     243          485 :           || TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 1)))
     244              :         return clk_none;
     245          485 :       op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
     246          485 :       op2_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 1));
     247          485 :       break;
     248              : 
     249     14870962 :     case COND_EXPR:
     250     14870962 :       if (processing_template_decl)
     251              :         {
     252              :           /* Within templates, a REFERENCE_TYPE will indicate whether
     253              :              the COND_EXPR result is an ordinary lvalue or rvalueref.
     254              :              Since REFERENCE_TYPEs are handled above, if we reach this
     255              :              point, we know we got a plain rvalue.  Unless we have a
     256              :              type-dependent expr, that is, but we shouldn't be testing
     257              :              lvalueness if we can't even tell the types yet!  */
     258      1171144 :           gcc_assert (!type_dependent_expression_p (const_cast<tree> (ref)));
     259      1171144 :           goto default_;
     260              :         }
     261     13699818 :       {
     262     13699818 :         tree op1 = TREE_OPERAND (ref, 1);
     263     13699818 :         if (!op1) op1 = TREE_OPERAND (ref, 0);
     264     13699818 :         tree op2 = TREE_OPERAND (ref, 2);
     265     13699818 :         op1_lvalue_kind = lvalue_kind (op1);
     266     13699818 :         op2_lvalue_kind = lvalue_kind (op2);
     267     13699818 :         if (!op1_lvalue_kind != !op2_lvalue_kind)
     268              :           {
     269              :             /* The second or the third operand (but not both) is a
     270              :                throw-expression; the result is of the type
     271              :                and value category of the other.  */
     272       542763 :             if (op1_lvalue_kind && TREE_CODE (op2) == THROW_EXPR)
     273              :               op2_lvalue_kind = op1_lvalue_kind;
     274       542721 :             else if (op2_lvalue_kind && TREE_CODE (op1) == THROW_EXPR)
     275     13700303 :               op1_lvalue_kind = op2_lvalue_kind;
     276              :           }
     277              :       }
     278              :       break;
     279              : 
     280        92906 :     case MODOP_EXPR:
     281              :       /* We expect to see unlowered MODOP_EXPRs only during
     282              :          template processing.  */
     283        92906 :       gcc_assert (processing_template_decl);
     284        92906 :       if (CLASS_TYPE_P (TREE_TYPE (TREE_OPERAND (ref, 0))))
     285            3 :         goto default_;
     286              :       else
     287              :         return clk_ordinary;
     288              : 
     289              :     case MODIFY_EXPR:
     290              :     case TYPEID_EXPR:
     291              :       return clk_ordinary;
     292              : 
     293      3630380 :     case COMPOUND_EXPR:
     294      3630380 :       return lvalue_kind (TREE_OPERAND (ref, 1));
     295              : 
     296              :     case TARGET_EXPR:
     297              :       return clk_class;
     298              : 
     299         1395 :     case VA_ARG_EXPR:
     300         1395 :       return (CLASS_TYPE_P (TREE_TYPE (ref)) ? clk_class : clk_none);
     301              : 
     302    143038919 :     case CALL_EXPR:
     303              :       /* We can see calls outside of TARGET_EXPR in templates.  */
     304    143038919 :       if (CLASS_TYPE_P (TREE_TYPE (ref)))
     305              :         return clk_class;
     306              :       return clk_none;
     307              : 
     308    158730642 :     case FUNCTION_DECL:
     309              :       /* All functions (except non-static-member functions) are
     310              :          lvalues.  */
     311    158730642 :       return (DECL_IOBJ_MEMBER_FUNCTION_P (ref)
     312    158730642 :               ? clk_none : clk_ordinary);
     313              : 
     314         1550 :     case BASELINK:
     315              :       /* We now represent a reference to a single static member function
     316              :          with a BASELINK.  */
     317              :       /* This CONST_CAST is okay because BASELINK_FUNCTIONS returns
     318              :          its argument unmodified and we assign it to a const_tree.  */
     319         1550 :       return lvalue_kind (BASELINK_FUNCTIONS (const_cast<tree> (ref)));
     320              : 
     321        32243 :     case PAREN_EXPR:
     322        32243 :       return lvalue_kind (TREE_OPERAND (ref, 0));
     323              : 
     324     15974354 :     case TEMPLATE_PARM_INDEX:
     325     15974354 :       if (CLASS_TYPE_P (TREE_TYPE (ref)))
     326              :         /* A template parameter object is an lvalue.  */
     327              :         return clk_ordinary;
     328              :       return clk_none;
     329              : 
     330   1121210919 :     default:
     331   1121210919 :     default_:
     332   1121210919 :       if (!TREE_TYPE (ref))
     333              :         return clk_none;
     334   2242421838 :       if (CLASS_TYPE_P (TREE_TYPE (ref))
     335   2239093297 :           || TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE)
     336              :         return clk_class;
     337              :       return clk_none;
     338              :     }
     339              : 
     340              :   /* If one operand is not an lvalue at all, then this expression is
     341              :      not an lvalue.  */
     342     13700303 :   if (!op1_lvalue_kind || !op2_lvalue_kind)
     343              :     return clk_none;
     344              : 
     345              :   /* Otherwise, it's an lvalue, and it has all the odd properties
     346              :      contributed by either operand.  */
     347      4851810 :   op1_lvalue_kind = op1_lvalue_kind | op2_lvalue_kind;
     348              :   /* It's not an ordinary lvalue if it involves any other kind.  */
     349      4851810 :   if ((op1_lvalue_kind & ~clk_ordinary) != clk_none)
     350      1208024 :     op1_lvalue_kind &= ~clk_ordinary;
     351              :   /* It can't be both a pseudo-lvalue and a non-addressable lvalue.
     352              :      A COND_EXPR of those should be wrapped in a TARGET_EXPR.  */
     353      1208024 :   if ((op1_lvalue_kind & (clk_rvalueref|clk_class))
     354        37247 :       && (op1_lvalue_kind & (clk_bitfield|clk_packed)))
     355   1264554987 :     op1_lvalue_kind = clk_none;
     356              :   return op1_lvalue_kind;
     357              : }
     358              : 
     359              : /* Returns the kind of lvalue that REF is, in the sense of [basic.lval].  */
     360              : 
     361              : cp_lvalue_kind
     362     46951859 : real_lvalue_p (const_tree ref)
     363              : {
     364     46951859 :   cp_lvalue_kind kind = lvalue_kind (ref);
     365     46951859 :   if (kind & (clk_rvalueref|clk_class))
     366              :     return clk_none;
     367              :   else
     368     44833094 :     return kind;
     369              : }
     370              : 
     371              : /* c-common wants us to return bool.  */
     372              : 
     373              : bool
     374     46106975 : lvalue_p (const_tree t)
     375              : {
     376     46106975 :   return real_lvalue_p (t);
     377              : }
     378              : 
     379              : /* This differs from lvalue_p in that xvalues are included.  */
     380              : 
     381              : bool
     382    176110163 : glvalue_p (const_tree ref)
     383              : {
     384    176110163 :   cp_lvalue_kind kind = lvalue_kind (ref);
     385    176110163 :   if (kind & clk_class)
     386              :     return false;
     387              :   else
     388    172434266 :     return (kind != clk_none);
     389              : }
     390              : 
     391              : /* This differs from glvalue_p in that class prvalues are included.  */
     392              : 
     393              : bool
     394   1488909966 : obvalue_p (const_tree ref)
     395              : {
     396   1488909966 :   return (lvalue_kind (ref) != clk_none);
     397              : }
     398              : 
     399              : /* Returns true if REF is an xvalue (the result of dereferencing an rvalue
     400              :    reference), false otherwise.  */
     401              : 
     402              : bool
     403      7197084 : xvalue_p (const_tree ref)
     404              : {
     405      7197084 :   return (lvalue_kind (ref) & clk_rvalueref);
     406              : }
     407              : 
     408              : /* True if REF is a bit-field.  */
     409              : 
     410              : bool
     411    276369633 : bitfield_p (const_tree ref)
     412              : {
     413    276369633 :   return (lvalue_kind (ref) & clk_bitfield);
     414              : }
     415              : 
     416              : /* True if REF is a glvalue with a unique address, excluding mergeable glvalues
     417              :    such as string constants.  */
     418              : 
     419              : bool
     420          108 : non_mergeable_glvalue_p (const_tree ref)
     421              : {
     422          108 :   auto kind = lvalue_kind (ref);
     423          108 :   return (kind != clk_none
     424          108 :           && !(kind & (clk_class|clk_mergeable)));
     425              : }
     426              : 
     427              : /* C++-specific version of stabilize_reference for bit-fields and
     428              :    DECL_PACKED fields.  We can't bind a reference to those.  */
     429              : 
     430              : static tree
     431           48 : cp_stabilize_bitfield_reference (tree ref)
     432              : {
     433           48 :   tree op1, op2, op3;
     434           48 :   STRIP_ANY_LOCATION_WRAPPER (ref);
     435           48 :   switch (TREE_CODE (ref))
     436              :     {
     437           24 :     case VAR_DECL:
     438           24 :     case PARM_DECL:
     439           24 :     case RESULT_DECL:
     440           24 :     CASE_CONVERT:
     441           24 :     case FLOAT_EXPR:
     442           24 :     case FIX_TRUNC_EXPR:
     443           24 :     case INDIRECT_REF:
     444           24 :     case COMPONENT_REF:
     445           24 :     case BIT_FIELD_REF:
     446           24 :     case ARRAY_REF:
     447           24 :     case ARRAY_RANGE_REF:
     448           24 :     case ERROR_MARK:
     449           24 :     case REALPART_EXPR:
     450           24 :     case IMAGPART_EXPR:
     451           24 :     default:
     452           24 :       break;
     453           24 :     case COMPOUND_EXPR:
     454           24 :       op2 = cp_stabilize_bitfield_reference (TREE_OPERAND (ref, 1));
     455           24 :       if (op2 == TREE_OPERAND (ref, 1))
     456              :         return ref;
     457           24 :       op1 = TREE_OPERAND (ref, 0);
     458           24 :       if (TREE_SIDE_EFFECTS (op1))
     459              :         {
     460           24 :           if (VOID_TYPE_P (TREE_TYPE (op1)))
     461            0 :             op1 = save_expr (op1);
     462              :           else
     463              :             {
     464           24 :               op1 = build2 (COMPOUND_EXPR, void_type_node, op1,
     465              :                             void_node);
     466           24 :               op1 = save_expr (op1);
     467              :             }
     468              :         }
     469           24 :       return build2 (COMPOUND_EXPR, TREE_TYPE (op2), op1, op2);
     470            0 :     case COND_EXPR:
     471            0 :       op1 = TREE_OPERAND (ref, 0);
     472            0 :       op2 = TREE_OPERAND (ref, 1);
     473            0 :       op3 = TREE_OPERAND (ref, 2);
     474            0 :       if (op2 && TREE_CODE (op2) != THROW_EXPR)
     475            0 :         op2 = cp_stabilize_bitfield_reference (op2);
     476            0 :       if (TREE_CODE (op3) != THROW_EXPR)
     477            0 :         op3 = cp_stabilize_bitfield_reference (op3);
     478            0 :       if (op2 == NULL_TREE)
     479            0 :         op1 = cp_stabilize_bitfield_reference (op1);
     480            0 :       if (op1 == TREE_OPERAND (ref, 0)
     481            0 :           && op2 == TREE_OPERAND (ref, 1)
     482            0 :           && op3 == TREE_OPERAND (ref, 2))
     483              :         return ref;
     484            0 :       if (op2 != NULL_TREE && TREE_SIDE_EFFECTS (op1))
     485            0 :         op1 = save_expr (op1);
     486            0 :       return build3 (COND_EXPR, TREE_TYPE (ref), op1, op2, op3);
     487            0 :     case PREINCREMENT_EXPR:
     488            0 :     case PREDECREMENT_EXPR:
     489            0 :       op1 = cp_stabilize_bitfield_reference (TREE_OPERAND (ref, 0));
     490            0 :       if (op1 == TREE_OPERAND (ref, 0))
     491              :         return ref;
     492            0 :       return build2 (COMPOUND_EXPR, TREE_TYPE (ref),
     493            0 :                      build2 (TREE_CODE (ref), TREE_TYPE (ref), op1,
     494            0 :                              TREE_OPERAND (ref, 0)), op1);
     495            0 :     case PAREN_EXPR:
     496            0 :       op1 = cp_stabilize_bitfield_reference (TREE_OPERAND (ref, 0));
     497            0 :       if (op1 == TREE_OPERAND (ref, 0))
     498              :         return ref;
     499            0 :       return build1 (PAREN_EXPR, TREE_TYPE (ref), op1);
     500              :     }
     501           24 :   return stabilize_reference (ref);
     502              : }
     503              : 
     504              : /* C++-specific version of stabilize_reference.  */
     505              : 
     506              : tree
     507      5166254 : cp_stabilize_reference (tree ref)
     508              : {
     509      5166254 :   if (processing_template_decl)
     510              :     /* As in cp_save_expr.  */
     511              :     return ref;
     512              : 
     513      4470994 :   STRIP_ANY_LOCATION_WRAPPER (ref);
     514      4470994 :   switch (TREE_CODE (ref))
     515              :     {
     516              :     /* We need to treat specially anything stabilize_reference doesn't
     517              :        handle specifically.  */
     518              :     case VAR_DECL:
     519              :     case PARM_DECL:
     520              :     case RESULT_DECL:
     521              :     CASE_CONVERT:
     522              :     case FLOAT_EXPR:
     523              :     case FIX_TRUNC_EXPR:
     524              :     case INDIRECT_REF:
     525              :     case COMPONENT_REF:
     526              :     case BIT_FIELD_REF:
     527              :     case ARRAY_REF:
     528              :     case ARRAY_RANGE_REF:
     529              :     case ERROR_MARK:
     530              :       break;
     531          449 :     default:
     532          449 :       cp_lvalue_kind kind = lvalue_kind (ref);
     533          449 :       if ((kind & ~clk_class) != clk_none)
     534              :         {
     535          440 :           if (kind & (clk_bitfield | clk_packed))
     536           24 :             return cp_stabilize_bitfield_reference (ref);
     537          416 :           tree type = unlowered_expr_type (ref);
     538          416 :           bool rval = !!(kind & clk_rvalueref);
     539          416 :           type = cp_build_reference_type (type, rval);
     540              :           /* This inhibits warnings in, eg, cxx_mark_addressable
     541              :              (c++/60955).  */
     542          416 :           warning_sentinel s (extra_warnings);
     543          416 :           ref = build_static_cast (input_location, type, ref,
     544              :                                    tf_error);
     545          416 :         }
     546              :     }
     547              : 
     548      4470970 :   return stabilize_reference (ref);
     549              : }
     550              : 
     551              : /* Test whether DECL is a builtin that may appear in a
     552              :    constant-expression. */
     553              : 
     554              : bool
     555    583546726 : builtin_valid_in_constant_expr_p (const_tree decl)
     556              : {
     557    583546726 :   STRIP_ANY_LOCATION_WRAPPER (decl);
     558    583546726 :   if (TREE_CODE (decl) != FUNCTION_DECL)
     559              :     /* Not a function.  */
     560              :     return false;
     561    316699771 :   if (DECL_BUILT_IN_CLASS (decl) != BUILT_IN_NORMAL)
     562              :     {
     563    279050411 :       if (fndecl_built_in_p (decl, BUILT_IN_FRONTEND))
     564       227163 :         switch (DECL_FE_FUNCTION_CODE (decl))
     565              :           {
     566              :           case CP_BUILT_IN_IS_CONSTANT_EVALUATED:
     567              :           case CP_BUILT_IN_SOURCE_LOCATION:
     568              :           case CP_BUILT_IN_IS_CORRESPONDING_MEMBER:
     569              :           case CP_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS:
     570              :           case CP_BUILT_IN_EH_PTR_ADJUST_REF:
     571              :           case CP_BUILT_IN_IS_STRING_LITERAL:
     572              :           case CP_BUILT_IN_CONSTEXPR_DIAG:
     573              :             return true;
     574              :           default:
     575              :             break;
     576              :           }
     577              :       /* Not a built-in.  */
     578              :       return false;
     579              :     }
     580     37649360 :   switch (DECL_FUNCTION_CODE (decl))
     581              :     {
     582              :       /* These always have constant results like the corresponding
     583              :          macros/symbol.  */
     584              :     case BUILT_IN_FILE:
     585              :     case BUILT_IN_FUNCTION:
     586              :     case BUILT_IN_LINE:
     587              : 
     588              :       /* The following built-ins are valid in constant expressions
     589              :          when their arguments are.  */
     590              :     case BUILT_IN_ADD_OVERFLOW_P:
     591              :     case BUILT_IN_SUB_OVERFLOW_P:
     592              :     case BUILT_IN_MUL_OVERFLOW_P:
     593              : 
     594              :       /* These have constant results even if their operands are
     595              :          non-constant.  */
     596              :     case BUILT_IN_CONSTANT_P:
     597              :     case BUILT_IN_ATOMIC_ALWAYS_LOCK_FREE:
     598              :       return true;
     599              :     default:
     600              :       return false;
     601              :     }
     602              : }
     603              : 
     604              : /* Build a TARGET_EXPR, initializing the DECL with the VALUE.  */
     605              : 
     606              : static tree
     607     47795495 : build_target_expr (tree decl, tree value, tsubst_flags_t complain)
     608              : {
     609     47795495 :   tree t;
     610     47795495 :   tree type = TREE_TYPE (decl);
     611              : 
     612     47795495 :   value = mark_rvalue_use (value);
     613              : 
     614     47795495 :   gcc_checking_assert (VOID_TYPE_P (TREE_TYPE (value))
     615              :                        || TREE_TYPE (decl) == TREE_TYPE (value)
     616              :                        /* On ARM ctors return 'this'.  */
     617              :                        || (TYPE_PTR_P (TREE_TYPE (value))
     618              :                            && TREE_CODE (value) == CALL_EXPR)
     619              :                        || useless_type_conversion_p (TREE_TYPE (decl),
     620              :                                                      TREE_TYPE (value)));
     621              : 
     622              :   /* Set TREE_READONLY for optimization, such as gimplify_init_constructor
     623              :      moving a constant aggregate into .rodata.  */
     624     47795495 :   if (CP_TYPE_CONST_NON_VOLATILE_P (type)
     625      2574667 :       && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
     626      2403371 :       && !VOID_TYPE_P (TREE_TYPE (value))
     627      1219473 :       && !TYPE_HAS_MUTABLE_P (type)
     628     49014961 :       && reduced_constant_expression_p (value))
     629       316358 :     TREE_READONLY (decl) = true;
     630              : 
     631     47795495 :   if (complain & tf_no_cleanup)
     632              :     /* The caller is building a new-expr and does not need a cleanup.  */
     633              :     t = NULL_TREE;
     634              :   else
     635              :     {
     636     46994817 :       t = cxx_maybe_build_cleanup (decl, complain);
     637     46994817 :       if (t == error_mark_node)
     638              :         return error_mark_node;
     639              :     }
     640              : 
     641     47795459 :   set_target_expr_eliding (value);
     642              : 
     643     47795459 :   t = build4 (TARGET_EXPR, type, decl, value, t, NULL_TREE);
     644     47795459 :   if (location_t eloc = cp_expr_location (value))
     645     31726603 :     SET_EXPR_LOCATION (t, eloc);
     646              :   /* We always set TREE_SIDE_EFFECTS so that expand_expr does not
     647              :      ignore the TARGET_EXPR.  If there really turn out to be no
     648              :      side-effects, then the optimizer should be able to get rid of
     649              :      whatever code is generated anyhow.  */
     650     47795459 :   TREE_SIDE_EFFECTS (t) = 1;
     651              : 
     652     47795459 :   return t;
     653              : }
     654              : 
     655              : /* Return an undeclared local temporary of type TYPE for use in building a
     656              :    TARGET_EXPR.  */
     657              : 
     658              : tree
     659     53842159 : build_local_temp (tree type)
     660              : {
     661     53842159 :   tree slot = build_decl (input_location,
     662              :                           VAR_DECL, NULL_TREE, type);
     663     53842159 :   DECL_ARTIFICIAL (slot) = 1;
     664     53842159 :   DECL_IGNORED_P (slot) = 1;
     665     53842159 :   DECL_CONTEXT (slot) = current_function_decl;
     666     53842159 :   layout_decl (slot, 0);
     667     53842159 :   return slot;
     668              : }
     669              : 
     670              : /* Return whether DECL is such a local temporary (or one from
     671              :    create_tmp_var_raw).  */
     672              : 
     673              : bool
     674     63977353 : is_local_temp (tree decl)
     675              : {
     676     63977353 :   return (VAR_P (decl) && DECL_ARTIFICIAL (decl)
     677     64572578 :           && !TREE_STATIC (decl));
     678              : }
     679              : 
     680              : /* Set various status flags when building an AGGR_INIT_EXPR object T.  */
     681              : 
     682              : static void
     683     15956274 : process_aggr_init_operands (tree t)
     684              : {
     685     15956274 :   bool side_effects;
     686              : 
     687     15956274 :   side_effects = TREE_SIDE_EFFECTS (t);
     688     15956274 :   if (!side_effects)
     689              :     {
     690     15956274 :       int i, n;
     691     15956274 :       n = TREE_OPERAND_LENGTH (t);
     692     71304588 :       for (i = 1; i < n; i++)
     693              :         {
     694     59740977 :           tree op = TREE_OPERAND (t, i);
     695     59740977 :           if (op && TREE_SIDE_EFFECTS (op))
     696              :             {
     697              :               side_effects = 1;
     698              :               break;
     699              :             }
     700              :         }
     701              :     }
     702     15956274 :   TREE_SIDE_EFFECTS (t) = side_effects;
     703     15956274 : }
     704              : 
     705              : /* Build an AGGR_INIT_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE,
     706              :    FN, and SLOT.  NARGS is the number of call arguments which are specified
     707              :    as a tree array ARGS.  */
     708              : 
     709              : static tree
     710     15956274 : build_aggr_init_array (tree return_type, tree fn, tree slot, int nargs,
     711              :                        tree *args)
     712              : {
     713     15956274 :   tree t;
     714     15956274 :   int i;
     715              : 
     716     15956274 :   t = build_vl_exp (AGGR_INIT_EXPR, nargs + 3);
     717     15956274 :   TREE_TYPE (t) = return_type;
     718     15956274 :   AGGR_INIT_EXPR_FN (t) = fn;
     719     15956274 :   AGGR_INIT_EXPR_SLOT (t) = slot;
     720     45884179 :   for (i = 0; i < nargs; i++)
     721     29927905 :     AGGR_INIT_EXPR_ARG (t, i) = args[i];
     722     15956274 :   process_aggr_init_operands (t);
     723     15956274 :   return t;
     724              : }
     725              : 
     726              : /* INIT is a CALL_EXPR or AGGR_INIT_EXPR which needs info about its
     727              :    target.  TYPE is the type to be initialized.
     728              : 
     729              :    Build an AGGR_INIT_EXPR to represent the initialization.  This function
     730              :    differs from build_cplus_new in that an AGGR_INIT_EXPR can only be used
     731              :    to initialize another object, whereas a TARGET_EXPR can either
     732              :    initialize another object or create its own temporary object, and as a
     733              :    result building up a TARGET_EXPR requires that the type's destructor be
     734              :    callable.  */
     735              : 
     736              : tree
     737     55862936 : build_aggr_init_expr (tree type, tree init)
     738              : {
     739     55862936 :   tree fn;
     740     55862936 :   tree slot;
     741     55862936 :   tree rval;
     742     55862936 :   int is_ctor;
     743              : 
     744     55862936 :   gcc_assert (!VOID_TYPE_P (type));
     745              : 
     746              :   /* Don't build AGGR_INIT_EXPR in a template.  */
     747     55862936 :   if (processing_template_decl)
     748              :     return init;
     749              : 
     750     55725895 :   fn = cp_get_callee (init);
     751     55725895 :   if (fn == NULL_TREE)
     752     23174924 :     return convert (type, init);
     753              : 
     754     66570987 :   is_ctor = (TREE_CODE (fn) == ADDR_EXPR
     755     32442452 :              && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
     756     97435875 :              && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0)));
     757              : 
     758              :   /* We split the CALL_EXPR into its function and its arguments here.
     759              :      Then, in expand_expr, we put them back together.  The reason for
     760              :      this is that this expression might be a default argument
     761              :      expression.  In that case, we need a new temporary every time the
     762              :      expression is used.  That's what break_out_target_exprs does; it
     763              :      replaces every AGGR_INIT_EXPR with a copy that uses a fresh
     764              :      temporary slot.  Then, expand_expr builds up a call-expression
     765              :      using the new slot.  */
     766              : 
     767              :   /* If we don't need to use a constructor to create an object of this
     768              :      type, don't mess with AGGR_INIT_EXPR.  */
     769     18063742 :   if (is_ctor || TREE_ADDRESSABLE (type))
     770              :     {
     771     15956274 :       slot = build_local_temp (type);
     772              : 
     773     15956274 :       if (TREE_CODE (init) == CALL_EXPR)
     774              :         {
     775     61795144 :           rval = build_aggr_init_array (void_type_node, fn, slot,
     776     15448786 :                                         call_expr_nargs (init),
     777     15448786 :                                         CALL_EXPR_ARGP (init));
     778     15448786 :           AGGR_INIT_FROM_THUNK_P (rval)
     779     15448786 :             = CALL_FROM_THUNK_P (init);
     780              :         }
     781              :       else
     782              :         {
     783       507488 :           rval = build_aggr_init_array (void_type_node, fn, slot,
     784       507488 :                                         aggr_init_expr_nargs (init),
     785       507488 :                                         AGGR_INIT_EXPR_ARGP (init));
     786       507488 :           AGGR_INIT_FROM_THUNK_P (rval)
     787       507488 :             = AGGR_INIT_FROM_THUNK_P (init);
     788              :         }
     789     15956274 :       TREE_SIDE_EFFECTS (rval) = 1;
     790     15956274 :       AGGR_INIT_VIA_CTOR_P (rval) = is_ctor;
     791     15956274 :       TREE_NOTHROW (rval) = TREE_NOTHROW (init);
     792     15956274 :       CALL_EXPR_OPERATOR_SYNTAX (rval) = CALL_EXPR_OPERATOR_SYNTAX (init);
     793     15956274 :       CALL_EXPR_ORDERED_ARGS (rval) = CALL_EXPR_ORDERED_ARGS (init);
     794     15956274 :       CALL_EXPR_REVERSE_ARGS (rval) = CALL_EXPR_REVERSE_ARGS (init);
     795     15956274 :       SET_EXPR_LOCATION (rval, EXPR_LOCATION (init));
     796              :     }
     797              :   else
     798              :     rval = init;
     799              : 
     800              :   return rval;
     801              : }
     802              : 
     803              : /* INIT is a CALL_EXPR or AGGR_INIT_EXPR which needs info about its
     804              :    target.  TYPE is the type that this initialization should appear to
     805              :    have.
     806              : 
     807              :    Build an encapsulation of the initialization to perform
     808              :    and return it so that it can be processed by language-independent
     809              :    and language-specific expression expanders.  */
     810              : 
     811              : tree
     812     48933682 : build_cplus_new (tree type, tree init, tsubst_flags_t complain)
     813              : {
     814              :   /* This function should cope with what build_special_member_call
     815              :      can produce.  When performing parenthesized aggregate initialization,
     816              :      it can produce a { }.  */
     817     48933682 :   if (BRACE_ENCLOSED_INITIALIZER_P (init))
     818              :     {
     819          310 :       gcc_assert (cxx_dialect >= cxx20);
     820          310 :       return finish_compound_literal (type, init, complain);
     821              :     }
     822              : 
     823     48933372 :   tree rval = build_aggr_init_expr (type, init);
     824     48933372 :   tree slot;
     825              : 
     826     48933372 :   if (init == error_mark_node)
     827              :     return error_mark_node;
     828              : 
     829     48931309 :   if (!complete_type_or_maybe_complain (type, init, complain))
     830            6 :     return error_mark_node;
     831              : 
     832              :   /* Make sure that we're not trying to create an instance of an
     833              :      abstract class.  */
     834     48931303 :   if (abstract_virtuals_error (NULL_TREE, type, complain))
     835           19 :     return error_mark_node;
     836              : 
     837     48931284 :   if (TREE_CODE (rval) == AGGR_INIT_EXPR)
     838      9287573 :     slot = AGGR_INIT_EXPR_SLOT (rval);
     839     39643711 :   else if (TREE_CODE (rval) == CALL_EXPR
     840     22911990 :            || TREE_CODE (rval) == CONSTRUCTOR)
     841     16731885 :     slot = build_local_temp (type);
     842              :   else
     843              :     return rval;
     844              : 
     845     26019458 :   rval = build_target_expr (slot, rval, complain);
     846              : 
     847     26019458 :   if (rval != error_mark_node)
     848     26019458 :     TARGET_EXPR_IMPLICIT_P (rval) = 1;
     849              : 
     850              :   return rval;
     851              : }
     852              : 
     853              : /* Subroutine of build_vec_init_expr: Build up a single element
     854              :    intialization as a proxy for the full array initialization to get things
     855              :    marked as used and any appropriate diagnostics.
     856              : 
     857              :    This used to be necessary because we were deferring building the actual
     858              :    constructor calls until gimplification time; now we only do it to set
     859              :    VEC_INIT_EXPR_IS_CONSTEXPR.
     860              : 
     861              :    We assume that init is either NULL_TREE, {}, void_type_node (indicating
     862              :    value-initialization), or another array to copy.  */
     863              : 
     864              : static tree
     865         1167 : build_vec_init_elt (tree type, tree init, tsubst_flags_t complain)
     866              : {
     867         1167 :   tree inner_type = strip_array_types (type);
     868              : 
     869         1167 :   if (integer_zerop (array_type_nelts_total (type))
     870         1167 :       || !CLASS_TYPE_P (inner_type))
     871              :     /* No interesting initialization to do.  */
     872          216 :     return integer_zero_node;
     873          951 :   if (init && BRACE_ENCLOSED_INITIALIZER_P (init))
     874              :     {
     875              :       /* Even if init has initializers for some array elements,
     876              :          we're interested in the {}-init of trailing elements.  */
     877          119 :       if (CP_AGGREGATE_TYPE_P (inner_type))
     878              :         {
     879           34 :           tree empty = build_constructor (init_list_type_node, nullptr);
     880           34 :           return digest_init (inner_type, empty, complain);
     881              :         }
     882              :       else
     883              :         /* It's equivalent to value-init.  */
     884           85 :         init = void_type_node;
     885              :     }
     886          917 :   if (init == void_type_node)
     887          116 :     return build_value_init (inner_type, complain);
     888              : 
     889          801 :   releasing_vec argvec;
     890          801 :   if (init && !BRACE_ENCLOSED_INITIALIZER_P (init))
     891              :     {
     892          202 :       tree init_type = strip_array_types (TREE_TYPE (init));
     893          202 :       tree dummy = build_dummy_object (init_type);
     894          202 :       if (!lvalue_p (init))
     895          157 :         dummy = move (dummy);
     896          202 :       argvec->quick_push (dummy);
     897              :     }
     898          801 :   init = build_special_member_call (NULL_TREE, complete_ctor_identifier,
     899              :                                     &argvec, inner_type, LOOKUP_NORMAL,
     900              :                                     complain);
     901              : 
     902              :   /* For a trivial constructor, build_over_call creates a TARGET_EXPR.  But
     903              :      we don't want one here because we aren't creating a temporary.  */
     904          801 :   if (TREE_CODE (init) == TARGET_EXPR)
     905           32 :     init = TARGET_EXPR_INITIAL (init);
     906              : 
     907          801 :   return init;
     908          801 : }
     909              : 
     910              : /* Return a TARGET_EXPR which expresses the initialization of an array to
     911              :    be named later, either default-initialization or copy-initialization
     912              :    from another array of the same type.  */
     913              : 
     914              : tree
     915         1184 : build_vec_init_expr (tree type, tree init, tsubst_flags_t complain)
     916              : {
     917         1184 :   if (tree vi = get_vec_init_expr (init))
     918              :     return vi;
     919              : 
     920         1169 :   tree elt_init;
     921          558 :   if (init && TREE_CODE (init) == CONSTRUCTOR
     922         1292 :       && !BRACE_ENCLOSED_INITIALIZER_P (init))
     923              :     /* We built any needed constructor calls in digest_init.  */
     924              :     elt_init = init;
     925              :   else
     926         1165 :     elt_init = build_vec_init_elt (type, init, complain);
     927              : 
     928         1169 :   bool value_init = false;
     929         1169 :   if (init == void_type_node)
     930              :     {
     931          226 :       value_init = true;
     932          226 :       init = NULL_TREE;
     933              :     }
     934              : 
     935         1169 :   tree slot = build_local_temp (type);
     936         1169 :   init = build2 (VEC_INIT_EXPR, type, slot, init);
     937         1169 :   TREE_SIDE_EFFECTS (init) = true;
     938         1169 :   SET_EXPR_LOCATION (init, input_location);
     939              : 
     940         1169 :   if (cxx_dialect >= cxx11)
     941              :     {
     942         1104 :       bool cx = potential_constant_expression (elt_init);
     943         1104 :       if (BRACE_ENCLOSED_INITIALIZER_P (init))
     944            0 :         cx &= potential_constant_expression (init);
     945         1104 :       VEC_INIT_EXPR_IS_CONSTEXPR (init) = cx;
     946              :     }
     947         1169 :   VEC_INIT_EXPR_VALUE_INIT (init) = value_init;
     948              : 
     949         1169 :   return init;
     950              : }
     951              : 
     952              : /* Call build_vec_init to expand VEC_INIT into TARGET (for which NULL_TREE
     953              :    means VEC_INIT_EXPR_SLOT).  */
     954              : 
     955              : tree
     956         1185 : expand_vec_init_expr (tree target, tree vec_init, tsubst_flags_t complain,
     957              :                       vec<tree,va_gc> **flags)
     958              : {
     959         1185 :   iloc_sentinel ils = EXPR_LOCATION (vec_init);
     960              : 
     961         1185 :   if (!target)
     962            0 :     target = VEC_INIT_EXPR_SLOT (vec_init);
     963         1185 :   tree init = VEC_INIT_EXPR_INIT (vec_init);
     964         1185 :   int from_array = (init && TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE);
     965         3555 :   return build_vec_init (target, NULL_TREE, init,
     966         1185 :                          VEC_INIT_EXPR_VALUE_INIT (vec_init),
     967         1185 :                          from_array, complain, flags);
     968         1185 : }
     969              : 
     970              : /* Give a helpful diagnostic for a non-constexpr VEC_INIT_EXPR in a context
     971              :    that requires a constant expression.  */
     972              : 
     973              : void
     974            2 : diagnose_non_constexpr_vec_init (tree expr)
     975              : {
     976            2 :   tree type = TREE_TYPE (VEC_INIT_EXPR_SLOT (expr));
     977            2 :   tree init, elt_init;
     978            2 :   if (VEC_INIT_EXPR_VALUE_INIT (expr))
     979            2 :     init = void_type_node;
     980              :   else
     981            0 :     init = VEC_INIT_EXPR_INIT (expr);
     982              : 
     983            2 :   elt_init = build_vec_init_elt (type, init, tf_warning_or_error);
     984            2 :   require_potential_constant_expression (elt_init);
     985            2 : }
     986              : 
     987              : tree
     988           19 : build_array_copy (tree init)
     989              : {
     990           19 :   return get_target_expr (build_vec_init_expr
     991           19 :                           (TREE_TYPE (init), init, tf_warning_or_error));
     992              : }
     993              : 
     994              : /* Build a TARGET_EXPR using INIT to initialize a new temporary of the
     995              :    indicated TYPE.  */
     996              : 
     997              : tree
     998     10859531 : build_target_expr_with_type (tree init, tree type, tsubst_flags_t complain)
     999              : {
    1000     10859531 :   gcc_assert (!VOID_TYPE_P (type));
    1001     10859531 :   gcc_assert (!VOID_TYPE_P (TREE_TYPE (init)));
    1002              : 
    1003     10859531 :   if (TREE_CODE (init) == TARGET_EXPR
    1004      9272264 :       || init == error_mark_node)
    1005              :     return init;
    1006      6780707 :   else if (CLASS_TYPE_P (type) && type_has_nontrivial_copy_init (type)
    1007        86467 :            && TREE_CODE (init) != COND_EXPR
    1008              :            && TREE_CODE (init) != CONSTRUCTOR
    1009              :            && TREE_CODE (init) != VA_ARG_EXPR
    1010      9272006 :            && TREE_CODE (init) != CALL_EXPR)
    1011              :     /* We need to build up a copy constructor call.  COND_EXPR is a special
    1012              :        case because we already have copies on the arms and we don't want
    1013              :        another one here.  A CONSTRUCTOR is aggregate initialization, which
    1014              :        is handled separately.  A VA_ARG_EXPR is magic creation of an
    1015              :        aggregate; there's no additional work to be done.  A CALL_EXPR
    1016              :        already creates a prvalue.  */
    1017            0 :     return force_rvalue (init, complain);
    1018              : 
    1019      9272006 :   return force_target_expr (type, init, complain);
    1020              : }
    1021              : 
    1022              : /* Like the above function, but without the checking.  This function should
    1023              :    only be used by code which is deliberately trying to subvert the type
    1024              :    system, such as call_builtin_trap.  Or build_over_call, to avoid
    1025              :    infinite recursion.  */
    1026              : 
    1027              : tree
    1028     21152808 : force_target_expr (tree type, tree init, tsubst_flags_t complain)
    1029              : {
    1030     21152808 :   tree slot;
    1031              : 
    1032     21152808 :   gcc_assert (!VOID_TYPE_P (type));
    1033              : 
    1034     21152808 :   slot = build_local_temp (type);
    1035     21152808 :   return build_target_expr (slot, init, complain);
    1036              : }
    1037              : 
    1038              : /* Like build_target_expr_with_type, but use the type of INIT.  */
    1039              : 
    1040              : tree
    1041      8445050 : get_target_expr (tree init, tsubst_flags_t complain /* = tf_warning_or_error */)
    1042              : {
    1043      8445050 :   if (TREE_CODE (init) == AGGR_INIT_EXPR)
    1044       622935 :     return build_target_expr (AGGR_INIT_EXPR_SLOT (init), init, complain);
    1045      7822115 :   else if (TREE_CODE (init) == VEC_INIT_EXPR)
    1046          294 :     return build_target_expr (VEC_INIT_EXPR_SLOT (init), init, complain);
    1047              :   else
    1048              :     {
    1049      7821821 :       init = convert_bitfield_to_declared_type (init);
    1050      7821821 :       return build_target_expr_with_type (init, TREE_TYPE (init), complain);
    1051              :     }
    1052              : }
    1053              : 
    1054              : /* Like get_target_expr, but for an internal detail like a cleanup flag or loop
    1055              :    iterator.  These variables should not be extended by extend_all_temps.
    1056              : 
    1057              :    This function can also be used for an ephemeral copy of a scalar value such
    1058              :    as the pointer to the allocated memory in build_new_1.
    1059              : 
    1060              :    This function should not be used for objects that are part of the abstract
    1061              :    C++ semantics such as in stabilize_expr.  */
    1062              : 
    1063              : tree
    1064      3001468 : get_internal_target_expr (tree init)
    1065              : {
    1066      3001468 :   init = convert_bitfield_to_declared_type (init);
    1067      3001468 :   tree t = force_target_expr (TREE_TYPE (init), init, tf_warning_or_error);
    1068      3001468 :   TARGET_EXPR_INTERNAL_P (t) = true;
    1069      3001468 :   return t;
    1070              : }
    1071              : 
    1072              : /* If EXPR is a bitfield reference, convert it to the declared type of
    1073              :    the bitfield, and return the resulting expression.  Otherwise,
    1074              :    return EXPR itself.  */
    1075              : 
    1076              : tree
    1077   1222131694 : convert_bitfield_to_declared_type (tree expr)
    1078              : {
    1079   1222131694 :   tree bitfield_type;
    1080              : 
    1081   1222131694 :   bitfield_type = is_bitfield_expr_with_lowered_type (expr);
    1082   1222131694 :   if (bitfield_type)
    1083      2218428 :     expr = convert_to_integer_nofold (TYPE_MAIN_VARIANT (bitfield_type),
    1084              :                                       expr);
    1085   1222131694 :   return expr;
    1086              : }
    1087              : 
    1088              : /* EXPR is being used in an rvalue context.  Return a version of EXPR
    1089              :    that is marked as an rvalue.  */
    1090              : 
    1091              : tree
    1092    213277298 : rvalue (tree expr)
    1093              : {
    1094    213277298 :   tree type;
    1095              : 
    1096    213277298 :   if (error_operand_p (expr))
    1097              :     return expr;
    1098              : 
    1099    213276975 :   expr = mark_rvalue_use (expr);
    1100              : 
    1101              :   /* [expr.type]: "If a prvalue initially has the type "cv T", where T is a
    1102              :      cv-unqualified non-class, non-array type, the type of the expression is
    1103              :      adjusted to T prior to any further analysis.  */
    1104    213276975 :   type = TREE_TYPE (expr);
    1105    213276975 :   if (!CLASS_TYPE_P (type) && TREE_CODE (type) != ARRAY_TYPE
    1106    422860214 :       && cv_qualified_p (type))
    1107     34799516 :     type = cv_unqualified (type);
    1108              : 
    1109              :   /* We need to do this for rvalue refs as well to get the right answer
    1110              :      from decltype; see c++/36628.  */
    1111    213276975 :   if (!processing_template_decl && glvalue_p (expr))
    1112              :     {
    1113              :       /* But don't use this function for class lvalues; use move (to treat an
    1114              :          lvalue as an xvalue) or force_rvalue (to make a prvalue copy).  */
    1115     11721274 :       gcc_checking_assert (!CLASS_TYPE_P (type));
    1116     11721274 :       expr = build1 (NON_LVALUE_EXPR, type, expr);
    1117              :     }
    1118    201555701 :   else if (type != TREE_TYPE (expr))
    1119     34553720 :     expr = build_nop (type, expr);
    1120              : 
    1121              :   return expr;
    1122              : }
    1123              : 
    1124              : 
    1125              : struct cplus_array_info
    1126              : {
    1127              :   tree type;
    1128              :   tree domain;
    1129              : };
    1130              : 
    1131              : struct cplus_array_hasher : ggc_ptr_hash<tree_node>
    1132              : {
    1133              :   typedef cplus_array_info *compare_type;
    1134              : 
    1135              :   static hashval_t hash (tree t);
    1136              :   static bool equal (tree, cplus_array_info *);
    1137              : };
    1138              : 
    1139              : /* Hash an ARRAY_TYPE.  K is really of type `tree'.  */
    1140              : 
    1141              : hashval_t
    1142     40138285 : cplus_array_hasher::hash (tree t)
    1143              : {
    1144     40138285 :   hashval_t hash;
    1145              : 
    1146     40138285 :   hash = TYPE_UID (TREE_TYPE (t));
    1147     40138285 :   if (TYPE_DOMAIN (t))
    1148     35347296 :     hash ^= TYPE_UID (TYPE_DOMAIN (t));
    1149     40138285 :   return hash;
    1150              : }
    1151              : 
    1152              : /* Compare two ARRAY_TYPEs.  K1 is really of type `tree', K2 is really
    1153              :    of type `cplus_array_info*'. */
    1154              : 
    1155              : bool
    1156     46937477 : cplus_array_hasher::equal (tree t1, cplus_array_info *t2)
    1157              : {
    1158     49787106 :   return (TREE_TYPE (t1) == t2->type && TYPE_DOMAIN (t1) == t2->domain);
    1159              : }
    1160              : 
    1161              : /* Hash table containing dependent array types, which are unsuitable for
    1162              :    the language-independent type hash table.  */
    1163              : static GTY (()) hash_table<cplus_array_hasher> *cplus_array_htab;
    1164              : 
    1165              : /* Build an ARRAY_TYPE without laying it out.  */
    1166              : 
    1167              : static tree
    1168      5323811 : build_min_array_type (tree elt_type, tree index_type)
    1169              : {
    1170      5323811 :   tree t = cxx_make_type (ARRAY_TYPE);
    1171      5323811 :   TREE_TYPE (t) = elt_type;
    1172      5323811 :   TYPE_DOMAIN (t) = index_type;
    1173      5323811 :   return t;
    1174              : }
    1175              : 
    1176              : /* Set TYPE_CANONICAL like build_array_type_1, but using
    1177              :    build_cplus_array_type.  */
    1178              : 
    1179              : static void
    1180      5323811 : set_array_type_canon (tree t, tree elt_type, tree index_type, bool dep)
    1181              : {
    1182              :   /* Set the canonical type for this new node.  */
    1183      5323811 :   if (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
    1184      5323811 :       || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type)))
    1185      1438791 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    1186      3885020 :   else if (TYPE_CANONICAL (elt_type) != elt_type
    1187      3885020 :            || (index_type && TYPE_CANONICAL (index_type) != index_type))
    1188      1163525 :     TYPE_CANONICAL (t)
    1189      3036545 :       = build_cplus_array_type (TYPE_CANONICAL (elt_type),
    1190              :                                 index_type
    1191       709495 :                                 ? TYPE_CANONICAL (index_type) : index_type,
    1192              :                                 dep);
    1193              :   else
    1194      2721495 :     TYPE_CANONICAL (t) = t;
    1195      5323811 : }
    1196              : 
    1197              : /* Like build_array_type, but handle special C++ semantics: an array of a
    1198              :    variant element type is a variant of the array of the main variant of
    1199              :    the element type.  IS_DEPENDENT is -ve if we should determine the
    1200              :    dependency.  Otherwise its bool value indicates dependency.  */
    1201              : 
    1202              : tree
    1203     63735856 : build_cplus_array_type (tree elt_type, tree index_type, int dependent)
    1204              : {
    1205     63735856 :   tree t;
    1206              : 
    1207     63735856 :   if (elt_type == error_mark_node || index_type == error_mark_node)
    1208              :     return error_mark_node;
    1209              : 
    1210     63735853 :   if (dependent < 0)
    1211     66610076 :     dependent = (uses_template_parms (elt_type)
    1212     33305038 :                  || (index_type && uses_template_parms (index_type)));
    1213              : 
    1214     63735853 :   if (elt_type != TYPE_MAIN_VARIANT (elt_type))
    1215              :     /* Start with an array of the TYPE_MAIN_VARIANT.  */
    1216     26833361 :     t = build_cplus_array_type (TYPE_MAIN_VARIANT (elt_type),
    1217              :                                 index_type, dependent);
    1218     36902492 :   else if (dependent)
    1219              :     {
    1220              :       /* Since type_hash_canon calls layout_type, we need to use our own
    1221              :          hash table.  */
    1222      4691178 :       cplus_array_info cai;
    1223      4691178 :       hashval_t hash;
    1224              : 
    1225      4691178 :       if (cplus_array_htab == NULL)
    1226        16677 :         cplus_array_htab = hash_table<cplus_array_hasher>::create_ggc (61);
    1227              : 
    1228      4691178 :       hash = TYPE_UID (elt_type);
    1229      4691178 :       if (index_type)
    1230      2419125 :         hash ^= TYPE_UID (index_type);
    1231      4691178 :       cai.type = elt_type;
    1232      4691178 :       cai.domain = index_type;
    1233              : 
    1234      4691178 :       tree *e = cplus_array_htab->find_slot_with_hash (&cai, hash, INSERT);
    1235      4691178 :       if (*e)
    1236              :         /* We have found the type: we're done.  */
    1237      2720682 :         return (tree) *e;
    1238              :       else
    1239              :         {
    1240              :           /* Build a new array type.  */
    1241      1970496 :           t = build_min_array_type (elt_type, index_type);
    1242              : 
    1243              :           /* Store it in the hash table. */
    1244      1970496 :           *e = t;
    1245              : 
    1246              :           /* Set the canonical type for this new node.  */
    1247      1970496 :           set_array_type_canon (t, elt_type, index_type, dependent);
    1248              : 
    1249              :           /* Mark it as dependent now, this saves time later.  */
    1250      1970496 :           TYPE_DEPENDENT_P_VALID (t) = true;
    1251      1970496 :           TYPE_DEPENDENT_P (t) = true;
    1252              :         }
    1253              :     }
    1254              :   else
    1255              :     {
    1256     32211314 :       bool typeless_storage = is_byte_access_type (elt_type);
    1257     32211314 :       t = build_array_type (elt_type, index_type, typeless_storage);
    1258              : 
    1259              :       /* Mark as non-dependenty now, this will save time later.  */
    1260     32211314 :       TYPE_DEPENDENT_P_VALID (t) = true;
    1261              :     }
    1262              : 
    1263              :   /* Now check whether we already have this array variant.  */
    1264     61015171 :   if (elt_type != TYPE_MAIN_VARIANT (elt_type))
    1265              :     {
    1266              :       tree m = t;
    1267     54845328 :       for (t = m; t; t = TYPE_NEXT_VARIANT (t))
    1268     51492013 :         if (TREE_TYPE (t) == elt_type
    1269     23494657 :             && TYPE_NAME (t) == NULL_TREE
    1270     23480049 :             && TYPE_ATTRIBUTES (t) == NULL_TREE
    1271     23480049 :             && (!TYPE_USER_ALIGN (t)
    1272        17859 :                 || (TYPE_USER_ALIGN (elt_type)
    1273        17856 :                     && TYPE_ALIGN (t) == TYPE_ALIGN (elt_type)))
    1274     23480046 :             && !TREE_DEPRECATED (t)
    1275     74972059 :             && !TREE_UNAVAILABLE (t))
    1276              :           break;
    1277     26833361 :       if (!t)
    1278              :         {
    1279      3353315 :           t = build_min_array_type (elt_type, index_type);
    1280              :           /* Mark dependency now, this saves time later.  */
    1281      3353315 :           TYPE_DEPENDENT_P_VALID (t) = true;
    1282      3353315 :           TYPE_DEPENDENT_P (t) = dependent;
    1283      3353315 :           set_array_type_canon (t, elt_type, index_type, dependent);
    1284      3353315 :           if (!dependent)
    1285              :             {
    1286      2727844 :               layout_type (t);
    1287              :               /* Make sure sizes are shared with the main variant.
    1288              :                  layout_type can't be called after setting TYPE_NEXT_VARIANT,
    1289              :                  as it will overwrite alignment etc. of all variants.  */
    1290      2727844 :               TYPE_SIZE (t) = TYPE_SIZE (m);
    1291      2727844 :               TYPE_SIZE_UNIT (t) = TYPE_SIZE_UNIT (m);
    1292      2727844 :               TYPE_TYPELESS_STORAGE (t) = TYPE_TYPELESS_STORAGE (m);
    1293              :             }
    1294              : 
    1295      3353315 :           TYPE_MAIN_VARIANT (t) = m;
    1296      3353315 :           TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
    1297      3353315 :           TYPE_NEXT_VARIANT (m) = t;
    1298              :         }
    1299              :     }
    1300              : 
    1301              :   /* Avoid spurious warnings with VLAs (c++/54583).  */
    1302     61015171 :   if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
    1303         2042 :     suppress_warning (TYPE_SIZE (t), OPT_Wunused);
    1304              : 
    1305              :   /* Push these needs up to the ARRAY_TYPE so that initialization takes
    1306              :      place more easily.  */
    1307    122030342 :   bool needs_ctor = (TYPE_NEEDS_CONSTRUCTING (t)
    1308     61015171 :                      = TYPE_NEEDS_CONSTRUCTING (elt_type));
    1309    122030342 :   bool needs_dtor = (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
    1310     61015171 :                      = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (elt_type));
    1311              : 
    1312     58278323 :   if (!dependent && t == TYPE_MAIN_VARIANT (t)
    1313     93226485 :       && !COMPLETE_TYPE_P (t) && COMPLETE_TYPE_P (elt_type))
    1314              :     {
    1315              :       /* The element type has been completed since the last time we saw
    1316              :          this array type; update the layout and 'tor flags for any variants
    1317              :          that need it.  */
    1318      2927829 :       layout_type (t);
    1319      4480452 :       for (tree v = TYPE_NEXT_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v))
    1320              :         {
    1321      1552623 :           TYPE_NEEDS_CONSTRUCTING (v) = needs_ctor;
    1322      1552623 :           TYPE_HAS_NONTRIVIAL_DESTRUCTOR (v) = needs_dtor;
    1323              :         }
    1324              :     }
    1325              : 
    1326              :   return t;
    1327              : }
    1328              : 
    1329              : /* Return an ARRAY_TYPE with element type ELT and length N.  */
    1330              : 
    1331              : tree
    1332      2217710 : build_array_of_n_type (tree elt, unsigned HOST_WIDE_INT n)
    1333              : {
    1334      2217710 :   return build_cplus_array_type (elt, build_index_type (size_int (n - 1)));
    1335              : }
    1336              : 
    1337              : /* True iff T is an array of unknown bound.  */
    1338              : 
    1339              : bool
    1340      8515672 : array_of_unknown_bound_p (const_tree t)
    1341              : {
    1342      8515672 :   return (TREE_CODE (t) == ARRAY_TYPE
    1343      8515672 :           && !TYPE_DOMAIN (t));
    1344              : }
    1345              : 
    1346              : /* True iff T is an N3639 array of runtime bound (VLA).  These were approved
    1347              :    for C++14 but then removed.  This should only be used for N3639
    1348              :    specifically; code wondering more generally if something is a VLA should use
    1349              :    vla_type_p.  */
    1350              : 
    1351              : bool
    1352       536367 : array_of_runtime_bound_p (tree t)
    1353              : {
    1354       536367 :   if (!t || TREE_CODE (t) != ARRAY_TYPE)
    1355              :     return false;
    1356          249 :   if (variably_modified_type_p (TREE_TYPE (t), NULL_TREE))
    1357              :     return false;
    1358          237 :   tree dom = TYPE_DOMAIN (t);
    1359          237 :   if (!dom)
    1360              :     return false;
    1361          234 :   tree max = TYPE_MAX_VALUE (dom);
    1362          234 :   return (!potential_rvalue_constant_expression (max)
    1363          234 :           || (!value_dependent_expression_p (max) && !TREE_CONSTANT (max)));
    1364              : }
    1365              : 
    1366              : /* True iff T is a variable length array.  */
    1367              : 
    1368              : bool
    1369     49590727 : vla_type_p (tree t)
    1370              : {
    1371     50463563 :   for (; t && TREE_CODE (t) == ARRAY_TYPE;
    1372       872836 :        t = TREE_TYPE (t))
    1373       873019 :     if (tree dom = TYPE_DOMAIN (t))
    1374              :       {
    1375       872955 :         tree max = TYPE_MAX_VALUE (dom);
    1376       872955 :         if (!potential_rvalue_constant_expression (max)
    1377       872955 :             || (!value_dependent_expression_p (max) && !TREE_CONSTANT (max)))
    1378          183 :           return true;
    1379              :       }
    1380              :   return false;
    1381              : }
    1382              : 
    1383              : 
    1384              : /* Return a reference type node of MODE referring to TO_TYPE.  If MODE
    1385              :    is VOIDmode the standard pointer mode will be picked.  If RVAL is
    1386              :    true, return an rvalue reference type, otherwise return an lvalue
    1387              :    reference type.  If a type node exists, reuse it, otherwise create
    1388              :    a new one.  */
    1389              : tree
    1390    733257597 : cp_build_reference_type_for_mode (tree to_type, machine_mode mode, bool rval)
    1391              : {
    1392    733257597 :   tree lvalue_ref, t;
    1393              : 
    1394    733257597 :   if (to_type == error_mark_node)
    1395              :     return error_mark_node;
    1396              : 
    1397    733257592 :   if (TYPE_REF_P (to_type))
    1398              :     {
    1399         1163 :       rval = rval && TYPE_REF_IS_RVALUE (to_type);
    1400         1163 :       to_type = TREE_TYPE (to_type);
    1401              :     }
    1402              : 
    1403    733257592 :   lvalue_ref = build_reference_type_for_mode (to_type, mode, false);
    1404              : 
    1405    733257592 :   if (!rval)
    1406              :     return lvalue_ref;
    1407              : 
    1408              :   /* This code to create rvalue reference types is based on and tied
    1409              :      to the code creating lvalue reference types in the middle-end
    1410              :      functions build_reference_type_for_mode and build_reference_type.
    1411              : 
    1412              :      It works by putting the rvalue reference type nodes after the
    1413              :      lvalue reference nodes in the TYPE_NEXT_REF_TO linked list, so
    1414              :      they will effectively be ignored by the middle end.  */
    1415              : 
    1416    113368808 :   for (t = lvalue_ref; (t = TYPE_NEXT_REF_TO (t)); )
    1417     84767974 :     if (TYPE_REF_IS_RVALUE (t))
    1418              :       return t;
    1419              : 
    1420     28600834 :   t = build_distinct_type_copy (lvalue_ref);
    1421              : 
    1422     28600834 :   TYPE_REF_IS_RVALUE (t) = true;
    1423     28600834 :   TYPE_NEXT_REF_TO (t) = TYPE_NEXT_REF_TO (lvalue_ref);
    1424     28600834 :   TYPE_NEXT_REF_TO (lvalue_ref) = t;
    1425              : 
    1426     28600834 :   if (TYPE_STRUCTURAL_EQUALITY_P (to_type))
    1427       946184 :     SET_TYPE_STRUCTURAL_EQUALITY (t);
    1428     27654650 :   else if (TYPE_CANONICAL (to_type) != to_type)
    1429     15042751 :     TYPE_CANONICAL (t)
    1430     30085502 :       = cp_build_reference_type_for_mode (TYPE_CANONICAL (to_type), mode, rval);
    1431              :   else
    1432     12611899 :     TYPE_CANONICAL (t) = t;
    1433              : 
    1434     28600834 :   layout_type (t);
    1435              : 
    1436     28600834 :   return t;
    1437              : 
    1438              : }
    1439              : 
    1440              : /* Return a reference type node referring to TO_TYPE.  If RVAL is
    1441              :    true, return an rvalue reference type, otherwise return an lvalue
    1442              :    reference type.  If a type node exists, reuse it, otherwise create
    1443              :    a new one.  */
    1444              : tree
    1445    599698223 : cp_build_reference_type (tree to_type, bool rval)
    1446              : {
    1447    599698223 :   return cp_build_reference_type_for_mode (to_type, VOIDmode, rval);
    1448              : }
    1449              : 
    1450              : /* Returns EXPR cast to rvalue reference type, like std::move.  */
    1451              : 
    1452              : tree
    1453      2251388 : move (tree expr)
    1454              : {
    1455      2251388 :   tree type = TREE_TYPE (expr);
    1456      2251388 :   gcc_assert (!TYPE_REF_P (type));
    1457      2251388 :   if (xvalue_p (expr))
    1458              :     return expr;
    1459      2251131 :   type = cp_build_reference_type (type, /*rval*/true);
    1460      2251131 :   return build_static_cast (input_location, type, expr,
    1461      2251131 :                             tf_warning_or_error);
    1462              : }
    1463              : 
    1464              : /* Used by the C++ front end to build qualified array types.  However,
    1465              :    the C version of this function does not properly maintain canonical
    1466              :    types (which are not used in C).  */
    1467              : tree
    1468     25562660 : c_build_qualified_type (tree type, int type_quals, tree /* orig_qual_type */,
    1469              :                         size_t /* orig_qual_indirect */)
    1470              : {
    1471     25562660 :   return cp_build_qualified_type (type, type_quals);
    1472              : }
    1473              : 
    1474              : 
    1475              : /* Make a variant of TYPE, qualified with the TYPE_QUALS.  Handles
    1476              :    arrays correctly.  In particular, if TYPE is an array of T's, and
    1477              :    TYPE_QUALS is non-empty, returns an array of qualified T's.
    1478              : 
    1479              :    FLAGS determines how to deal with ill-formed qualifications. If
    1480              :    tf_ignore_bad_quals is set, then bad qualifications are dropped
    1481              :    (this is permitted if TYPE was introduced via a typedef or template
    1482              :    type parameter). If bad qualifications are dropped and tf_warning
    1483              :    is set, then a warning is issued for non-const qualifications.  If
    1484              :    tf_ignore_bad_quals is not set and tf_error is not set, we
    1485              :    return error_mark_node. Otherwise, we issue an error, and ignore
    1486              :    the qualifications.
    1487              : 
    1488              :    Qualification of a reference type is valid when the reference came
    1489              :    via a typedef or template type argument. [dcl.ref] No such
    1490              :    dispensation is provided for qualifying a function type.  [dcl.fct]
    1491              :    DR 295 queries this and the proposed resolution brings it into line
    1492              :    with qualifying a reference.  We implement the DR.  We also behave
    1493              :    in a similar manner for restricting non-pointer types.  */
    1494              : 
    1495              : tree
    1496  21547271806 : cp_build_qualified_type (tree type, int type_quals,
    1497              :                          tsubst_flags_t complain /* = tf_warning_or_error */)
    1498              : {
    1499  21547271806 :   tree result;
    1500  21547271806 :   int bad_quals = TYPE_UNQUALIFIED;
    1501              : 
    1502  21547271806 :   if (type == error_mark_node)
    1503              :     return type;
    1504              : 
    1505  21490744076 :   if (type_quals == cp_type_quals (type))
    1506              :     return type;
    1507              : 
    1508   4239973469 :   if (TREE_CODE (type) == ARRAY_TYPE)
    1509              :     {
    1510              :       /* In C++, the qualification really applies to the array element
    1511              :          type.  Obtain the appropriately qualified element type.  */
    1512     31955246 :       tree t;
    1513     31955246 :       tree element_type
    1514     31955246 :         = cp_build_qualified_type (TREE_TYPE (type), type_quals, complain);
    1515              : 
    1516     31955246 :       if (element_type == error_mark_node)
    1517              :         return error_mark_node;
    1518              : 
    1519              :       /* See if we already have an identically qualified type.  Tests
    1520              :          should be equivalent to those in check_qualified_type.  */
    1521     60203306 :       for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
    1522     35883956 :         if (TREE_TYPE (t) == element_type
    1523      8164380 :             && TYPE_NAME (t) == TYPE_NAME (type)
    1524      7635896 :             && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
    1525     43519852 :             && attribute_list_equal (TYPE_ATTRIBUTES (t),
    1526      7635896 :                                      TYPE_ATTRIBUTES (type)))
    1527              :           break;
    1528              : 
    1529     31955246 :       if (!t)
    1530              :         {
    1531              :           /* If we already know the dependentness, tell the array type
    1532              :              constructor.  This is important for module streaming, as we cannot
    1533              :              dynamically determine that on read in.  */
    1534     24319350 :           t = build_cplus_array_type (element_type, TYPE_DOMAIN (type),
    1535     24319350 :                                       TYPE_DEPENDENT_P_VALID (type)
    1536       554597 :                                       ? int (TYPE_DEPENDENT_P (type)) : -1);
    1537              : 
    1538              :           /* Keep the typedef name.  */
    1539     24319350 :           if (TYPE_NAME (t) != TYPE_NAME (type))
    1540              :             {
    1541        29235 :               t = build_variant_type_copy (t);
    1542        29235 :               TYPE_NAME (t) = TYPE_NAME (type);
    1543        29235 :               SET_TYPE_ALIGN (t, TYPE_ALIGN (type));
    1544        29235 :               TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (type);
    1545              :             }
    1546              :         }
    1547              : 
    1548              :       /* Even if we already had this variant, we update
    1549              :          TYPE_NEEDS_CONSTRUCTING and TYPE_HAS_NONTRIVIAL_DESTRUCTOR in case
    1550              :          they changed since the variant was originally created.
    1551              : 
    1552              :          This seems hokey; if there is some way to use a previous
    1553              :          variant *without* coming through here,
    1554              :          TYPE_NEEDS_CONSTRUCTING will never be updated.  */
    1555     63910492 :       TYPE_NEEDS_CONSTRUCTING (t)
    1556     31955246 :         = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (element_type));
    1557     63910492 :       TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
    1558     31955246 :         = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (element_type));
    1559     31955246 :       return t;
    1560              :     }
    1561   4208018223 :   else if (TREE_CODE (type) == TYPE_PACK_EXPANSION)
    1562              :     {
    1563            3 :       tree t = PACK_EXPANSION_PATTERN (type);
    1564              : 
    1565            3 :       t = cp_build_qualified_type (t, type_quals, complain);
    1566            3 :       return make_pack_expansion (t, complain);
    1567              :     }
    1568              : 
    1569              :   /* A reference or method type shall not be cv-qualified.
    1570              :      [dcl.ref], [dcl.fct].  This used to be an error, but as of DR 295
    1571              :      (in CD1) we always ignore extra cv-quals on functions.  */
    1572              : 
    1573              :   /* [dcl.ref/1] Cv-qualified references are ill-formed except when
    1574              :      the cv-qualifiers are introduced through the use of a typedef-name
    1575              :      ([dcl.typedef], [temp.param]) or decltype-specifier
    1576              :      ([dcl.type.decltype]),in which case the cv-qualifiers are
    1577              :      ignored.  */
    1578   4208018220 :   if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
    1579   1182827906 :       && (TYPE_REF_P (type)
    1580   1182326268 :           || FUNC_OR_METHOD_TYPE_P (type)))
    1581              :     {
    1582       502398 :       if (TYPE_REF_P (type)
    1583       502398 :           && (!typedef_variant_p (type) || FUNC_OR_METHOD_TYPE_P (type)))
    1584              :         bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
    1585       502398 :       type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
    1586              :     }
    1587              : 
    1588              :   /* But preserve any function-cv-quals on a FUNCTION_TYPE.  */
    1589   4208018220 :   if (TREE_CODE (type) == FUNCTION_TYPE)
    1590          763 :     type_quals |= type_memfn_quals (type);
    1591              : 
    1592              :   /* A restrict-qualified type must be a pointer (or reference)
    1593              :      to object or incomplete type. */
    1594   4208018220 :   if ((type_quals & TYPE_QUAL_RESTRICT)
    1595      8284643 :       && TREE_CODE (type) != TEMPLATE_TYPE_PARM
    1596      8284606 :       && TREE_CODE (type) != TYPENAME_TYPE
    1597      8284600 :       && !INDIRECT_TYPE_P (type))
    1598              :     {
    1599           25 :       bad_quals |= TYPE_QUAL_RESTRICT;
    1600           25 :       type_quals &= ~TYPE_QUAL_RESTRICT;
    1601              :     }
    1602              : 
    1603   4208018220 :   if (bad_quals == TYPE_UNQUALIFIED
    1604       366753 :       || (complain & tf_ignore_bad_quals))
    1605              :     /*OK*/;
    1606           12 :   else if (!(complain & tf_error))
    1607            0 :     return error_mark_node;
    1608              :   else
    1609              :     {
    1610           12 :       tree bad_type = build_qualified_type (ptr_type_node, bad_quals);
    1611           12 :       error ("%qV qualifiers cannot be applied to %qT",
    1612              :              bad_type, type);
    1613              :     }
    1614              : 
    1615              :   /* Retrieve (or create) the appropriately qualified variant.  */
    1616   4208018220 :   result = build_qualified_type (type, type_quals);
    1617              : 
    1618   4208018220 :   return result;
    1619              : }
    1620              : 
    1621              : /* Return a FUNCTION_TYPE for a function returning VALUE_TYPE
    1622              :    with ARG_TYPES arguments.  Wrapper around build_function_type
    1623              :    which ensures TYPE_NO_NAMED_ARGS_STDARG_P is set if ARG_TYPES
    1624              :    is NULL for C++26.  */
    1625              : 
    1626              : tree
    1627    266647567 : cp_build_function_type (tree value_type, tree arg_types)
    1628              : {
    1629    266647567 :   return build_function_type (value_type, arg_types,
    1630    266647567 :                               cxx_dialect >= cxx26
    1631    266647567 :                               && arg_types == NULL_TREE);
    1632              : }
    1633              : 
    1634              : /* Return TYPE with const and volatile removed.  */
    1635              : 
    1636              : tree
    1637   1862667670 : cv_unqualified (tree type)
    1638              : {
    1639   1862667670 :   int quals;
    1640              : 
    1641   1862667670 :   if (type == error_mark_node)
    1642              :     return type;
    1643              : 
    1644   1862667471 :   quals = cp_type_quals (type);
    1645   1862667471 :   quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE);
    1646   1862667471 :   return cp_build_qualified_type (type, quals);
    1647              : }
    1648              : 
    1649              : /* Subroutine of strip_typedefs.  We want to apply to RESULT the attributes
    1650              :    from ATTRIBS that affect type identity, and no others.  If any are not
    1651              :    applied, set *remove_attributes to true.  */
    1652              : 
    1653              : static tree
    1654      8546848 : apply_identity_attributes (tree result, tree attribs, bool *remove_attributes)
    1655              : {
    1656      8546848 :   tree first_ident = NULL_TREE;
    1657      8546848 :   tree new_attribs = NULL_TREE;
    1658      8546848 :   tree *p = &new_attribs;
    1659              : 
    1660      8546848 :   if (OVERLOAD_TYPE_P (result))
    1661              :     {
    1662              :       /* On classes and enums all attributes are ingrained.  */
    1663      8545933 :       gcc_assert (attribs == TYPE_ATTRIBUTES (result));
    1664              :       return result;
    1665              :     }
    1666              : 
    1667         1833 :   for (tree a = attribs; a; a = TREE_CHAIN (a))
    1668              :     {
    1669          918 :       const attribute_spec *as
    1670          918 :         = lookup_attribute_spec (get_attribute_name (a));
    1671          918 :       if (as && as->affects_type_identity)
    1672              :         {
    1673          178 :           if (!first_ident)
    1674              :             first_ident = a;
    1675            0 :           else if (first_ident == error_mark_node)
    1676              :             {
    1677            0 :               *p = tree_cons (TREE_PURPOSE (a), TREE_VALUE (a), NULL_TREE);
    1678            0 :               p = &TREE_CHAIN (*p);
    1679              :             }
    1680              :         }
    1681          740 :       else if (first_ident && first_ident != error_mark_node)
    1682              :         {
    1683            0 :           for (tree a2 = first_ident; a2 != a; a2 = TREE_CHAIN (a2))
    1684              :             {
    1685            0 :               *p = tree_cons (TREE_PURPOSE (a2), TREE_VALUE (a2), NULL_TREE);
    1686            0 :               p = &TREE_CHAIN (*p);
    1687              :             }
    1688            0 :           first_ident = error_mark_node;
    1689              :         }
    1690              :     }
    1691          915 :   if (first_ident != error_mark_node)
    1692          915 :     new_attribs = first_ident;
    1693              : 
    1694          915 :   if (first_ident == attribs)
    1695              :     /* All attributes affected type identity.  */;
    1696              :   else
    1697          737 :     *remove_attributes = true;
    1698              : 
    1699          915 :   return cp_build_type_attribute_variant (result, new_attribs);
    1700              : }
    1701              : 
    1702              : /* Builds a qualified variant of T that is either not a typedef variant
    1703              :    (the default behavior) or not a typedef variant of a user-facing type
    1704              :    (if FLAGS contains STF_USER_VISIBLE).  If T is not a type, then this
    1705              :    just dispatches to strip_typedefs_expr.
    1706              : 
    1707              :    E.g. consider the following declarations:
    1708              :      typedef const int ConstInt;
    1709              :      typedef ConstInt* PtrConstInt;
    1710              :    If T is PtrConstInt, this function returns a type representing
    1711              :      const int*.
    1712              :    In other words, if T is a typedef, the function returns the underlying type.
    1713              :    The cv-qualification and attributes of the type returned match the
    1714              :    input type.
    1715              :    They will always be compatible types.
    1716              :    The returned type is built so that all of its subtypes
    1717              :    recursively have their typedefs stripped as well.
    1718              : 
    1719              :    This is different from just returning TYPE_CANONICAL (T)
    1720              :    Because of several reasons:
    1721              :     * If T is a type that needs structural equality
    1722              :       its TYPE_CANONICAL (T) will be NULL.
    1723              :     * TYPE_CANONICAL (T) desn't carry type attributes
    1724              :       and loses template parameter names.
    1725              : 
    1726              :    If REMOVE_ATTRIBUTES is non-null, also strip attributes that don't
    1727              :    affect type identity, and set the referent to true if any were
    1728              :    stripped.  */
    1729              : 
    1730              : tree
    1731   3161311308 : strip_typedefs (tree t, bool *remove_attributes /* = NULL */,
    1732              :                 unsigned int flags /* = 0 */)
    1733              : {
    1734   3161311308 :   tree result = NULL, type = NULL, t0 = NULL;
    1735              : 
    1736   3161311308 :   if (!t || t == error_mark_node)
    1737              :     return t;
    1738              : 
    1739   3126495364 :   if (!TYPE_P (t))
    1740    171367510 :     return strip_typedefs_expr (t, remove_attributes, flags);
    1741              : 
    1742   2955127854 :   if (t == TYPE_CANONICAL (t))
    1743              :     return t;
    1744              : 
    1745   1140528605 :   if (typedef_variant_p (t))
    1746              :     {
    1747    434288970 :       if ((flags & STF_USER_VISIBLE)
    1748    434288970 :           && !user_facing_original_type_p (t))
    1749              :         return t;
    1750              : 
    1751    434288852 :       if ((flags & STF_KEEP_INJ_CLASS_NAME)
    1752        31950 :           && CLASS_TYPE_P (t)
    1753    434298196 :           && DECL_SELF_REFERENCE_P (TYPE_NAME (t)))
    1754              :         return t;
    1755              : 
    1756    434288851 :       if (dependent_opaque_alias_p (t))
    1757              :         return t;
    1758              : 
    1759    434288452 :       if (alias_template_specialization_p (t, nt_opaque))
    1760              :         {
    1761    116389916 :           if (dependent_alias_template_spec_p (t, nt_opaque)
    1762    116389916 :               && !(flags & STF_STRIP_DEPENDENT))
    1763              :             /* DR 1558: However, if the template-id is dependent, subsequent
    1764              :                template argument substitution still applies to the template-id.  */
    1765              :             return t;
    1766              :         }
    1767              :       else
    1768              :         /* If T is a non-template alias or typedef, we can assume that
    1769              :            instantiating its definition will hit any substitution failure,
    1770              :            so we don't need to retain it here as well.  */
    1771    317898536 :         flags |= STF_STRIP_DEPENDENT;
    1772              : 
    1773    420623737 :       result = strip_typedefs (DECL_ORIGINAL_TYPE (TYPE_NAME (t)),
    1774              :                                remove_attributes, flags);
    1775    420623737 :       goto stripped;
    1776              :     }
    1777              : 
    1778    706239635 :   switch (TREE_CODE (t))
    1779              :     {
    1780     10846479 :     case POINTER_TYPE:
    1781     10846479 :       type = strip_typedefs (TREE_TYPE (t), remove_attributes, flags);
    1782     10846479 :       result = build_pointer_type_for_mode (type, TYPE_MODE (t), false);
    1783     10846479 :       break;
    1784    118516623 :     case REFERENCE_TYPE:
    1785    118516623 :       type = strip_typedefs (TREE_TYPE (t), remove_attributes, flags);
    1786    118516623 :       result = cp_build_reference_type_for_mode (type, TYPE_MODE (t), TYPE_REF_IS_RVALUE (t));
    1787    118516623 :       break;
    1788       307594 :     case OFFSET_TYPE:
    1789       307594 :       t0 = strip_typedefs (TYPE_OFFSET_BASETYPE (t), remove_attributes, flags);
    1790       307594 :       type = strip_typedefs (TREE_TYPE (t), remove_attributes, flags);
    1791       307594 :       result = build_offset_type (t0, type);
    1792       307594 :       break;
    1793     24438792 :     case RECORD_TYPE:
    1794     24438792 :       if (TYPE_PTRMEMFUNC_P (t))
    1795              :         {
    1796      1509914 :           t0 = strip_typedefs (TYPE_PTRMEMFUNC_FN_TYPE (t),
    1797              :                                remove_attributes, flags);
    1798      1509914 :           result = build_ptrmemfunc_type (t0);
    1799              :         }
    1800              :       break;
    1801      1859107 :     case ARRAY_TYPE:
    1802      1859107 :       type = strip_typedefs (TREE_TYPE (t), remove_attributes, flags);
    1803      1859107 :       t0  = strip_typedefs (TYPE_DOMAIN (t), remove_attributes, flags);
    1804      1859107 :       gcc_checking_assert (TYPE_DEPENDENT_P_VALID (t)
    1805              :                            || !dependent_type_p (t));
    1806      1859107 :       result = build_cplus_array_type (type, t0, TYPE_DEPENDENT_P (t));
    1807      1859107 :       break;
    1808      8411905 :     case FUNCTION_TYPE:
    1809      8411905 :     case METHOD_TYPE:
    1810      8411905 :       {
    1811      8411905 :         tree arg_types = NULL, arg_node, arg_node2, arg_type;
    1812      8411905 :         bool changed;
    1813              : 
    1814              :         /* Because we stomp on TREE_PURPOSE of TYPE_ARG_TYPES in many places
    1815              :            around the compiler (e.g. cp_parser_late_parsing_default_args), we
    1816              :            can't expect that re-hashing a function type will find a previous
    1817              :            equivalent type, so try to reuse the input type if nothing has
    1818              :            changed.  If the type is itself a variant, that will change.  */
    1819      8411905 :         bool is_variant = typedef_variant_p (t);
    1820      8411905 :         if (remove_attributes
    1821      8411905 :             && (TYPE_ATTRIBUTES (t) || TYPE_USER_ALIGN (t)))
    1822              :           is_variant = true;
    1823              : 
    1824      8411905 :         type = strip_typedefs (TREE_TYPE (t), remove_attributes, flags);
    1825      8411905 :         tree canon_spec = (flag_noexcept_type
    1826      8401457 :                            ? canonical_eh_spec (TYPE_RAISES_EXCEPTIONS (t))
    1827      8411905 :                            : NULL_TREE);
    1828     10866572 :         changed = (type != TREE_TYPE (t) || is_variant
    1829     10866369 :                    || TYPE_RAISES_EXCEPTIONS (t) != canon_spec);
    1830              : 
    1831      8411905 :         for (arg_node = TYPE_ARG_TYPES (t);
    1832     12553953 :              arg_node;
    1833      4142048 :              arg_node = TREE_CHAIN (arg_node))
    1834              :           {
    1835     11782804 :             if (arg_node == void_list_node)
    1836              :               break;
    1837      4142048 :             arg_type = strip_typedefs (TREE_VALUE (arg_node),
    1838              :                                        remove_attributes, flags);
    1839      4142048 :             gcc_assert (arg_type);
    1840      4142048 :             if (arg_type == TREE_VALUE (arg_node) && !changed)
    1841      3892765 :               continue;
    1842              : 
    1843       249283 :             if (!changed)
    1844              :               {
    1845        37885 :                 changed = true;
    1846        37885 :                 for (arg_node2 = TYPE_ARG_TYPES (t);
    1847        47954 :                      arg_node2 != arg_node;
    1848        10069 :                      arg_node2 = TREE_CHAIN (arg_node2))
    1849        10069 :                   arg_types
    1850        10069 :                     = tree_cons (TREE_PURPOSE (arg_node2),
    1851        10069 :                                  TREE_VALUE (arg_node2), arg_types);
    1852              :               }
    1853              : 
    1854       249283 :             arg_types
    1855       249283 :               = tree_cons (TREE_PURPOSE (arg_node), arg_type, arg_types);
    1856              :           }
    1857              : 
    1858      8411905 :         if (!changed)
    1859              :           return t;
    1860              : 
    1861      5996198 :         if (arg_types)
    1862        58296 :           arg_types = nreverse (arg_types);
    1863              : 
    1864              :         /* A list of parameters not ending with an ellipsis
    1865              :            must end with void_list_node.  */
    1866      5996198 :         if (arg_node)
    1867      5996157 :           arg_types = chainon (arg_types, void_list_node);
    1868              : 
    1869      5996198 :         if (TREE_CODE (t) == METHOD_TYPE)
    1870              :           {
    1871        27276 :             tree class_type = TREE_TYPE (TREE_VALUE (arg_types));
    1872        27276 :             gcc_assert (class_type);
    1873        27276 :             result =
    1874        27276 :               build_method_type_directly (class_type, type,
    1875        27276 :                                           TREE_CHAIN (arg_types));
    1876              :           }
    1877              :         else
    1878              :           {
    1879     17906766 :             result = build_function_type (type, arg_types,
    1880      5968922 :                                           TYPE_NO_NAMED_ARGS_STDARG_P (t));
    1881      5968922 :             result = apply_memfn_quals (result, type_memfn_quals (t));
    1882              :           }
    1883              : 
    1884     17988594 :         result = build_cp_fntype_variant (result,
    1885              :                                           type_memfn_rqual (t), canon_spec,
    1886      5996198 :                                           TYPE_HAS_LATE_RETURN_TYPE (t));
    1887              :       }
    1888      5996198 :       break;
    1889     71516346 :     case TYPENAME_TYPE:
    1890     71516346 :       {
    1891     71516346 :         bool changed = false;
    1892     71516346 :         tree fullname = TYPENAME_TYPE_FULLNAME (t);
    1893     71516346 :         if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR
    1894     71516346 :             && TREE_OPERAND (fullname, 1))
    1895              :           {
    1896      4237079 :             tree args = TREE_OPERAND (fullname, 1);
    1897      4237079 :             tree new_args = copy_node (args);
    1898     11713588 :             for (int i = 0; i < TREE_VEC_LENGTH (args); ++i)
    1899              :               {
    1900      7476509 :                 tree arg = TREE_VEC_ELT (args, i);
    1901      7476509 :                 tree strip_arg = strip_typedefs (arg, remove_attributes, flags);
    1902      7476509 :                 TREE_VEC_ELT (new_args, i) = strip_arg;
    1903      7476509 :                 if (strip_arg != arg)
    1904       239479 :                   changed = true;
    1905              :               }
    1906      4237079 :             if (changed)
    1907              :               {
    1908       239479 :                 NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_args)
    1909       239479 :                   = NON_DEFAULT_TEMPLATE_ARGS_COUNT (args);
    1910       239479 :                 fullname
    1911       239479 :                   = lookup_template_function (TREE_OPERAND (fullname, 0),
    1912              :                                               new_args);
    1913              :               }
    1914              :             else
    1915      3997600 :               ggc_free (new_args);
    1916              :           }
    1917     71516346 :         tree ctx = strip_typedefs (TYPE_CONTEXT (t), remove_attributes, flags);
    1918     71516346 :         if (!changed && ctx == TYPE_CONTEXT (t) && !typedef_variant_p (t))
    1919              :           return t;
    1920      4533199 :         tree name = fullname;
    1921      4533199 :         if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR)
    1922       262475 :           name = TREE_OPERAND (fullname, 0);
    1923              :         /* Use build_typename_type rather than make_typename_type because we
    1924              :            don't want to resolve it here, just strip typedefs.  */
    1925      4533199 :         result = build_typename_type (ctx, name, fullname, typename_type);
    1926              :       }
    1927      4533199 :       break;
    1928     11934597 :     case DECLTYPE_TYPE:
    1929     11934597 :       result = strip_typedefs_expr (DECLTYPE_TYPE_EXPR (t),
    1930              :                                     remove_attributes, flags);
    1931     11934597 :       if (result == DECLTYPE_TYPE_EXPR (t))
    1932              :         result = NULL_TREE;
    1933              :       else
    1934       348609 :         result = (finish_decltype_type
    1935       348609 :                   (result,
    1936       348609 :                    DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (t),
    1937              :                    tf_none));
    1938              :       break;
    1939       775897 :     case TRAIT_TYPE:
    1940       775897 :       {
    1941       775897 :         tree type1 = strip_typedefs (TRAIT_TYPE_TYPE1 (t),
    1942              :                                      remove_attributes, flags);
    1943       775897 :         tree type2 = strip_typedefs (TRAIT_TYPE_TYPE2 (t),
    1944              :                                      remove_attributes, flags);
    1945       775897 :         if (type1 == TRAIT_TYPE_TYPE1 (t) && type2 == TRAIT_TYPE_TYPE2 (t))
    1946              :           result = NULL_TREE;
    1947              :         else
    1948            0 :           result = finish_trait_type (TRAIT_TYPE_KIND (t), type1, type2,
    1949              :                                       tf_warning_or_error);
    1950              :       }
    1951              :       break;
    1952     24646268 :     case TYPE_PACK_EXPANSION:
    1953     24646268 :       {
    1954     24646268 :         tree pat = PACK_EXPANSION_PATTERN (t);
    1955     24646268 :         if (TYPE_P (pat))
    1956              :           {
    1957     24646268 :             type = strip_typedefs (pat, remove_attributes, flags);
    1958     24646268 :             if (type != pat)
    1959              :               {
    1960       280591 :                 result = build_distinct_type_copy (t);
    1961       280591 :                 PACK_EXPANSION_PATTERN (result) = type;
    1962              :               }
    1963              :           }
    1964              :       }
    1965              :       break;
    1966              :     default:
    1967              :       break;
    1968              :     }
    1969              : 
    1970    144198314 :   if (!result)
    1971    492642467 :     result = TYPE_MAIN_VARIANT (t);
    1972              : 
    1973    144198314 : stripped:
    1974              :   /*gcc_assert (!typedef_variant_p (result)
    1975              :               || dependent_alias_template_spec_p (result, nt_opaque)
    1976              :               || ((flags & STF_USER_VISIBLE)
    1977              :                   && !user_facing_original_type_p (result)));*/
    1978              : 
    1979   1057464518 :   if (COMPLETE_TYPE_P (result) && !COMPLETE_TYPE_P (t))
    1980              :   /* If RESULT is complete and T isn't, it's likely the case that T
    1981              :      is a variant of RESULT which hasn't been updated yet.  Skip the
    1982              :      attribute handling.  */;
    1983              :   else
    1984              :     {
    1985   1057464512 :       if (TYPE_USER_ALIGN (t) != TYPE_USER_ALIGN (result)
    1986   1057464512 :           || TYPE_ALIGN (t) != TYPE_ALIGN (result))
    1987              :         {
    1988           21 :           gcc_assert (TYPE_USER_ALIGN (t));
    1989           21 :           if (remove_attributes)
    1990           12 :             *remove_attributes = true;
    1991              :           else
    1992              :             {
    1993            9 :               if (TYPE_ALIGN (t) == TYPE_ALIGN (result))
    1994            0 :                 result = build_variant_type_copy (result);
    1995              :               else
    1996            9 :                 result = build_aligned_type (result, TYPE_ALIGN (t));
    1997            9 :               TYPE_USER_ALIGN (result) = true;
    1998              :             }
    1999              :         }
    2000              : 
    2001   1057464512 :       if (TYPE_ATTRIBUTES (t))
    2002              :         {
    2003      8556572 :           if (remove_attributes)
    2004      8546848 :             result = apply_identity_attributes (result, TYPE_ATTRIBUTES (t),
    2005              :                                                 remove_attributes);
    2006              :           else
    2007         9724 :             result = cp_build_type_attribute_variant (result,
    2008         9724 :                                                       TYPE_ATTRIBUTES (t));
    2009              :         }
    2010              :     }
    2011              : 
    2012   1057464518 :   return cp_build_qualified_type (result, cp_type_quals (t));
    2013              : }
    2014              : 
    2015              : /* Like strip_typedefs above, but works on expressions (and other
    2016              :    non-types such as TREE_VEC), so that in
    2017              : 
    2018              :    template<class T> struct A
    2019              :    {
    2020              :      typedef T TT;
    2021              :      B<sizeof(TT)> b;
    2022              :    };
    2023              : 
    2024              :    sizeof(TT) is replaced by sizeof(T).  */
    2025              : 
    2026              : tree
    2027    371190316 : strip_typedefs_expr (tree t, bool *remove_attributes, unsigned int flags)
    2028              : {
    2029    371190316 :   unsigned i,n;
    2030    371190316 :   tree r, type, *ops;
    2031    371190316 :   enum tree_code code;
    2032              : 
    2033    371190316 :   if (t == NULL_TREE || t == error_mark_node)
    2034              :     return t;
    2035              : 
    2036    371190316 :   STRIP_ANY_LOCATION_WRAPPER (t);
    2037              : 
    2038    371190316 :   if (DECL_P (t) || CONSTANT_CLASS_P (t))
    2039              :     return t;
    2040              : 
    2041    184089097 :   code = TREE_CODE (t);
    2042    184089097 :   switch (code)
    2043              :     {
    2044              :     case IDENTIFIER_NODE:
    2045              :     case TEMPLATE_PARM_INDEX:
    2046              :     case OVERLOAD:
    2047              :     case BASELINK:
    2048              :     case ARGUMENT_PACK_SELECT:
    2049              :       return t;
    2050              : 
    2051      2199145 :     case TRAIT_EXPR:
    2052      2199145 :       {
    2053      2199145 :         tree type1 = strip_typedefs (TRAIT_EXPR_TYPE1 (t),
    2054              :                                      remove_attributes, flags);
    2055      2199145 :         tree type2 = strip_typedefs (TRAIT_EXPR_TYPE2 (t),
    2056              :                                      remove_attributes, flags);
    2057      2199145 :         if (type1 == TRAIT_EXPR_TYPE1 (t)
    2058      2199145 :             && type2 == TRAIT_EXPR_TYPE2 (t))
    2059              :           return t;
    2060        49683 :         r = copy_node (t);
    2061        49683 :         TRAIT_EXPR_TYPE1 (r) = type1;
    2062        49683 :         TRAIT_EXPR_TYPE2 (r) = type2;
    2063        49683 :         return r;
    2064              :       }
    2065              : 
    2066      1005828 :     case TREE_LIST:
    2067      1005828 :       {
    2068      1005828 :         bool changed = false;
    2069      1005828 :         auto_vec<tree_pair, 4> vec;
    2070      1005828 :         r = t;
    2071      2142292 :         for (; t; t = TREE_CHAIN (t))
    2072              :           {
    2073      1136464 :             tree purpose = strip_typedefs (TREE_PURPOSE (t),
    2074      1136464 :                                            remove_attributes, flags);
    2075      1136464 :             tree value = strip_typedefs (TREE_VALUE (t),
    2076      1136464 :                                          remove_attributes, flags);
    2077      1136464 :             if (purpose != TREE_PURPOSE (t) || value != TREE_VALUE (t))
    2078              :               changed = true;
    2079      1136464 :             vec.safe_push ({purpose, value});
    2080              :           }
    2081      1005828 :         if (changed)
    2082              :           {
    2083       223643 :             r = NULL_TREE;
    2084       732634 :             for (int i = vec.length () - 1; i >= 0; i--)
    2085       285348 :               r = tree_cons (vec[i].first, vec[i].second, r);
    2086              :           }
    2087      1005828 :         return r;
    2088      1005828 :       }
    2089              : 
    2090     18574363 :     case TREE_VEC:
    2091     18574363 :       {
    2092     18574363 :         bool changed = false;
    2093     18574363 :         releasing_vec vec;
    2094     18574363 :         n = TREE_VEC_LENGTH (t);
    2095     18574363 :         vec_safe_reserve (vec, n);
    2096     39731699 :         for (i = 0; i < n; ++i)
    2097              :           {
    2098     21157336 :             tree op = strip_typedefs (TREE_VEC_ELT (t, i),
    2099     21157336 :                                       remove_attributes, flags);
    2100     21157336 :             vec->quick_push (op);
    2101     21157336 :             if (op != TREE_VEC_ELT (t, i))
    2102       202486 :               changed = true;
    2103              :           }
    2104     18574363 :         if (changed)
    2105              :           {
    2106       202486 :             r = copy_node (t);
    2107       626141 :             for (i = 0; i < n; ++i)
    2108       221169 :               TREE_VEC_ELT (r, i) = (*vec)[i];
    2109       404972 :             NON_DEFAULT_TEMPLATE_ARGS_COUNT (r)
    2110       404972 :               = NON_DEFAULT_TEMPLATE_ARGS_COUNT (t);
    2111              :           }
    2112              :         else
    2113              :           r = t;
    2114     18574363 :         return r;
    2115     18574363 :       }
    2116              : 
    2117       290208 :     case CONSTRUCTOR:
    2118       290208 :       {
    2119       290208 :         bool changed = false;
    2120       290208 :         vec<constructor_elt, va_gc> *vec
    2121       290208 :           = vec_safe_copy (CONSTRUCTOR_ELTS (t));
    2122       290208 :         n = CONSTRUCTOR_NELTS (t);
    2123       290208 :         type = strip_typedefs (TREE_TYPE (t), remove_attributes, flags);
    2124       309586 :         for (i = 0; i < n; ++i)
    2125              :           {
    2126        19378 :             constructor_elt *e = &(*vec)[i];
    2127        19378 :             tree op = strip_typedefs (e->value, remove_attributes, flags);
    2128        19378 :             if (op != e->value)
    2129              :               {
    2130            6 :                 changed = true;
    2131            6 :                 e->value = op;
    2132              :               }
    2133        19378 :             gcc_checking_assert
    2134              :               (e->index == strip_typedefs (e->index, remove_attributes,
    2135              :                                            flags));
    2136              :           }
    2137              : 
    2138       290208 :         if (!changed && type == TREE_TYPE (t))
    2139              :           {
    2140       268956 :             vec_free (vec);
    2141       268956 :             return t;
    2142              :           }
    2143              :         else
    2144              :           {
    2145        21252 :             r = copy_node (t);
    2146        21252 :             TREE_TYPE (r) = type;
    2147        21252 :             CONSTRUCTOR_ELTS (r) = vec;
    2148        21252 :             return r;
    2149              :           }
    2150              :       }
    2151              : 
    2152              :     case LAMBDA_EXPR:
    2153              :     case STMT_EXPR:
    2154              :       return t;
    2155              : 
    2156     97360259 :     default:
    2157     97360259 :       break;
    2158              :     }
    2159              : 
    2160     97360259 :   gcc_assert (EXPR_P (t));
    2161              : 
    2162     97360259 :   n = cp_tree_operand_length (t);
    2163     97360259 :   ops = XALLOCAVEC (tree, n);
    2164     97360259 :   type = TREE_TYPE (t);
    2165              : 
    2166     97360259 :   switch (code)
    2167              :     {
    2168      7108677 :     CASE_CONVERT:
    2169      7108677 :     case IMPLICIT_CONV_EXPR:
    2170      7108677 :     case DYNAMIC_CAST_EXPR:
    2171      7108677 :     case STATIC_CAST_EXPR:
    2172      7108677 :     case CONST_CAST_EXPR:
    2173      7108677 :     case REINTERPRET_CAST_EXPR:
    2174      7108677 :     case CAST_EXPR:
    2175      7108677 :     case NEW_EXPR:
    2176      7108677 :       type = strip_typedefs (type, remove_attributes, flags);
    2177              :       /* fallthrough */
    2178              : 
    2179     97360259 :     default:
    2180    318920194 :       for (i = 0; i < n; ++i)
    2181    221559935 :         ops[i] = strip_typedefs (TREE_OPERAND (t, i),
    2182              :                                  remove_attributes, flags);
    2183              :       break;
    2184              :     }
    2185              : 
    2186              :   /* If nothing changed, return t.  */
    2187    313232418 :   for (i = 0; i < n; ++i)
    2188    219552402 :     if (ops[i] != TREE_OPERAND (t, i))
    2189              :       break;
    2190     97360259 :   if (i == n && type == TREE_TYPE (t))
    2191              :     return t;
    2192              : 
    2193      3936515 :   r = copy_node (t);
    2194      3936515 :   TREE_TYPE (r) = type;
    2195     12464191 :   for (i = 0; i < n; ++i)
    2196      8527676 :     TREE_OPERAND (r, i) = ops[i];
    2197              :   return r;
    2198              : }
    2199              : 
    2200              : /* Makes a copy of BINFO and TYPE, which is to be inherited into a
    2201              :    graph dominated by T.  If BINFO is NULL, TYPE is a dependent base,
    2202              :    and we do a shallow copy.  If BINFO is non-NULL, we do a deep copy.
    2203              :    VIRT indicates whether TYPE is inherited virtually or not.
    2204              :    IGO_PREV points at the previous binfo of the inheritance graph
    2205              :    order chain.  The newly copied binfo's TREE_CHAIN forms this
    2206              :    ordering.
    2207              : 
    2208              :    The CLASSTYPE_VBASECLASSES vector of T is constructed in the
    2209              :    correct order. That is in the order the bases themselves should be
    2210              :    constructed in.
    2211              : 
    2212              :    The BINFO_INHERITANCE of a virtual base class points to the binfo
    2213              :    of the most derived type. ??? We could probably change this so that
    2214              :    BINFO_INHERITANCE becomes synonymous with BINFO_PRIMARY, and hence
    2215              :    remove a field.  They currently can only differ for primary virtual
    2216              :    virtual bases.  */
    2217              : 
    2218              : tree
    2219     38432212 : copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
    2220              : {
    2221     38432212 :   tree new_binfo;
    2222              : 
    2223     38432212 :   if (virt)
    2224              :     {
    2225              :       /* See if we've already made this virtual base.  */
    2226       279390 :       new_binfo = binfo_for_vbase (type, t);
    2227       279390 :       if (new_binfo)
    2228              :         return new_binfo;
    2229              :     }
    2230              : 
    2231     70040364 :   new_binfo = make_tree_binfo (binfo ? BINFO_N_BASE_BINFOS (binfo) : 0);
    2232     38364814 :   BINFO_TYPE (new_binfo) = type;
    2233              : 
    2234              :   /* Chain it into the inheritance graph.  */
    2235     38364814 :   TREE_CHAIN (*igo_prev) = new_binfo;
    2236     38364814 :   *igo_prev = new_binfo;
    2237              : 
    2238     70040364 :   if (binfo && !BINFO_DEPENDENT_BASE_P (binfo))
    2239              :     {
    2240     31675541 :       int ix;
    2241     31675541 :       tree base_binfo;
    2242              : 
    2243     31675541 :       gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), type));
    2244              : 
    2245     31675541 :       BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo);
    2246     31675541 :       BINFO_VIRTUALS (new_binfo) = BINFO_VIRTUALS (binfo);
    2247              : 
    2248              :       /* We do not need to copy the accesses, as they are read only.  */
    2249     31675541 :       BINFO_BASE_ACCESSES (new_binfo) = BINFO_BASE_ACCESSES (binfo);
    2250              : 
    2251              :       /* Recursively copy base binfos of BINFO.  */
    2252     35836253 :       for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
    2253              :         {
    2254      4160712 :           tree new_base_binfo;
    2255      4160712 :           new_base_binfo = copy_binfo (base_binfo, BINFO_TYPE (base_binfo),
    2256              :                                        t, igo_prev,
    2257      4160712 :                                        BINFO_VIRTUAL_P (base_binfo));
    2258              : 
    2259      4160712 :           if (!BINFO_INHERITANCE_CHAIN (new_base_binfo))
    2260      3947582 :             BINFO_INHERITANCE_CHAIN (new_base_binfo) = new_binfo;
    2261      4160712 :           BINFO_BASE_APPEND (new_binfo, new_base_binfo);
    2262              :         }
    2263              :     }
    2264              :   else
    2265      6689273 :     BINFO_DEPENDENT_BASE_P (new_binfo) = 1;
    2266              : 
    2267     38364814 :   if (virt)
    2268              :     {
    2269              :       /* Push it onto the list after any virtual bases it contains
    2270              :          will have been pushed.  */
    2271       211992 :       CLASSTYPE_VBASECLASSES (t)->quick_push (new_binfo);
    2272       211992 :       BINFO_VIRTUAL_P (new_binfo) = 1;
    2273       211992 :       BINFO_INHERITANCE_CHAIN (new_binfo) = TYPE_BINFO (t);
    2274              :     }
    2275              : 
    2276              :   return new_binfo;
    2277              : }
    2278              : 
    2279              : /* Hashing of lists so that we don't make duplicates.
    2280              :    The entry point is `list_hash_canon'.  */
    2281              : 
    2282              : struct list_proxy
    2283              : {
    2284              :   tree purpose;
    2285              :   tree value;
    2286              :   tree chain;
    2287              : };
    2288              : 
    2289              : struct list_hasher : ggc_ptr_hash<tree_node>
    2290              : {
    2291              :   typedef list_proxy *compare_type;
    2292              : 
    2293              :   static hashval_t hash (tree);
    2294              :   static bool equal (tree, list_proxy *);
    2295              : };
    2296              : 
    2297              : /* Now here is the hash table.  When recording a list, it is added
    2298              :    to the slot whose index is the hash code mod the table size.
    2299              :    Note that the hash table is used for several kinds of lists.
    2300              :    While all these live in the same table, they are completely independent,
    2301              :    and the hash code is computed differently for each of these.  */
    2302              : 
    2303              : static GTY (()) hash_table<list_hasher> *list_hash_table;
    2304              : 
    2305              : /* Compare ENTRY (an entry in the hash table) with DATA (a list_proxy
    2306              :    for a node we are thinking about adding).  */
    2307              : 
    2308              : bool
    2309   2638785110 : list_hasher::equal (tree t, list_proxy *proxy)
    2310              : {
    2311   2638785110 :   return (TREE_VALUE (t) == proxy->value
    2312    177919004 :           && TREE_PURPOSE (t) == proxy->purpose
    2313   2814870059 :           && TREE_CHAIN (t) == proxy->chain);
    2314              : }
    2315              : 
    2316              : /* Compute a hash code for a list (chain of TREE_LIST nodes
    2317              :    with goodies in the TREE_PURPOSE, TREE_VALUE, and bits of the
    2318              :    TREE_COMMON slots), by adding the hash codes of the individual entries.  */
    2319              : 
    2320              : static hashval_t
    2321   2423368200 : list_hash_pieces (tree purpose, tree value, tree chain)
    2322              : {
    2323   2423368200 :   hashval_t hashcode = 0;
    2324              : 
    2325   2423368200 :   if (chain)
    2326   2423141032 :     hashcode += TREE_HASH (chain);
    2327              : 
    2328   2423368200 :   if (value)
    2329   2423368200 :     hashcode += TREE_HASH (value);
    2330              :   else
    2331            0 :     hashcode += 1007;
    2332   2423368200 :   if (purpose)
    2333    137332985 :     hashcode += TREE_HASH (purpose);
    2334              :   else
    2335   2286035215 :     hashcode += 1009;
    2336   2423368200 :   return hashcode;
    2337              : }
    2338              : 
    2339              : /* Hash an already existing TREE_LIST.  */
    2340              : 
    2341              : hashval_t
    2342   2100504329 : list_hasher::hash (tree t)
    2343              : {
    2344   2100504329 :   return list_hash_pieces (TREE_PURPOSE (t),
    2345   2100504329 :                            TREE_VALUE (t),
    2346   2100504329 :                            TREE_CHAIN (t));
    2347              : }
    2348              : 
    2349              : /* Given list components PURPOSE, VALUE, AND CHAIN, return the canonical
    2350              :    object for an identical list if one already exists.  Otherwise, build a
    2351              :    new one, and record it as the canonical object.  */
    2352              : 
    2353              : tree
    2354    322863871 : hash_tree_cons (tree purpose, tree value, tree chain)
    2355              : {
    2356    322863871 :   int hashcode = 0;
    2357    322863871 :   tree *slot;
    2358    322863871 :   struct list_proxy proxy;
    2359              : 
    2360              :   /* Hash the list node.  */
    2361    322863871 :   hashcode = list_hash_pieces (purpose, value, chain);
    2362              :   /* Create a proxy for the TREE_LIST we would like to create.  We
    2363              :      don't actually create it so as to avoid creating garbage.  */
    2364    322863871 :   proxy.purpose = purpose;
    2365    322863871 :   proxy.value = value;
    2366    322863871 :   proxy.chain = chain;
    2367              :   /* See if it is already in the table.  */
    2368    322863871 :   slot = list_hash_table->find_slot_with_hash (&proxy, hashcode, INSERT);
    2369              :   /* If not, create a new node.  */
    2370    322863871 :   if (!*slot)
    2371    152703773 :     *slot = tree_cons (purpose, value, chain);
    2372    322863871 :   return (tree) *slot;
    2373              : }
    2374              : 
    2375              : /* Constructor for hashed lists.  */
    2376              : 
    2377              : tree
    2378      2229084 : hash_tree_chain (tree value, tree chain)
    2379              : {
    2380      2229084 :   return hash_tree_cons (NULL_TREE, value, chain);
    2381              : }
    2382              : 
    2383              : void
    2384            0 : debug_binfo (tree elem)
    2385              : {
    2386            0 :   HOST_WIDE_INT n;
    2387            0 :   tree virtuals;
    2388              : 
    2389            0 :   fprintf (stderr, "type \"%s\", offset = " HOST_WIDE_INT_PRINT_DEC
    2390              :            "\nvtable type:\n",
    2391            0 :            TYPE_NAME_STRING (BINFO_TYPE (elem)),
    2392            0 :            TREE_INT_CST_LOW (BINFO_OFFSET (elem)));
    2393            0 :   debug_tree (BINFO_TYPE (elem));
    2394            0 :   if (BINFO_VTABLE (elem))
    2395            0 :     fprintf (stderr, "vtable decl \"%s\"\n",
    2396            0 :              IDENTIFIER_POINTER (DECL_NAME (get_vtbl_decl_for_binfo (elem))));
    2397              :   else
    2398            0 :     fprintf (stderr, "no vtable decl yet\n");
    2399            0 :   fprintf (stderr, "virtuals:\n");
    2400            0 :   virtuals = BINFO_VIRTUALS (elem);
    2401            0 :   n = 0;
    2402              : 
    2403            0 :   while (virtuals)
    2404              :     {
    2405            0 :       tree fndecl = TREE_VALUE (virtuals);
    2406            0 :       fprintf (stderr, "%s [" HOST_WIDE_INT_PRINT_DEC " =? "
    2407              :                        HOST_WIDE_INT_PRINT_DEC "]\n",
    2408            0 :                IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)),
    2409            0 :                n, TREE_INT_CST_LOW (DECL_VINDEX (fndecl)));
    2410            0 :       ++n;
    2411            0 :       virtuals = TREE_CHAIN (virtuals);
    2412              :     }
    2413            0 : }
    2414              : 
    2415              : /* Build a representation for the qualified name SCOPE::NAME.  TYPE is
    2416              :    the type of the result expression, if known, or NULL_TREE if the
    2417              :    resulting expression is type-dependent.  If TEMPLATE_P is true,
    2418              :    NAME is known to be a template because the user explicitly used the
    2419              :    "template" keyword after the "::".
    2420              : 
    2421              :    All SCOPE_REFs should be built by use of this function.  */
    2422              : 
    2423              : tree
    2424    148472882 : build_qualified_name (tree type, tree scope, tree name, bool template_p)
    2425              : {
    2426    148472882 :   tree t;
    2427    148472882 :   if (type == error_mark_node
    2428    148472882 :       || scope == error_mark_node
    2429    148472879 :       || name == error_mark_node)
    2430              :     return error_mark_node;
    2431    148472879 :   gcc_assert (TREE_CODE (name) != SCOPE_REF);
    2432    148472879 :   t = build2 (SCOPE_REF, type, scope, name);
    2433    148472879 :   QUALIFIED_NAME_IS_TEMPLATE (t) = template_p;
    2434    148472879 :   PTRMEM_OK_P (t) = true;
    2435    148472879 :   if (type)
    2436     10179952 :     t = convert_from_reference (t);
    2437              :   return t;
    2438              : }
    2439              : 
    2440              : /* Like check_qualified_type, but also check ref-qualifier, exception
    2441              :    specification, and whether the return type was specified after the
    2442              :    parameters.  */
    2443              : 
    2444              : static bool
    2445   1287362267 : cp_check_qualified_type (const_tree cand, const_tree base, int type_quals,
    2446              :                          cp_ref_qualifier rqual, tree raises, bool late)
    2447              : {
    2448   1287362267 :   return (TYPE_QUALS (cand) == type_quals
    2449   1287300778 :           && check_base_type (cand, base)
    2450   1287207678 :           && comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (cand),
    2451              :                                 ce_exact)
    2452    614357574 :           && TYPE_HAS_LATE_RETURN_TYPE (cand) == late
    2453   1859551975 :           && type_memfn_rqual (cand) == rqual);
    2454              : }
    2455              : 
    2456              : /* Build the FUNCTION_TYPE or METHOD_TYPE with the ref-qualifier RQUAL.  */
    2457              : 
    2458              : tree
    2459      1301056 : build_ref_qualified_type (tree type, cp_ref_qualifier rqual)
    2460              : {
    2461      1301056 :   tree raises = TYPE_RAISES_EXCEPTIONS (type);
    2462      1301056 :   bool late = TYPE_HAS_LATE_RETURN_TYPE (type);
    2463      1301056 :   return build_cp_fntype_variant (type, rqual, raises, late);
    2464              : }
    2465              : 
    2466              : tree
    2467       196481 : make_binding_vec (tree name, unsigned clusters MEM_STAT_DECL)
    2468              : {
    2469              :   /* Stored in an unsigned short, but we're limited to the number of
    2470              :      modules anyway.  */
    2471       196481 :   gcc_checking_assert (clusters <= (unsigned short)(~0));
    2472       196481 :   size_t length = (offsetof (tree_binding_vec, vec)
    2473       196481 :                    + clusters * sizeof (binding_cluster));
    2474       196481 :   tree vec = ggc_alloc_cleared_tree_node_stat (length PASS_MEM_STAT);
    2475       196481 :   TREE_SET_CODE (vec, BINDING_VECTOR);
    2476       196481 :   BINDING_VECTOR_NAME (vec) = name;
    2477       196481 :   BINDING_VECTOR_ALLOC_CLUSTERS (vec) = clusters;
    2478       196481 :   BINDING_VECTOR_NUM_CLUSTERS (vec) = 0;
    2479              : 
    2480       196481 :   return vec;
    2481              : }
    2482              : 
    2483              : /* Make a raw overload node containing FN.  */
    2484              : 
    2485              : tree
    2486    405869637 : ovl_make (tree fn, tree next)
    2487              : {
    2488    405869637 :   tree result = make_node (OVERLOAD);
    2489              : 
    2490    405869637 :   if (TREE_CODE (fn) == OVERLOAD)
    2491     19919208 :     OVL_NESTED_P (result) = true;
    2492              : 
    2493    522568411 :   TREE_TYPE (result) = (next || TREE_CODE (fn) == TEMPLATE_DECL
    2494    522568411 :                         ? unknown_type_node : TREE_TYPE (fn));
    2495    405869637 :   if (next && TREE_CODE (next) == OVERLOAD && OVL_DEDUP_P (next))
    2496     15137605 :     OVL_DEDUP_P (result) = true;
    2497    405869637 :   OVL_FUNCTION (result) = fn;
    2498    405869637 :   OVL_CHAIN (result) = next;
    2499    405869637 :   return result;
    2500              : }
    2501              : 
    2502              : /* Add FN to the (potentially NULL) overload set OVL.  USING_OR_HIDDEN is > 0
    2503              :    if this is a using-decl.  It is > 1 if we're revealing the using decl.
    2504              :    It is > 2 if we're also exporting it.  USING_OR_HIDDEN is < 0, if FN is
    2505              :    hidden.  (A decl cannot be both using and hidden.)  We keep the hidden
    2506              :    decls first, but remaining ones are unordered.  */
    2507              : 
    2508              : tree
    2509    703364718 : ovl_insert (tree fn, tree maybe_ovl, int using_or_hidden)
    2510              : {
    2511    703364718 :   tree result = maybe_ovl;
    2512    703364718 :   tree insert_after = NULL_TREE;
    2513              : 
    2514              :   /* Skip hidden.  */
    2515    985464599 :   for (; maybe_ovl && TREE_CODE (maybe_ovl) == OVERLOAD
    2516   1014375574 :          && OVL_HIDDEN_P (maybe_ovl);
    2517     88875035 :        maybe_ovl = OVL_CHAIN (maybe_ovl))
    2518              :     {
    2519     88875035 :       gcc_checking_assert (!OVL_LOOKUP_P (maybe_ovl));
    2520     88875035 :       insert_after = maybe_ovl;
    2521              :     }
    2522              : 
    2523    703364718 :   if (maybe_ovl || using_or_hidden || TREE_CODE (fn) == TEMPLATE_DECL)
    2524              :     {
    2525    305766815 :       maybe_ovl = ovl_make (fn, maybe_ovl);
    2526              : 
    2527    305766815 :       if (using_or_hidden < 0)
    2528     78321839 :         OVL_HIDDEN_P (maybe_ovl) = true;
    2529    305766815 :       if (using_or_hidden > 0)
    2530              :         {
    2531     12689334 :           OVL_DEDUP_P (maybe_ovl) = OVL_USING_P (maybe_ovl) = true;
    2532     12689334 :           if (using_or_hidden > 1)
    2533        13688 :             OVL_PURVIEW_P (maybe_ovl) = true;
    2534        13688 :           if (using_or_hidden > 2)
    2535        13168 :             OVL_EXPORT_P (maybe_ovl) = true;
    2536              :         }
    2537              :     }
    2538              :   else
    2539              :     maybe_ovl = fn;
    2540              : 
    2541    703364718 :   if (insert_after)
    2542              :     {
    2543      8866691 :       OVL_CHAIN (insert_after) = maybe_ovl;
    2544      8866691 :       TREE_TYPE (insert_after) = unknown_type_node;
    2545              :     }
    2546              :   else
    2547              :     result = maybe_ovl;
    2548              : 
    2549    703364718 :   return result;
    2550              : }
    2551              : 
    2552              : /* Skip any hidden names at the beginning of OVL.   */
    2553              : 
    2554              : tree
    2555   2009605614 : ovl_skip_hidden (tree ovl)
    2556              : {
    2557   3872358467 :   while (ovl && TREE_CODE (ovl) == OVERLOAD && OVL_HIDDEN_P (ovl))
    2558   1862752853 :     ovl = OVL_CHAIN (ovl);
    2559              : 
    2560   2009605614 :   return ovl;
    2561              : }
    2562              : 
    2563              : /* NODE is an OVL_HIDDEN_P node that is now revealed.  */
    2564              : 
    2565              : tree
    2566      3886273 : ovl_iterator::reveal_node (tree overload, tree node)
    2567              : {
    2568              :   /* We cannot have returned NODE as part of a lookup overload, so we
    2569              :      don't have to worry about preserving that.  */
    2570              : 
    2571      3886273 :   OVL_HIDDEN_P (node) = false;
    2572      3886273 :   if (tree chain = OVL_CHAIN (node))
    2573       166476 :     if (TREE_CODE (chain) == OVERLOAD)
    2574              :       {
    2575       157415 :         if (OVL_HIDDEN_P (chain))
    2576              :           {
    2577              :             /* The node needs moving, and the simplest way is to remove it
    2578              :                and reinsert.  */
    2579        72223 :             overload = remove_node (overload, node);
    2580        72223 :             overload = ovl_insert (OVL_FUNCTION (node), overload);
    2581              :           }
    2582        85192 :         else if (OVL_DEDUP_P (chain))
    2583            9 :           OVL_DEDUP_P (node) = true;
    2584              :       }
    2585      3886273 :   return overload;
    2586              : }
    2587              : 
    2588              : /* NODE is on the overloads of OVL.  Remove it.
    2589              :    The removed node is unaltered and may continue to be iterated
    2590              :    from (i.e. it is safe to remove a node from an overload one is
    2591              :    currently iterating over).  */
    2592              : 
    2593              : tree
    2594       373484 : ovl_iterator::remove_node (tree overload, tree node)
    2595              : {
    2596       373484 :   tree *slot = &overload;
    2597      2211075 :   while (*slot != node)
    2598              :     {
    2599      1837591 :       tree probe = *slot;
    2600      1837591 :       gcc_checking_assert (!OVL_LOOKUP_P (probe));
    2601              : 
    2602      1837591 :       slot = &OVL_CHAIN (probe);
    2603              :     }
    2604              : 
    2605              :   /* Stitch out NODE.  We don't have to worry about now making a
    2606              :      singleton overload (and consequently maybe setting its type),
    2607              :      because all uses of this function will be followed by inserting a
    2608              :      new node that must follow the place we've cut this out from.  */
    2609       373484 :   if (TREE_CODE (node) != OVERLOAD)
    2610              :     /* Cloned inherited ctors don't mark themselves as via_using.  */
    2611       229054 :     *slot = NULL_TREE;
    2612              :   else
    2613       144430 :     *slot = OVL_CHAIN (node);
    2614              : 
    2615       373484 :   return overload;
    2616              : }
    2617              : 
    2618              : /* Mark or unmark a lookup set. */
    2619              : 
    2620              : void
    2621    130350548 : lookup_mark (tree ovl, bool val)
    2622              : {
    2623   2001033448 :   for (lkp_iterator iter (ovl); iter; ++iter)
    2624              :     {
    2625   1870682900 :       gcc_checking_assert (LOOKUP_SEEN_P (*iter) != val);
    2626   1870682900 :       LOOKUP_SEEN_P (*iter) = val;
    2627              :     }
    2628    130350548 : }
    2629              : 
    2630              : /* Add a set of new FNS into a lookup.  */
    2631              : 
    2632              : tree
    2633    671320149 : lookup_add (tree fns, tree lookup)
    2634              : {
    2635    671320149 :   if (fns == error_mark_node || lookup == error_mark_node)
    2636              :     return error_mark_node;
    2637              : 
    2638    671320137 :   if (lookup || TREE_CODE (fns) == TEMPLATE_DECL)
    2639              :     {
    2640     94672817 :       lookup = ovl_make (fns, lookup);
    2641     94672817 :       OVL_LOOKUP_P (lookup) = true;
    2642              :     }
    2643              :   else
    2644              :     lookup = fns;
    2645              : 
    2646              :   return lookup;
    2647              : }
    2648              : 
    2649              : /* FNS is a new overload set, add them to LOOKUP, if they are not
    2650              :    already present there.  */
    2651              : 
    2652              : tree
    2653    667057293 : lookup_maybe_add (tree fns, tree lookup, bool deduping)
    2654              : {
    2655    667057293 :   if (deduping)
    2656    846956238 :     for (tree next, probe = fns; probe; probe = next)
    2657              :       {
    2658    756275007 :         tree fn = probe;
    2659    756275007 :         next = NULL_TREE;
    2660              : 
    2661    756275007 :         if (TREE_CODE (probe) == OVERLOAD)
    2662              :           {
    2663    716569707 :             fn = OVL_FUNCTION (probe);
    2664    716569707 :             next = OVL_CHAIN (probe);
    2665              :           }
    2666              : 
    2667    756275007 :         if (!LOOKUP_SEEN_P (fn))
    2668    560216234 :           LOOKUP_SEEN_P (fn) = true;
    2669              :         else
    2670              :           {
    2671              :             /* This function was already seen.  Insert all the
    2672              :                predecessors onto the lookup.  */
    2673    219084701 :             for (; fns != probe; fns = OVL_CHAIN (fns))
    2674              :               {
    2675              :                 /* Propagate OVL_USING, but OVL_HIDDEN &
    2676              :                    OVL_DEDUP_P don't matter.  */
    2677     23025928 :                 if (OVL_USING_P (fns))
    2678              :                   {
    2679        31745 :                     lookup = ovl_make (OVL_FUNCTION (fns), lookup);
    2680        31745 :                     OVL_USING_P (lookup) = true;
    2681              :                   }
    2682              :                 else
    2683     22994183 :                   lookup = lookup_add (OVL_FUNCTION (fns), lookup);
    2684              :               }
    2685              : 
    2686              :             /* And now skip this function.  */
    2687              :             fns = next;
    2688              :           }
    2689              :       }
    2690              : 
    2691    667057293 :   if (fns)
    2692              :     /* We ended in a set of new functions.  Add them all in one go.  */
    2693    647109242 :     lookup = lookup_add (fns, lookup);
    2694              : 
    2695    667057293 :   return lookup;
    2696              : }
    2697              : 
    2698              : /* Returns nonzero if X is an expression for a (possibly overloaded)
    2699              :    function.  If "f" is a function or function template, "f", "c->f",
    2700              :    "c.f", "C::f", and "f<int>" will all be considered possibly
    2701              :    overloaded functions.  Returns 2 if the function is actually
    2702              :    overloaded, i.e., if it is impossible to know the type of the
    2703              :    function without performing overload resolution.  */
    2704              : 
    2705              : int
    2706   8304700156 : is_overloaded_fn (tree x)
    2707              : {
    2708   8304700156 :   STRIP_ANY_LOCATION_WRAPPER (x);
    2709              : 
    2710              :   /* A baselink is also considered an overloaded function.  */
    2711   8304700156 :   if (TREE_CODE (x) == OFFSET_REF
    2712   8304636738 :       || TREE_CODE (x) == COMPONENT_REF)
    2713    432275415 :     x = TREE_OPERAND (x, 1);
    2714   8304700156 :   x = MAYBE_BASELINK_FUNCTIONS (x);
    2715   8304700156 :   if (TREE_CODE (x) == TEMPLATE_ID_EXPR)
    2716    223631891 :     x = TREE_OPERAND (x, 0);
    2717              : 
    2718   9545267452 :   if (DECL_FUNCTION_TEMPLATE_P (OVL_FIRST (x))
    2719   8335121177 :       || (TREE_CODE (x) == OVERLOAD && !OVL_SINGLE_P (x)))
    2720              :     return 2;
    2721              : 
    2722   8751240961 :   return OVL_P (x);
    2723              : }
    2724              : 
    2725              : /* X is the CALL_EXPR_FN of a CALL_EXPR.  If X represents a dependent name
    2726              :    (14.6.2), return the IDENTIFIER_NODE for that name.  Otherwise, return
    2727              :    NULL_TREE.  */
    2728              : 
    2729              : tree
    2730    225866323 : dependent_name (tree x)
    2731              : {
    2732              :   /* FIXME a dependent name must be unqualified, but this function doesn't
    2733              :      distinguish between qualified and unqualified identifiers.  */
    2734    225866323 :   if (identifier_p (x))
    2735              :     return x;
    2736    225706122 :   if (TREE_CODE (x) == TEMPLATE_ID_EXPR)
    2737    111647487 :     x = TREE_OPERAND (x, 0);
    2738    225706122 :   if (OVL_P (x))
    2739    200657331 :     return OVL_NAME (x);
    2740              :   return NULL_TREE;
    2741              : }
    2742              : 
    2743              : /* Like dependent_name, but instead takes a CALL_EXPR and also checks
    2744              :    its dependence.  */
    2745              : 
    2746              : tree
    2747    221685901 : call_expr_dependent_name (tree x)
    2748              : {
    2749    221685901 :   if (TREE_TYPE (x) != NULL_TREE)
    2750              :     /* X isn't dependent, so its callee isn't a dependent name.  */
    2751              :     return NULL_TREE;
    2752    216907482 :   return dependent_name (CALL_EXPR_FN (x));
    2753              : }
    2754              : 
    2755              : /* Returns true iff X is an expression for an overloaded function
    2756              :    whose type cannot be known without performing overload
    2757              :    resolution.  */
    2758              : 
    2759              : bool
    2760    709579662 : really_overloaded_fn (tree x)
    2761              : {
    2762    709579662 :   return is_overloaded_fn (x) == 2;
    2763              : }
    2764              : 
    2765              : /* Get the overload set FROM refers to.  Returns NULL if it's not an
    2766              :    overload set.  */
    2767              : 
    2768              : tree
    2769   4592943171 : maybe_get_fns (tree from)
    2770              : {
    2771   4592943171 :   STRIP_ANY_LOCATION_WRAPPER (from);
    2772              : 
    2773              :   /* A baselink is also considered an overloaded function.  */
    2774   4592943171 :   if (TREE_CODE (from) == OFFSET_REF
    2775   4592884474 :       || TREE_CODE (from) == COMPONENT_REF)
    2776    146550183 :     from = TREE_OPERAND (from, 1);
    2777   4592943171 :   if (BASELINK_P (from))
    2778    137592257 :     from = BASELINK_FUNCTIONS (from);
    2779   4592943171 :   if (TREE_CODE (from) == TEMPLATE_ID_EXPR)
    2780    113614225 :     from = TREE_OPERAND (from, 0);
    2781              : 
    2782   4592943171 :   if (OVL_P (from))
    2783   1234894335 :     return from;
    2784              : 
    2785              :   return NULL_TREE;
    2786              : }
    2787              : 
    2788              : /* FROM refers to an overload set.  Return that set (or die).  */
    2789              : 
    2790              : tree
    2791    913080383 : get_fns (tree from)
    2792              : {
    2793    913080383 :   tree res = maybe_get_fns (from);
    2794              : 
    2795    913080383 :   gcc_assert (res);
    2796    913080383 :   return res;
    2797              : }
    2798              : 
    2799              : /* Return the first function of the overload set FROM refers to.  */
    2800              : 
    2801              : tree
    2802    552219118 : get_first_fn (tree from)
    2803              : {
    2804    552219118 :   return OVL_FIRST (get_fns (from));
    2805              : }
    2806              : 
    2807              : /* Return the first function of the overload set FROM refers to if
    2808              :    there is an overload set, otherwise return FROM unchanged.  */
    2809              : 
    2810              : tree
    2811        91774 : maybe_get_first_fn (tree from)
    2812              : {
    2813        91774 :   if (tree res = maybe_get_fns (from))
    2814        91774 :     return OVL_FIRST (res);
    2815              :   return from;
    2816              : }
    2817              : 
    2818              : /* Return the scope where the overloaded functions OVL were found.  */
    2819              : 
    2820              : tree
    2821    256997047 : ovl_scope (tree ovl)
    2822              : {
    2823    256997047 :   if (TREE_CODE (ovl) == OFFSET_REF
    2824    256997047 :       || TREE_CODE (ovl) == COMPONENT_REF)
    2825            0 :     ovl = TREE_OPERAND (ovl, 1);
    2826    256997047 :   if (TREE_CODE (ovl) == BASELINK)
    2827     43545546 :     return BINFO_TYPE (BASELINK_BINFO (ovl));
    2828    213451501 :   if (TREE_CODE (ovl) == TEMPLATE_ID_EXPR)
    2829    106166243 :     ovl = TREE_OPERAND (ovl, 0);
    2830              :   /* Skip using-declarations.  */
    2831    213451501 :   lkp_iterator iter (ovl);
    2832    228956190 :   do
    2833    228956190 :     ovl = *iter;
    2834    442407691 :   while (iter.using_p () && ++iter);
    2835              : 
    2836    213451501 :   return CP_DECL_CONTEXT (ovl);
    2837              : }
    2838              : 
    2839              : #define PRINT_RING_SIZE 4
    2840              : 
    2841              : static const char *
    2842       157525 : cxx_printable_name_internal (tree decl, int v, bool translate)
    2843              : {
    2844       157525 :   static unsigned int uid_ring[PRINT_RING_SIZE];
    2845       157525 :   static char *print_ring[PRINT_RING_SIZE];
    2846       157525 :   static bool trans_ring[PRINT_RING_SIZE];
    2847       157525 :   static int ring_counter;
    2848       157525 :   int i;
    2849              : 
    2850              :   /* Only cache functions.  */
    2851       157525 :   if (v < 2
    2852        77016 :       || TREE_CODE (decl) != FUNCTION_DECL
    2853       231461 :       || DECL_LANG_SPECIFIC (decl) == 0)
    2854        84973 :     return lang_decl_name (decl, v, translate);
    2855              : 
    2856              :   /* See if this print name is lying around.  */
    2857       332715 :   for (i = 0; i < PRINT_RING_SIZE; i++)
    2858       272396 :     if (uid_ring[i] == DECL_UID (decl) && translate == trans_ring[i])
    2859              :       /* yes, so return it.  */
    2860        12233 :       return print_ring[i];
    2861              : 
    2862        60319 :   const char *ret = lang_decl_name (decl, v, translate);
    2863              : 
    2864              :   /* The lang_decl_name call could have called this function recursively,
    2865              :      so check again.  */
    2866       361914 :   for (i = 0; i < PRINT_RING_SIZE; i++)
    2867       241276 :     if (uid_ring[i] == DECL_UID (decl) && translate == trans_ring[i])
    2868              :       /* yes, so return it.  */
    2869            0 :       return print_ring[i];
    2870              : 
    2871        60319 :   if (++ring_counter == PRINT_RING_SIZE)
    2872        12187 :     ring_counter = 0;
    2873              : 
    2874        60319 :   if (current_function_decl != NULL_TREE)
    2875              :     {
    2876              :       /* There may be both translated and untranslated versions of the
    2877              :          name cached.  */
    2878       162240 :       for (i = 0; i < 2; i++)
    2879              :         {
    2880       108160 :           if (uid_ring[ring_counter] == DECL_UID (current_function_decl))
    2881           73 :             ring_counter += 1;
    2882       108160 :           if (ring_counter == PRINT_RING_SIZE)
    2883           10 :             ring_counter = 0;
    2884              :         }
    2885        54080 :       gcc_assert (uid_ring[ring_counter] != DECL_UID (current_function_decl));
    2886              :     }
    2887              : 
    2888        60319 :   free (print_ring[ring_counter]);
    2889              : 
    2890        60319 :   print_ring[ring_counter] = xstrdup (ret);
    2891        60319 :   uid_ring[ring_counter] = DECL_UID (decl);
    2892        60319 :   trans_ring[ring_counter] = translate;
    2893        60319 :   return print_ring[ring_counter];
    2894              : }
    2895              : 
    2896              : const char *
    2897       157525 : cxx_printable_name (tree decl, int v)
    2898              : {
    2899       157525 :   return cxx_printable_name_internal (decl, v, false);
    2900              : }
    2901              : 
    2902              : const char *
    2903            0 : cxx_printable_name_translate (tree decl, int v)
    2904              : {
    2905            0 :   return cxx_printable_name_internal (decl, v, true);
    2906              : }
    2907              : 
    2908              : /* Return the canonical version of exception-specification RAISES for a C++17
    2909              :    function type, for use in type comparison and building TYPE_CANONICAL.  */
    2910              : 
    2911              : tree
    2912    222691001 : canonical_eh_spec (tree raises)
    2913              : {
    2914    222691001 :   if (raises == NULL_TREE)
    2915              :     return raises;
    2916    196751554 :   else if (DEFERRED_NOEXCEPT_SPEC_P (raises)
    2917    157731106 :            || UNPARSED_NOEXCEPT_SPEC_P (raises)
    2918    149650473 :            || uses_template_parms (raises)
    2919    149650473 :            || uses_template_parms (TREE_PURPOSE (raises)))
    2920              :     /* Keep a dependent or deferred exception specification.  */
    2921     48809802 :     return raises;
    2922    147941752 :   else if (nothrow_spec_p (raises))
    2923              :     /* throw() -> noexcept.  */
    2924    147417909 :     return noexcept_true_spec;
    2925              :   else
    2926              :     /* For C++17 type matching, anything else -> nothing.  */
    2927              :     return NULL_TREE;
    2928              : }
    2929              : 
    2930              : tree
    2931    765549857 : build_cp_fntype_variant (tree type, cp_ref_qualifier rqual,
    2932              :                          tree raises, bool late)
    2933              : {
    2934    765549857 :   cp_cv_quals type_quals = TYPE_QUALS (type);
    2935              : 
    2936    765549857 :   if (cp_check_qualified_type (type, type, type_quals, rqual, raises, late))
    2937              :     return type;
    2938              : 
    2939    327306277 :   tree v = TYPE_MAIN_VARIANT (type);
    2940    718749183 :   for (; v; v = TYPE_NEXT_VARIANT (v))
    2941    521812410 :     if (cp_check_qualified_type (v, type, type_quals, rqual, raises, late))
    2942              :       return v;
    2943              : 
    2944              :   /* Need to build a new variant.  */
    2945    196936773 :   v = build_variant_type_copy (type);
    2946    196936773 :   if (!TYPE_DEPENDENT_P (v))
    2947              :     /* We no longer know that it's not type-dependent.  */
    2948    196150786 :     TYPE_DEPENDENT_P_VALID (v) = false;
    2949    196936773 :   TYPE_RAISES_EXCEPTIONS (v) = raises;
    2950    196936773 :   TYPE_HAS_LATE_RETURN_TYPE (v) = late;
    2951    196936773 :   switch (rqual)
    2952              :     {
    2953      1167985 :     case REF_QUAL_RVALUE:
    2954      1167985 :       FUNCTION_RVALUE_QUALIFIED (v) = 1;
    2955      1167985 :       FUNCTION_REF_QUALIFIED (v) = 1;
    2956      1167985 :       break;
    2957      1117511 :     case REF_QUAL_LVALUE:
    2958      1117511 :       FUNCTION_RVALUE_QUALIFIED (v) = 0;
    2959      1117511 :       FUNCTION_REF_QUALIFIED (v) = 1;
    2960      1117511 :       break;
    2961    194651277 :     default:
    2962    194651277 :       FUNCTION_REF_QUALIFIED (v) = 0;
    2963    194651277 :       break;
    2964              :     }
    2965              : 
    2966              :   /* Canonicalize the exception specification.  */
    2967    196936773 :   tree cr = flag_noexcept_type ? canonical_eh_spec (raises) : NULL_TREE;
    2968    185913606 :   bool complex_eh_spec_p = (cr && cr != noexcept_true_spec
    2969    244255727 :                             && !UNPARSED_NOEXCEPT_SPEC_P (cr));
    2970              : 
    2971    156745924 :   if (!complex_eh_spec_p && TYPE_RAISES_EXCEPTIONS (type))
    2972              :     /* We want to consider structural equality of the exception-less
    2973              :        variant since we'll be replacing the exception specification.  */
    2974      6659470 :     type = build_cp_fntype_variant (type, rqual, /*raises=*/NULL_TREE, late);
    2975    196936773 :   if (TYPE_STRUCTURAL_EQUALITY_P (type) || complex_eh_spec_p)
    2976              :     /* Propagate structural equality.  And always use structural equality
    2977              :        for function types with a complex noexcept-spec since their identity
    2978              :        may depend on e.g. whether comparing_specializations is set.  */
    2979     53348369 :     SET_TYPE_STRUCTURAL_EQUALITY (v);
    2980    143588404 :   else if (TYPE_CANONICAL (type) != type || cr != raises || late)
    2981              :     /* Build the underlying canonical type, since it is different
    2982              :        from TYPE. */
    2983     61523749 :     TYPE_CANONICAL (v) = build_cp_fntype_variant (TYPE_CANONICAL (type),
    2984              :                                                   rqual, cr, false);
    2985              :   else
    2986              :     /* T is its own canonical type. */
    2987     82064655 :     TYPE_CANONICAL (v) = v;
    2988              : 
    2989              :   return v;
    2990              : }
    2991              : 
    2992              : /* TYPE is a function or method type with a deferred exception
    2993              :    specification that has been parsed to RAISES.  Fixup all the type
    2994              :    variants that are affected in place.  Via decltype &| noexcept
    2995              :    tricks, the unparsed spec could have escaped into the type system.  */
    2996              : 
    2997              : void
    2998      3273325 : fixup_deferred_exception_variants (tree type, tree raises)
    2999              : {
    3000      3273325 :   tree original = TYPE_RAISES_EXCEPTIONS (type);
    3001              : 
    3002      6546650 :   gcc_checking_assert (UNPARSED_NOEXCEPT_SPEC_P (original));
    3003              : 
    3004      3273325 :   for (tree variant = TYPE_MAIN_VARIANT (type);
    3005     10608959 :        variant; variant = TYPE_NEXT_VARIANT (variant))
    3006      7335634 :     if (TYPE_RAISES_EXCEPTIONS (variant) == original)
    3007              :       {
    3008      3537719 :         gcc_checking_assert (variant != TYPE_MAIN_VARIANT (type));
    3009              : 
    3010      3537719 :         SET_TYPE_STRUCTURAL_EQUALITY (variant);
    3011      3537719 :         TYPE_RAISES_EXCEPTIONS (variant) = raises;
    3012              : 
    3013      3537719 :         if (!TYPE_DEPENDENT_P (variant))
    3014              :           /* We no longer know that it's not type-dependent.  */
    3015       267980 :           TYPE_DEPENDENT_P_VALID (variant) = false;
    3016              :       }
    3017      3273325 : }
    3018              : 
    3019              : /* Build the FUNCTION_TYPE or METHOD_TYPE which may throw exceptions
    3020              :    listed in RAISES.  */
    3021              : 
    3022              : tree
    3023    196401574 : build_exception_variant (tree type, tree raises)
    3024              : {
    3025    196401574 :   cp_ref_qualifier rqual = type_memfn_rqual (type);
    3026    196401574 :   bool late = TYPE_HAS_LATE_RETURN_TYPE (type);
    3027    196401574 :   return build_cp_fntype_variant (type, rqual, raises, late);
    3028              : }
    3029              : 
    3030              : /* Given a TEMPLATE_TEMPLATE_PARM node T, create a new
    3031              :    BOUND_TEMPLATE_TEMPLATE_PARM bound with NEWARGS as its template
    3032              :    arguments.  */
    3033              : 
    3034              : tree
    3035       334469 : bind_template_template_parm (tree t, tree newargs)
    3036              : {
    3037       334469 :   tree decl = TYPE_NAME (t);
    3038       334469 :   tree t2;
    3039              : 
    3040       334469 :   t2 = cxx_make_type (BOUND_TEMPLATE_TEMPLATE_PARM);
    3041       334469 :   decl = build_decl (input_location,
    3042       334469 :                      TYPE_DECL, DECL_NAME (decl), NULL_TREE);
    3043       334469 :   SET_DECL_TEMPLATE_PARM_P (decl);
    3044              : 
    3045              :   /* These nodes have to be created to reflect new TYPE_DECL and template
    3046              :      arguments.  */
    3047       334469 :   TEMPLATE_TYPE_PARM_INDEX (t2) = copy_node (TEMPLATE_TYPE_PARM_INDEX (t));
    3048       334469 :   TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (t2)) = decl;
    3049       334469 :   TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t2)
    3050       668938 :     = build_template_info (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t), newargs);
    3051              : 
    3052       334469 :   TREE_TYPE (decl) = t2;
    3053       334469 :   TYPE_NAME (t2) = decl;
    3054       334469 :   TYPE_STUB_DECL (t2) = decl;
    3055       334469 :   TYPE_SIZE (t2) = 0;
    3056              : 
    3057       334469 :   if (any_template_arguments_need_structural_equality_p (newargs))
    3058           13 :     SET_TYPE_STRUCTURAL_EQUALITY (t2);
    3059              :   else
    3060       334456 :     TYPE_CANONICAL (t2) = canonical_type_parameter (t2);
    3061              : 
    3062       334469 :   return t2;
    3063              : }
    3064              : 
    3065              : /* Called from count_trees via walk_tree.  */
    3066              : 
    3067              : static tree
    3068            0 : count_trees_r (tree *tp, int *walk_subtrees, void *data)
    3069              : {
    3070            0 :   ++*((int *) data);
    3071              : 
    3072            0 :   if (TYPE_P (*tp))
    3073            0 :     *walk_subtrees = 0;
    3074              : 
    3075            0 :   return NULL_TREE;
    3076              : }
    3077              : 
    3078              : /* Debugging function for measuring the rough complexity of a tree
    3079              :    representation.  */
    3080              : 
    3081              : int
    3082            0 : count_trees (tree t)
    3083              : {
    3084            0 :   int n_trees = 0;
    3085            0 :   cp_walk_tree_without_duplicates (&t, count_trees_r, &n_trees);
    3086            0 :   return n_trees;
    3087              : }
    3088              : 
    3089              : /* Called from verify_stmt_tree via walk_tree.  */
    3090              : 
    3091              : static tree
    3092       600157 : verify_stmt_tree_r (tree* tp, int * /*walk_subtrees*/, void* data)
    3093              : {
    3094       600157 :   tree t = *tp;
    3095       600157 :   hash_table<nofree_ptr_hash <tree_node> > *statements
    3096              :       = static_cast <hash_table<nofree_ptr_hash <tree_node> > *> (data);
    3097       600157 :   tree_node **slot;
    3098              : 
    3099       600157 :   if (!STATEMENT_CODE_P (TREE_CODE (t)))
    3100              :     return NULL_TREE;
    3101              : 
    3102              :   /* If this statement is already present in the hash table, then
    3103              :      there is a circularity in the statement tree.  */
    3104        32302 :   gcc_assert (!statements->find (t));
    3105              : 
    3106        32302 :   slot = statements->find_slot (t, INSERT);
    3107        32302 :   *slot = t;
    3108              : 
    3109        32302 :   return NULL_TREE;
    3110              : }
    3111              : 
    3112              : /* Debugging function to check that the statement T has not been
    3113              :    corrupted.  For now, this function simply checks that T contains no
    3114              :    circularities.  */
    3115              : 
    3116              : void
    3117         1589 : verify_stmt_tree (tree t)
    3118              : {
    3119         1589 :   hash_table<nofree_ptr_hash <tree_node> > statements (37);
    3120         1589 :   cp_walk_tree (&t, verify_stmt_tree_r, &statements, NULL);
    3121         1589 : }
    3122              : 
    3123              : /* Check if the type T depends on a type with no linkage and if so,
    3124              :    return it.  If RELAXED_P then do not consider a class type declared
    3125              :    within a vague-linkage function or in a module CMI to have no linkage,
    3126              :    since it can still be accessed within a different TU.  Remember:
    3127              :    no-linkage is not the same as internal-linkage.  */
    3128              : 
    3129              : tree
    3130    377766360 : no_linkage_check (tree t, bool relaxed_p)
    3131              : {
    3132    377766360 :   tree r;
    3133              : 
    3134              :   /* Lambda types that don't have mangling scope have no linkage.  We
    3135              :      check CLASSTYPE_LAMBDA_EXPR for error_mark_node because
    3136              :      when we get here from pushtag none of the lambda information is
    3137              :      set up yet, so we want to assume that the lambda has linkage and
    3138              :      fix it up later if not.  We need to check this even in templates so
    3139              :      that we properly handle a lambda-expression in the signature.  */
    3140    419806910 :   if (LAMBDA_TYPE_P (t)
    3141    381976574 :       && CLASSTYPE_LAMBDA_EXPR (t) != error_mark_node)
    3142              :     {
    3143      2429660 :       tree extra = LAMBDA_TYPE_EXTRA_SCOPE (t);
    3144      2429660 :       if (!extra)
    3145              :         return t;
    3146              :     }
    3147              : 
    3148              :   /* Otherwise there's no point in checking linkage on template functions; we
    3149              :      can't know their complete types.  */
    3150    377764161 :   if (processing_template_decl)
    3151              :     return NULL_TREE;
    3152              : 
    3153    249107864 :   switch (TREE_CODE (t))
    3154              :     {
    3155    128831805 :     case RECORD_TYPE:
    3156    128831805 :       if (TYPE_PTRMEMFUNC_P (t))
    3157       120215 :         goto ptrmem;
    3158              :       /* Fall through.  */
    3159    129991817 :     case UNION_TYPE:
    3160    129991817 :       if (!CLASS_TYPE_P (t))
    3161              :         return NULL_TREE;
    3162              :       /* Fall through.  */
    3163    135043167 :     case ENUMERAL_TYPE:
    3164              :       /* Only treat unnamed types as having no linkage if they're at
    3165              :          namespace scope.  This is core issue 966.  */
    3166    275217389 :       if (TYPE_UNNAMED_P (t) && TYPE_NAMESPACE_SCOPE_P (t))
    3167              :         return t;
    3168              : 
    3169    134328209 :       for (r = CP_TYPE_CONTEXT (t); ; )
    3170              :         {
    3171              :           /* If we're a nested type of a !TREE_PUBLIC class, we might not
    3172              :              have linkage, or we might just be in an anonymous namespace.
    3173              :              If we're in a TREE_PUBLIC class, we have linkage.  */
    3174    137644045 :           if (TYPE_P (r) && !TREE_PUBLIC (TYPE_NAME (r)))
    3175        77185 :             return no_linkage_check (TYPE_CONTEXT (t), relaxed_p);
    3176    137566860 :           else if (TREE_CODE (r) == FUNCTION_DECL)
    3177              :             {
    3178      3986449 :               if (relaxed_p
    3179      3986449 :                   && (vague_linkage_p (r)
    3180         6981 :                       || (TREE_PUBLIC (r) && module_maybe_has_cmi_p ())))
    3181      3315836 :                 r = CP_DECL_CONTEXT (r);
    3182              :               else
    3183       670613 :                 return t;
    3184              :             }
    3185              :           else
    3186              :             break;
    3187              :         }
    3188              : 
    3189              :       return NULL_TREE;
    3190              : 
    3191     31736310 :     case ARRAY_TYPE:
    3192     31736310 :     case POINTER_TYPE:
    3193     31736310 :     case REFERENCE_TYPE:
    3194     31736310 :     case VECTOR_TYPE:
    3195     31736310 :       return no_linkage_check (TREE_TYPE (t), relaxed_p);
    3196              : 
    3197       123107 :     case OFFSET_TYPE:
    3198       123107 :     ptrmem:
    3199       123107 :       r = no_linkage_check (TYPE_PTRMEM_POINTED_TO_TYPE (t),
    3200              :                             relaxed_p);
    3201       123107 :       if (r)
    3202              :         return r;
    3203       123107 :       return no_linkage_check (TYPE_PTRMEM_CLASS_TYPE (t), relaxed_p);
    3204              : 
    3205     28705460 :     case METHOD_TYPE:
    3206     28705460 :     case FUNCTION_TYPE:
    3207     28705460 :       {
    3208     28705460 :         tree parm = TYPE_ARG_TYPES (t);
    3209     28705460 :         if (TREE_CODE (t) == METHOD_TYPE)
    3210              :           /* The 'this' pointer isn't interesting; a method has the same
    3211              :              linkage (or lack thereof) as its enclosing class.  */
    3212     15842066 :           parm = TREE_CHAIN (parm);
    3213     35352565 :         for (;
    3214     64058025 :              parm && parm != void_list_node;
    3215     35352565 :              parm = TREE_CHAIN (parm))
    3216              :           {
    3217     36009392 :             r = no_linkage_check (TREE_VALUE (parm), relaxed_p);
    3218     36009392 :             if (r)
    3219              :               return r;
    3220              :           }
    3221     28048633 :         return no_linkage_check (TREE_TYPE (t), relaxed_p);
    3222              :       }
    3223              : 
    3224              :     default:
    3225              :       return NULL_TREE;
    3226              :     }
    3227              : }
    3228              : 
    3229              : extern int depth_reached;
    3230              : 
    3231              : void
    3232            0 : cxx_print_statistics (void)
    3233              : {
    3234            0 :   print_template_statistics ();
    3235            0 :   if (GATHER_STATISTICS)
    3236              :     fprintf (stderr, "maximum template instantiation depth reached: %d\n",
    3237              :              depth_reached);
    3238            0 : }
    3239              : 
    3240              : /* Return, as an INTEGER_CST node, the number of elements for TYPE
    3241              :    (which is an ARRAY_TYPE).  This one is a recursive count of all
    3242              :    ARRAY_TYPEs that are clumped together.  */
    3243              : 
    3244              : tree
    3245         4750 : array_type_nelts_total (tree type)
    3246              : {
    3247         4750 :   tree sz = array_type_nelts_top (type);
    3248         4750 :   type = TREE_TYPE (type);
    3249         5010 :   while (TREE_CODE (type) == ARRAY_TYPE)
    3250              :     {
    3251          260 :       tree n = array_type_nelts_top (type);
    3252          260 :       sz = fold_build2_loc (input_location,
    3253              :                         MULT_EXPR, sizetype, sz, n);
    3254          260 :       type = TREE_TYPE (type);
    3255              :     }
    3256         4750 :   return sz;
    3257              : }
    3258              : 
    3259              : struct bot_data
    3260              : {
    3261              :   splay_tree target_remap;
    3262              :   bool clear_location;
    3263              : };
    3264              : 
    3265              : /* Called from break_out_target_exprs via mapcar.  */
    3266              : 
    3267              : static tree
    3268     50390842 : bot_manip (tree* tp, int* walk_subtrees, void* data_)
    3269              : {
    3270     50390842 :   bot_data &data = *(bot_data*)data_;
    3271     50390842 :   splay_tree target_remap = data.target_remap;
    3272     50390842 :   tree t = *tp;
    3273              : 
    3274     50390842 :   if (!TYPE_P (t) && TREE_CONSTANT (t) && !TREE_SIDE_EFFECTS (t))
    3275              :     {
    3276              :       /* There can't be any TARGET_EXPRs or their slot variables below this
    3277              :          point.  But we must make a copy, in case subsequent processing
    3278              :          alters any part of it.  For example, during gimplification a cast
    3279              :          of the form (T) &X::f (where "f" is a member function) will lead
    3280              :          to replacing the PTRMEM_CST for &X::f with a VAR_DECL.  */
    3281     18770231 :       *walk_subtrees = 0;
    3282     18770231 :       *tp = unshare_expr (t);
    3283     18770231 :       return NULL_TREE;
    3284              :     }
    3285     31620611 :   if (TREE_CODE (t) == TARGET_EXPR)
    3286              :     {
    3287       867209 :       tree u;
    3288              : 
    3289       867209 :       if (TREE_CODE (TARGET_EXPR_INITIAL (t)) == AGGR_INIT_EXPR)
    3290              :         {
    3291       507488 :           u = build_cplus_new (TREE_TYPE (t), TARGET_EXPR_INITIAL (t),
    3292              :                                tf_warning_or_error);
    3293       507488 :           if (u == error_mark_node)
    3294              :             return u;
    3295       507488 :           if (AGGR_INIT_ZERO_FIRST (TARGET_EXPR_INITIAL (t)))
    3296         1297 :             AGGR_INIT_ZERO_FIRST (TARGET_EXPR_INITIAL (u)) = true;
    3297              :         }
    3298              :       else
    3299       359721 :         u = force_target_expr (TREE_TYPE (t), TARGET_EXPR_INITIAL (t),
    3300              :                                tf_warning_or_error);
    3301              : 
    3302       867209 :       TARGET_EXPR_IMPLICIT_P (u) = TARGET_EXPR_IMPLICIT_P (t);
    3303       867209 :       TARGET_EXPR_LIST_INIT_P (u) = TARGET_EXPR_LIST_INIT_P (t);
    3304       867209 :       TARGET_EXPR_DIRECT_INIT_P (u) = TARGET_EXPR_DIRECT_INIT_P (t);
    3305       867209 :       TARGET_EXPR_ELIDING_P (u) = TARGET_EXPR_ELIDING_P (t);
    3306       867209 :       TREE_CONSTANT (u) = TREE_CONSTANT (t);
    3307              : 
    3308              :       /* Map the old variable to the new one.  */
    3309      2601627 :       splay_tree_insert (target_remap,
    3310       867209 :                          (splay_tree_key) TARGET_EXPR_SLOT (t),
    3311       867209 :                          (splay_tree_value) TARGET_EXPR_SLOT (u));
    3312              : 
    3313       867209 :       TARGET_EXPR_INITIAL (u) = break_out_target_exprs (TARGET_EXPR_INITIAL (u),
    3314       867209 :                                                         data.clear_location);
    3315       867209 :       if (TARGET_EXPR_INITIAL (u) == error_mark_node)
    3316              :         return error_mark_node;
    3317              : 
    3318       867209 :       if (data.clear_location)
    3319       434822 :         SET_EXPR_LOCATION (u, input_location);
    3320              : 
    3321              :       /* Replace the old expression with the new version.  */
    3322       867209 :       *tp = u;
    3323              :       /* We don't have to go below this point; the recursive call to
    3324              :          break_out_target_exprs will have handled anything below this
    3325              :          point.  */
    3326       867209 :       *walk_subtrees = 0;
    3327       867209 :       return NULL_TREE;
    3328              :     }
    3329     30753402 :   if (TREE_CODE (*tp) == SAVE_EXPR)
    3330              :     {
    3331       101109 :       t = *tp;
    3332       101109 :       splay_tree_node n = splay_tree_lookup (target_remap,
    3333              :                                              (splay_tree_key) t);
    3334       101109 :       if (n)
    3335              :         {
    3336        50874 :           *tp = (tree)n->value;
    3337        50874 :           *walk_subtrees = 0;
    3338              :         }
    3339              :       else
    3340              :         {
    3341        50235 :           copy_tree_r (tp, walk_subtrees, NULL);
    3342        50235 :           splay_tree_insert (target_remap,
    3343              :                              (splay_tree_key)t,
    3344        50235 :                              (splay_tree_value)*tp);
    3345              :           /* Make sure we don't remap an already-remapped SAVE_EXPR.  */
    3346        50235 :           splay_tree_insert (target_remap,
    3347              :                              (splay_tree_key)*tp,
    3348        50235 :                              (splay_tree_value)*tp);
    3349              :         }
    3350       101109 :       return NULL_TREE;
    3351              :     }
    3352     30652293 :   if (TREE_CODE (*tp) == DECL_EXPR
    3353          199 :       && VAR_P (DECL_EXPR_DECL (*tp))
    3354          199 :       && DECL_ARTIFICIAL (DECL_EXPR_DECL (*tp))
    3355     30652492 :       && !TREE_STATIC (DECL_EXPR_DECL (*tp)))
    3356              :     {
    3357          199 :       tree t;
    3358          199 :       splay_tree_node n
    3359          398 :         = splay_tree_lookup (target_remap,
    3360          199 :                              (splay_tree_key) DECL_EXPR_DECL (*tp));
    3361          199 :       if (n)
    3362            1 :         t = (tree) n->value;
    3363              :       else
    3364              :         {
    3365          198 :           t = create_temporary_var (TREE_TYPE (DECL_EXPR_DECL (*tp)));
    3366          198 :           DECL_INITIAL (t) = DECL_INITIAL (DECL_EXPR_DECL (*tp));
    3367          396 :           splay_tree_insert (target_remap,
    3368          198 :                              (splay_tree_key) DECL_EXPR_DECL (*tp),
    3369              :                              (splay_tree_value) t);
    3370              :         }
    3371          199 :       copy_tree_r (tp, walk_subtrees, NULL);
    3372          199 :       DECL_EXPR_DECL (*tp) = t;
    3373          199 :       if (data.clear_location && EXPR_HAS_LOCATION (*tp))
    3374           12 :         SET_EXPR_LOCATION (*tp, input_location);
    3375          199 :       return NULL_TREE;
    3376              :     }
    3377     30652094 :   if (TREE_CODE (*tp) == BIND_EXPR && BIND_EXPR_VARS (*tp))
    3378              :     {
    3379            1 :       copy_tree_r (tp, walk_subtrees, NULL);
    3380            2 :       for (tree *p = &BIND_EXPR_VARS (*tp); *p; p = &DECL_CHAIN (*p))
    3381              :         {
    3382            1 :           gcc_assert (VAR_P (*p) && DECL_ARTIFICIAL (*p) && !TREE_STATIC (*p));
    3383            1 :           tree t = create_temporary_var (TREE_TYPE (*p));
    3384            1 :           DECL_INITIAL (t) = DECL_INITIAL (*p);
    3385            1 :           DECL_CHAIN (t) = DECL_CHAIN (*p);
    3386            1 :           splay_tree_insert (target_remap, (splay_tree_key) *p,
    3387              :                              (splay_tree_value) t);
    3388            1 :           *p = t;
    3389              :         }
    3390            1 :       if (data.clear_location && EXPR_HAS_LOCATION (*tp))
    3391            0 :         SET_EXPR_LOCATION (*tp, input_location);
    3392            1 :       return NULL_TREE;
    3393              :     }
    3394              : 
    3395              :   /* Make a copy of this node.  */
    3396     30652093 :   t = copy_tree_r (tp, walk_subtrees, NULL);
    3397     30652093 :   if (TREE_CODE (*tp) == CALL_EXPR || TREE_CODE (*tp) == AGGR_INIT_EXPR)
    3398      4155032 :     if (!processing_template_decl)
    3399      4155032 :       set_flags_from_callee (*tp);
    3400     30652093 :   if (data.clear_location && EXPR_HAS_LOCATION (*tp))
    3401      3622238 :     SET_EXPR_LOCATION (*tp, input_location);
    3402              :   return t;
    3403              : }
    3404              : 
    3405              : /* Replace all remapped VAR_DECLs in T with their new equivalents.
    3406              :    DATA is really a splay-tree mapping old variables to new
    3407              :    variables.  */
    3408              : 
    3409              : static tree
    3410     73197063 : bot_replace (tree* t, int */*walk_subtrees*/, void* data_)
    3411              : {
    3412     73197063 :   bot_data &data = *(bot_data*)data_;
    3413     73197063 :   splay_tree target_remap = data.target_remap;
    3414              : 
    3415     73197063 :   if (VAR_P (*t))
    3416              :     {
    3417      2834927 :       splay_tree_node n = splay_tree_lookup (target_remap,
    3418              :                                              (splay_tree_key) *t);
    3419      2834927 :       if (n)
    3420         2173 :         *t = (tree) n->value;
    3421              :     }
    3422     70362136 :   else if (TREE_CODE (*t) == PARM_DECL
    3423      6282701 :            && DECL_NAME (*t) == this_identifier
    3424     72596821 :            && !DECL_CONTEXT (*t))
    3425              :     {
    3426              :       /* In an NSDMI we need to replace the 'this' parameter we used for
    3427              :          parsing with the real one for this function.  */
    3428        23444 :       *t = current_class_ptr;
    3429              :     }
    3430     70338692 :   else if (TREE_CODE (*t) == CONVERT_EXPR
    3431     70338692 :            && CONVERT_EXPR_VBASE_PATH (*t))
    3432              :     {
    3433              :       /* In an NSDMI build_base_path defers building conversions to morally
    3434              :          virtual bases, and we handle it here.  */
    3435           63 :       tree basetype = TREE_TYPE (*t);
    3436           63 :       *t = convert_to_base (TREE_OPERAND (*t, 0), basetype,
    3437              :                             /*check_access=*/false, /*nonnull=*/true,
    3438              :                             tf_warning_or_error);
    3439              :     }
    3440              : 
    3441     73197063 :   return NULL_TREE;
    3442              : }
    3443              : 
    3444              : /* When we parse a default argument expression, we may create
    3445              :    temporary variables via TARGET_EXPRs.  When we actually use the
    3446              :    default-argument expression, we make a copy of the expression
    3447              :    and replace the temporaries with appropriate local versions.
    3448              : 
    3449              :    If CLEAR_LOCATION is true, override any EXPR_LOCATION with
    3450              :    input_location.  */
    3451              : 
    3452              : tree
    3453     14978077 : break_out_target_exprs (tree t, bool clear_location /* = false */)
    3454              : {
    3455     14978077 :   static int target_remap_count;
    3456     14978077 :   static splay_tree target_remap;
    3457              : 
    3458              :   /* We shouldn't be called on templated trees, nor do we want to
    3459              :      produce them.  */
    3460     14978077 :   gcc_checking_assert (!processing_template_decl);
    3461              : 
    3462     14978077 :   if (!target_remap_count++)
    3463     14110868 :     target_remap = splay_tree_new (splay_tree_compare_pointers,
    3464              :                                    /*splay_tree_delete_key_fn=*/NULL,
    3465              :                                    /*splay_tree_delete_value_fn=*/NULL);
    3466     14978077 :   bot_data data = { target_remap, clear_location };
    3467     14978077 :   if (cp_walk_tree (&t, bot_manip, &data, NULL) == error_mark_node)
    3468            0 :     t = error_mark_node;
    3469     14978077 :   if (cp_walk_tree (&t, bot_replace, &data, NULL) == error_mark_node)
    3470            0 :     t = error_mark_node;
    3471              : 
    3472     14978077 :   if (!--target_remap_count)
    3473              :     {
    3474     14110868 :       splay_tree_delete (target_remap);
    3475     14110868 :       target_remap = NULL;
    3476              :     }
    3477              : 
    3478     14978077 :   return t;
    3479              : }
    3480              : 
    3481              : /* Build an expression for the subobject of OBJ at CONSTRUCTOR index INDEX,
    3482              :    which we expect to have type TYPE.  */
    3483              : 
    3484              : tree
    3485       517314 : build_ctor_subob_ref (tree index, tree type, tree obj)
    3486              : {
    3487       517314 :   if (index == NULL_TREE)
    3488              :     /* Can't refer to a particular member of a vector.  */
    3489              :     obj = NULL_TREE;
    3490       517314 :   else if (TREE_CODE (index) == INTEGER_CST)
    3491        21578 :     obj = cp_build_array_ref (input_location, obj, index, tf_none);
    3492              :   else
    3493       495736 :     obj = build_class_member_access_expr (obj, index, NULL_TREE,
    3494              :                                           /*reference*/false, tf_none);
    3495       517314 :   if (obj)
    3496              :     {
    3497       517314 :       tree objtype = TREE_TYPE (obj);
    3498       517314 :       if (TREE_CODE (objtype) == ARRAY_TYPE && !TYPE_DOMAIN (objtype))
    3499              :         {
    3500              :           /* When the destination object refers to a flexible array member
    3501              :              verify that it matches the type of the source object except
    3502              :              for its domain and qualifiers.  */
    3503           83 :           gcc_assert (comptypes (TYPE_MAIN_VARIANT (type),
    3504              :                                  TYPE_MAIN_VARIANT (objtype),
    3505              :                                  COMPARE_REDECLARATION));
    3506              :         }
    3507              :       else
    3508       517231 :         gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, objtype));
    3509              :     }
    3510              : 
    3511       517314 :   return obj;
    3512              : }
    3513              : 
    3514              : struct replace_placeholders_t
    3515              : {
    3516              :   tree obj;         /* The object to be substituted for a PLACEHOLDER_EXPR.  */
    3517              :   tree exp;         /* The outermost exp.  */
    3518              :   bool seen;        /* Whether we've encountered a PLACEHOLDER_EXPR.  */
    3519              :   hash_set<tree> *pset;   /* To avoid walking same trees multiple times.  */
    3520              : };
    3521              : 
    3522              : /* Like substitute_placeholder_in_expr, but handle C++ tree codes and
    3523              :    build up subexpressions as we go deeper.  */
    3524              : 
    3525              : static tree
    3526     33325833 : replace_placeholders_r (tree* t, int* walk_subtrees, void* data_)
    3527              : {
    3528     33325833 :   replace_placeholders_t *d = static_cast<replace_placeholders_t*>(data_);
    3529     33325833 :   tree obj = d->obj;
    3530              : 
    3531     33325833 :   if (TYPE_P (*t) || TREE_CONSTANT (*t))
    3532              :     {
    3533     10715937 :       *walk_subtrees = false;
    3534     10715937 :       return NULL_TREE;
    3535              :     }
    3536              : 
    3537     22609896 :   switch (TREE_CODE (*t))
    3538              :     {
    3539              :     case PLACEHOLDER_EXPR:
    3540              :       {
    3541              :         tree x = obj;
    3542          635 :         for (; !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (*t),
    3543          635 :                                                            TREE_TYPE (x));
    3544           77 :              x = TREE_OPERAND (x, 0))
    3545           77 :           gcc_assert (handled_component_p (x));
    3546          558 :         *t = unshare_expr (x);
    3547          558 :         *walk_subtrees = false;
    3548          558 :         d->seen = true;
    3549              :       }
    3550          558 :       break;
    3551              : 
    3552       703248 :     case CONSTRUCTOR:
    3553       703248 :       {
    3554       703248 :         constructor_elt *ce;
    3555       703248 :         vec<constructor_elt,va_gc> *v = CONSTRUCTOR_ELTS (*t);
    3556              :         /* Don't walk into CONSTRUCTOR_PLACEHOLDER_BOUNDARY ctors
    3557              :            other than the d->exp one, those have PLACEHOLDER_EXPRs
    3558              :            related to another object.  */
    3559       703248 :         if ((CONSTRUCTOR_PLACEHOLDER_BOUNDARY (*t)
    3560          621 :              && *t != d->exp)
    3561       703764 :             || d->pset->add (*t))
    3562              :           {
    3563          105 :             *walk_subtrees = false;
    3564          105 :             return NULL_TREE;
    3565              :           }
    3566      2419190 :         for (unsigned i = 0; vec_safe_iterate (v, i, &ce); ++i)
    3567              :           {
    3568      1716047 :             tree *valp = &ce->value;
    3569      1716047 :             tree type = TREE_TYPE (*valp);
    3570      1716047 :             tree subob = obj;
    3571              : 
    3572              :             /* Elements with RANGE_EXPR index shouldn't have any
    3573              :                placeholders in them.  */
    3574      1716047 :             if (ce->index && TREE_CODE (ce->index) == RANGE_EXPR)
    3575            2 :               continue;
    3576              : 
    3577      1716045 :             if (TREE_CODE (*valp) == CONSTRUCTOR
    3578         1883 :                 && AGGREGATE_TYPE_P (type))
    3579              :               {
    3580              :                 /* If we're looking at the initializer for OBJ, then build
    3581              :                    a sub-object reference.  If we're looking at an
    3582              :                    initializer for another object, just pass OBJ down.  */
    3583         1869 :                 if (same_type_ignoring_top_level_qualifiers_p
    3584         1869 :                     (TREE_TYPE (*t), TREE_TYPE (obj)))
    3585         1836 :                   subob = build_ctor_subob_ref (ce->index, type, obj);
    3586         1869 :                 if (TREE_CODE (*valp) == TARGET_EXPR)
    3587            0 :                   valp = &TARGET_EXPR_INITIAL (*valp);
    3588              :               }
    3589      1716045 :             d->obj = subob;
    3590      1716045 :             cp_walk_tree (valp, replace_placeholders_r, data_, NULL);
    3591      1716045 :             d->obj = obj;
    3592              :           }
    3593       703143 :         *walk_subtrees = false;
    3594       703143 :         break;
    3595              :       }
    3596              : 
    3597     21906090 :     default:
    3598     21906090 :       if (d->pset->add (*t))
    3599       717614 :         *walk_subtrees = false;
    3600              :       break;
    3601              :     }
    3602              : 
    3603              :   return NULL_TREE;
    3604              : }
    3605              : 
    3606              : /* Replace PLACEHOLDER_EXPRs in EXP with object OBJ.  SEEN_P is set if
    3607              :    a PLACEHOLDER_EXPR has been encountered.  */
    3608              : 
    3609              : tree
    3610     72865460 : replace_placeholders (tree exp, tree obj, bool *seen_p /*= NULL*/)
    3611              : {
    3612              :   /* This is only relevant for C++14.  */
    3613     72865460 :   if (cxx_dialect < cxx14)
    3614       868633 :     return exp;
    3615              : 
    3616              :   /* If the object isn't a (member of a) class, do nothing.  */
    3617              :   tree op0 = obj;
    3618     72606483 :   while (handled_component_p (op0))
    3619       609656 :     op0 = TREE_OPERAND (op0, 0);
    3620     71996827 :   if (!CLASS_TYPE_P (strip_array_types (TREE_TYPE (op0))))
    3621     64574406 :     return exp;
    3622              : 
    3623      7422421 :   tree *tp = &exp;
    3624      7422421 :   if (TREE_CODE (exp) == TARGET_EXPR)
    3625       969604 :     tp = &TARGET_EXPR_INITIAL (exp);
    3626      7422421 :   hash_set<tree> pset;
    3627      7422421 :   replace_placeholders_t data = { obj, *tp, false, &pset };
    3628      7422421 :   cp_walk_tree (tp, replace_placeholders_r, &data, NULL);
    3629      7422421 :   if (seen_p)
    3630       193970 :     *seen_p = data.seen;
    3631      7422421 :   return exp;
    3632      7422421 : }
    3633              : 
    3634              : /* Callback function for find_placeholders.  */
    3635              : 
    3636              : static tree
    3637      3076895 : find_placeholders_r (tree *t, int *walk_subtrees, void *)
    3638              : {
    3639      3076895 :   if (TYPE_P (*t) || TREE_CONSTANT (*t))
    3640              :     {
    3641      1492839 :       *walk_subtrees = false;
    3642      1492839 :       return NULL_TREE;
    3643              :     }
    3644              : 
    3645      1584056 :   switch (TREE_CODE (*t))
    3646              :     {
    3647              :     case PLACEHOLDER_EXPR:
    3648              :       return *t;
    3649              : 
    3650          604 :     case CONSTRUCTOR:
    3651          604 :       if (CONSTRUCTOR_PLACEHOLDER_BOUNDARY (*t))
    3652          173 :         *walk_subtrees = false;
    3653              :       break;
    3654              : 
    3655              :     default:
    3656              :       break;
    3657              :     }
    3658              : 
    3659              :   return NULL_TREE;
    3660              : }
    3661              : 
    3662              : /* Return true if EXP contains a PLACEHOLDER_EXPR.  Don't walk into
    3663              :    ctors with CONSTRUCTOR_PLACEHOLDER_BOUNDARY flag set.  */
    3664              : 
    3665              : bool
    3666       302712 : find_placeholders (tree exp)
    3667              : {
    3668              :   /* This is only relevant for C++14.  */
    3669       302712 :   if (cxx_dialect < cxx14)
    3670              :     return false;
    3671              : 
    3672       302712 :   return cp_walk_tree_without_duplicates (&exp, find_placeholders_r, NULL);
    3673              : }
    3674              : 
    3675              : /* Similar to `build_nt', but for template definitions of dependent
    3676              :    expressions  */
    3677              : 
    3678              : tree
    3679    316089363 : build_min_nt_loc (location_t loc, enum tree_code code, ...)
    3680              : {
    3681    316089363 :   tree t;
    3682    316089363 :   int length;
    3683    316089363 :   int i;
    3684    316089363 :   va_list p;
    3685              : 
    3686    316089363 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    3687              : 
    3688    316089363 :   va_start (p, code);
    3689              : 
    3690    316089363 :   t = make_node (code);
    3691    316089363 :   SET_EXPR_LOCATION (t, loc);
    3692    316089363 :   length = TREE_CODE_LENGTH (code);
    3693              : 
    3694   1038916518 :   for (i = 0; i < length; i++)
    3695    722827155 :     TREE_OPERAND (t, i) = va_arg (p, tree);
    3696              : 
    3697    316089363 :   va_end (p);
    3698    316089363 :   return t;
    3699              : }
    3700              : 
    3701              : /* Similar to `build', but for template definitions.  */
    3702              : 
    3703              : tree
    3704    256095946 : build_min (enum tree_code code, tree tt, ...)
    3705              : {
    3706    256095946 :   tree t;
    3707    256095946 :   int length;
    3708    256095946 :   int i;
    3709    256095946 :   va_list p;
    3710              : 
    3711    256095946 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    3712              : 
    3713    256095946 :   va_start (p, tt);
    3714              : 
    3715    256095946 :   t = make_node (code);
    3716    256095946 :   length = TREE_CODE_LENGTH (code);
    3717    256095946 :   TREE_TYPE (t) = tt;
    3718              : 
    3719    684962656 :   for (i = 0; i < length; i++)
    3720              :     {
    3721    428866710 :       tree x = va_arg (p, tree);
    3722    428866710 :       TREE_OPERAND (t, i) = x;
    3723    428866710 :       if (x && !TYPE_P (x) && TREE_SIDE_EFFECTS (x))
    3724      3189485 :         TREE_SIDE_EFFECTS (t) = 1;
    3725              :     }
    3726              : 
    3727    256095946 :   va_end (p);
    3728              : 
    3729    256095946 :   return t;
    3730              : }
    3731              : 
    3732              : /* Similar to `build', but for template definitions of non-dependent
    3733              :    expressions. NON_DEP is the non-dependent expression that has been
    3734              :    built.  */
    3735              : 
    3736              : tree
    3737    122060489 : build_min_non_dep (enum tree_code code, tree non_dep, ...)
    3738              : {
    3739    122060489 :   tree t;
    3740    122060489 :   int length;
    3741    122060489 :   int i;
    3742    122060489 :   va_list p;
    3743              : 
    3744    122060489 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    3745              : 
    3746    122060489 :   va_start (p, non_dep);
    3747              : 
    3748    122060489 :   if (REFERENCE_REF_P (non_dep))
    3749      1261033 :     non_dep = TREE_OPERAND (non_dep, 0);
    3750              : 
    3751    122060489 :   t = make_node (code);
    3752    163779206 :   SET_EXPR_LOCATION (t, cp_expr_loc_or_input_loc (non_dep));
    3753    122060489 :   length = TREE_CODE_LENGTH (code);
    3754    122060489 :   TREE_TYPE (t) = unlowered_expr_type (non_dep);
    3755    122060489 :   TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep);
    3756              : 
    3757    428852315 :   for (i = 0; i < length; i++)
    3758              :     {
    3759    306791826 :       tree x = va_arg (p, tree);
    3760    306791826 :       TREE_OPERAND (t, i) = x;
    3761    306791826 :       if (x && !TYPE_P (x))
    3762    241023763 :         TREE_SIDE_EFFECTS (t) |= TREE_SIDE_EFFECTS (x);
    3763              :     }
    3764              : 
    3765    122060489 :   va_end (p);
    3766    122060489 :   return convert_from_reference (t);
    3767              : }
    3768              : 
    3769              : /* Similar to build_min_nt, but call expressions  */
    3770              : 
    3771              : tree
    3772    217614143 : build_min_nt_call_vec (tree fn, vec<tree, va_gc> *args)
    3773              : {
    3774    217614143 :   tree ret, t;
    3775    217614143 :   unsigned int ix;
    3776              : 
    3777    435093001 :   ret = build_vl_exp (CALL_EXPR, vec_safe_length (args) + 3);
    3778    217614143 :   CALL_EXPR_FN (ret) = fn;
    3779    217614143 :   CALL_EXPR_STATIC_CHAIN (ret) = NULL_TREE;
    3780    459222316 :   FOR_EACH_VEC_SAFE_ELT (args, ix, t)
    3781    483216346 :     CALL_EXPR_ARG (ret, ix) = t;
    3782              : 
    3783    217614143 :   return ret;
    3784              : }
    3785              : 
    3786              : /* Similar to `build_min_nt_call_vec', but for template definitions of
    3787              :    non-dependent expressions. NON_DEP is the non-dependent expression
    3788              :    that has been built.  */
    3789              : 
    3790              : tree
    3791     13739678 : build_min_non_dep_call_vec (tree non_dep, tree fn, vec<tree, va_gc> *argvec)
    3792              : {
    3793     13739678 :   tree t = build_min_nt_call_vec (fn, argvec);
    3794     13739678 :   if (REFERENCE_REF_P (non_dep))
    3795            6 :     non_dep = TREE_OPERAND (non_dep, 0);
    3796     13739678 :   TREE_TYPE (t) = TREE_TYPE (non_dep);
    3797     13739678 :   TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep);
    3798     13739678 :   if (argvec)
    3799     27574483 :     for (tree x : *argvec)
    3800     13970090 :       if (x && !TYPE_P (x))
    3801     13970090 :         TREE_SIDE_EFFECTS (t) |= TREE_SIDE_EFFECTS (x);
    3802     13739678 :   return convert_from_reference (t);
    3803              : }
    3804              : 
    3805              : /* Similar to build_min_non_dep, but for expressions that have been resolved to
    3806              :    a call to an operator overload.  OP is the operator that has been
    3807              :    overloaded.  NON_DEP is the non-dependent expression that's been built,
    3808              :    which should be a CALL_EXPR or an INDIRECT_REF to a CALL_EXPR.  OVERLOAD is
    3809              :    the overload that NON_DEP is calling.  */
    3810              : 
    3811              : tree
    3812      6322815 : build_min_non_dep_op_overload (enum tree_code op,
    3813              :                                tree non_dep,
    3814              :                                tree overload, ...)
    3815              : {
    3816      6322815 :   va_list p;
    3817      6322815 :   int nargs, expected_nargs;
    3818      6322815 :   tree fn, call, obj = NULL_TREE;
    3819              : 
    3820      6322815 :   releasing_vec args;
    3821      6322815 :   va_start (p, overload);
    3822              : 
    3823      6322815 :   bool negated = false, rewritten = false, reversed = false;
    3824      6322815 :   if (cxx_dialect >= cxx20 && TREE_CODE (overload) == TREE_LIST)
    3825              :     {
    3826              :       /* Handle rebuilding a C++20 rewritten comparison operator expression,
    3827              :          e.g. !(x == y), y <=> x, (x <=> y) @ 0 etc, that resolved to a call
    3828              :          to a user-defined operator<=>/==.  */
    3829       552708 :       gcc_checking_assert (TREE_CODE_CLASS (op) == tcc_comparison
    3830              :                            || op == SPACESHIP_EXPR);
    3831       552708 :       int flags = TREE_INT_CST_LOW (TREE_PURPOSE (overload));
    3832       552708 :       if (TREE_CODE (non_dep) == TRUTH_NOT_EXPR)
    3833              :         {
    3834       507828 :           negated = true;
    3835       507828 :           non_dep = TREE_OPERAND (non_dep, 0);
    3836              :         }
    3837       552708 :       if (flags & LOOKUP_REWRITTEN)
    3838       552708 :         rewritten = true;
    3839       552708 :       if (flags & LOOKUP_REVERSED)
    3840           69 :         reversed = true;
    3841       552708 :       if (rewritten
    3842       552708 :           && DECL_OVERLOADED_OPERATOR_IS (TREE_VALUE (overload),
    3843              :                                           SPACESHIP_EXPR))
    3844              :         {
    3845              :           /* Handle (x <=> y) @ 0 and 0 @ (y <=> x) by recursing to first
    3846              :              rebuild the <=>.  Note that both OVERLOAD and the provided arguments
    3847              :              in this case already correspond to the selected operator<=>.  */
    3848              : 
    3849        44874 :           tree spaceship_non_dep = (TREE_CODE (non_dep) == CALL_EXPR
    3850        89685 :                                     ? CALL_EXPR_ARG (non_dep, reversed ? 1 : 0)
    3851        44886 :                                     : TREE_OPERAND (non_dep, reversed ? 1 : 0));
    3852        44874 :           gcc_checking_assert (TREE_CODE (spaceship_non_dep) == CALL_EXPR);
    3853        44874 :           tree spaceship_op0 = va_arg (p, tree);
    3854        44874 :           tree spaceship_op1 = va_arg (p, tree);
    3855        44874 :           if (reversed)
    3856           51 :             std::swap (spaceship_op0, spaceship_op1);
    3857              : 
    3858              :           /* Push the correct arguments for the operator OP expression, and
    3859              :              set OVERLOAD appropriately.  */
    3860        44874 :           tree op0 = build_min_non_dep_op_overload (SPACESHIP_EXPR,
    3861              :                                                     spaceship_non_dep,
    3862        44874 :                                                     TREE_VALUE (overload),
    3863              :                                                     spaceship_op0,
    3864        44874 :                                                     spaceship_op1);
    3865        44874 :           tree op1 = (TREE_CODE (non_dep) == CALL_EXPR
    3866        89712 :                       ? CALL_EXPR_ARG (non_dep, reversed ? 0 : 1)
    3867           39 :                       : TREE_OPERAND (non_dep, reversed ? 0 : 1));
    3868        44874 :           gcc_checking_assert (integer_zerop (op1));
    3869              : 
    3870        44874 :           if (TREE_CODE (non_dep) != CALL_EXPR)
    3871              :             {
    3872           27 :               gcc_checking_assert (COMPARISON_CLASS_P (non_dep)
    3873              :                                    || TREE_CODE (non_dep) == SPACESHIP_EXPR);
    3874           27 :               if (reversed)
    3875           15 :                 std::swap (op0, op1);
    3876           27 :               return build_min_non_dep (TREE_CODE (non_dep), non_dep, op0, op1);
    3877              :             }
    3878              : 
    3879        44847 :           vec_safe_push (args, op0);
    3880        44847 :           vec_safe_push (args, op1);
    3881        44847 :           overload = CALL_EXPR_FN (non_dep);
    3882              :         }
    3883              :       else
    3884       507834 :         overload = TREE_VALUE (overload);
    3885              :     }
    3886      6322788 :   non_dep = extract_call_expr (non_dep);
    3887              : 
    3888      6322788 :   nargs = call_expr_nargs (non_dep);
    3889              : 
    3890      6322788 :   expected_nargs = cp_tree_code_length (op);
    3891     11818292 :   if (DECL_OBJECT_MEMBER_FUNCTION_P (overload)
    3892              :       /* For ARRAY_REF, operator[] is either a non-static member or newly
    3893              :          static member, never out of class and for the static member case
    3894              :          if user uses single index the operator[] needs to have a single
    3895              :          argument as well, but the function is called with 2 - the object
    3896              :          it is invoked on and the index.  */
    3897     11816674 :       || op == ARRAY_REF)
    3898       828909 :     expected_nargs -= 1;
    3899      6322788 :   if ((op == POSTINCREMENT_EXPR
    3900      6322788 :        || op == POSTDECREMENT_EXPR)
    3901              :       /* With -fpermissive non_dep could be operator++().  */
    3902        10444 :       && (!flag_permissive || nargs != expected_nargs))
    3903        10441 :     expected_nargs += 1;
    3904      6322788 :   gcc_assert (nargs == expected_nargs);
    3905              : 
    3906      6322788 :   if (!DECL_OBJECT_MEMBER_FUNCTION_P (overload))
    3907              :     {
    3908      5493886 :       fn = overload;
    3909      5493886 :       if (vec_safe_length (args) != 0)
    3910              :         /* The correct arguments were already pushed above.  */
    3911        44847 :         gcc_checking_assert (rewritten);
    3912              :       else
    3913              :         {
    3914      5449039 :           if (op == ARRAY_REF)
    3915            7 :             obj = va_arg (p, tree);
    3916     16267475 :           for (int i = 0; i < nargs; i++)
    3917              :             {
    3918     10818436 :               tree arg = va_arg (p, tree);
    3919     10818436 :               vec_safe_push (args, arg);
    3920              :             }
    3921              :         }
    3922      5493886 :       if (reversed)
    3923           36 :         std::swap ((*args)[0], (*args)[1]);
    3924              :     }
    3925              :   else
    3926              :     {
    3927       828902 :       gcc_checking_assert (vec_safe_length (args) == 0);
    3928       828902 :       tree object = va_arg (p, tree);
    3929      1396777 :       for (int i = 0; i < nargs; i++)
    3930              :         {
    3931       567875 :           tree arg = va_arg (p, tree);
    3932       567875 :           vec_safe_push (args, arg);
    3933              :         }
    3934       828902 :       if (reversed)
    3935           18 :         std::swap (object, (*args)[0]);
    3936       828902 :       tree binfo = TYPE_BINFO (TREE_TYPE (object));
    3937       828902 :       tree method = build_baselink (binfo, binfo, overload, NULL_TREE);
    3938       828902 :       fn = build_min (COMPONENT_REF, TREE_TYPE (overload),
    3939              :                       object, method, NULL_TREE);
    3940              :     }
    3941              : 
    3942      6322788 :   va_end (p);
    3943      6322788 :   call = build_min_non_dep_call_vec (non_dep, fn, args);
    3944              : 
    3945      6322788 :   tree call_expr = extract_call_expr (call);
    3946      6322788 :   KOENIG_LOOKUP_P (call_expr) = KOENIG_LOOKUP_P (non_dep);
    3947      6322788 :   CALL_EXPR_OPERATOR_SYNTAX (call_expr) = true;
    3948      6322788 :   CALL_EXPR_ORDERED_ARGS (call_expr) = CALL_EXPR_ORDERED_ARGS (non_dep);
    3949      6322788 :   CALL_EXPR_REVERSE_ARGS (call_expr) = CALL_EXPR_REVERSE_ARGS (non_dep);
    3950              : 
    3951      6322788 :   if (negated)
    3952       507828 :     call = build_min (TRUTH_NOT_EXPR, boolean_type_node, call);
    3953      6322788 :   if (obj)
    3954            7 :     return keep_unused_object_arg (call, obj, overload);
    3955              :   return call;
    3956      6322815 : }
    3957              : 
    3958              : /* Similar to above build_min_non_dep_op_overload, but arguments
    3959              :    are taken from ARGS vector.  */
    3960              : 
    3961              : tree
    3962           22 : build_min_non_dep_op_overload (tree non_dep, tree overload, tree object,
    3963              :                                vec<tree, va_gc> *args)
    3964              : {
    3965           22 :   non_dep = extract_call_expr (non_dep);
    3966              : 
    3967           22 :   unsigned int nargs = call_expr_nargs (non_dep);
    3968           22 :   tree fn = overload;
    3969           22 :   if (DECL_OBJECT_MEMBER_FUNCTION_P (overload))
    3970              :     {
    3971           14 :       tree binfo = TYPE_BINFO (TREE_TYPE (object));
    3972           14 :       tree method = build_baselink (binfo, binfo, overload, NULL_TREE);
    3973           14 :       fn = build_min (COMPONENT_REF, TREE_TYPE (overload),
    3974              :                       object, method, NULL_TREE);
    3975           14 :       object = NULL_TREE;
    3976              :     }
    3977           44 :   gcc_assert (vec_safe_length (args) == nargs);
    3978              : 
    3979           22 :   tree call = build_min_non_dep_call_vec (non_dep, fn, args);
    3980              : 
    3981           22 :   tree call_expr = extract_call_expr (call);
    3982           22 :   KOENIG_LOOKUP_P (call_expr) = KOENIG_LOOKUP_P (non_dep);
    3983           22 :   CALL_EXPR_OPERATOR_SYNTAX (call_expr) = true;
    3984           22 :   CALL_EXPR_ORDERED_ARGS (call_expr) = CALL_EXPR_ORDERED_ARGS (non_dep);
    3985           22 :   CALL_EXPR_REVERSE_ARGS (call_expr) = CALL_EXPR_REVERSE_ARGS (non_dep);
    3986              : 
    3987           22 :   if (object)
    3988            8 :     return keep_unused_object_arg (call, object, overload);
    3989              :   return call;
    3990              : }
    3991              : 
    3992              : /* Return a new tree vec copied from VEC, with ELT inserted at index IDX.  */
    3993              : 
    3994              : vec<tree, va_gc> *
    3995         8960 : vec_copy_and_insert (vec<tree, va_gc> *old_vec, tree elt, unsigned idx)
    3996              : {
    3997         8960 :   unsigned len = vec_safe_length (old_vec);
    3998         8960 :   gcc_assert (idx <= len);
    3999              : 
    4000         8960 :   vec<tree, va_gc> *new_vec = NULL;
    4001         8960 :   vec_alloc (new_vec, len + 1);
    4002              : 
    4003         8960 :   unsigned i;
    4004        26909 :   for (i = 0; i < len; ++i)
    4005              :     {
    4006         8989 :       if (i == idx)
    4007           29 :         new_vec->quick_push (elt);
    4008         8989 :       new_vec->quick_push ((*old_vec)[i]);
    4009              :     }
    4010         8960 :   if (i == idx)
    4011         8931 :     new_vec->quick_push (elt);
    4012              : 
    4013         8960 :   return new_vec;
    4014              : }
    4015              : 
    4016              : tree
    4017       128298 : get_type_decl (tree t)
    4018              : {
    4019       128298 :   if (TREE_CODE (t) == TYPE_DECL)
    4020              :     return t;
    4021       128298 :   if (TYPE_P (t))
    4022       128298 :     return TYPE_STUB_DECL (t);
    4023            0 :   gcc_assert (t == error_mark_node);
    4024              :   return t;
    4025              : }
    4026              : 
    4027              : /* Returns the namespace that contains DECL, whether directly or
    4028              :    indirectly.  */
    4029              : 
    4030              : tree
    4031   1495317613 : decl_namespace_context (tree decl)
    4032              : {
    4033   3135827867 :   while (1)
    4034              :     {
    4035   3135827867 :       if (TREE_CODE (decl) == NAMESPACE_DECL)
    4036   1495317613 :         return decl;
    4037   1640510254 :       else if (TYPE_P (decl))
    4038    912211629 :         decl = CP_DECL_CONTEXT (TYPE_MAIN_DECL (decl));
    4039              :       else
    4040    728298625 :         decl = CP_DECL_CONTEXT (decl);
    4041              :     }
    4042              : }
    4043              : 
    4044              : /* Returns true if decl is within an anonymous namespace, however deeply
    4045              :    nested, or false otherwise.  */
    4046              : 
    4047              : bool
    4048           23 : decl_anon_ns_mem_p (tree decl)
    4049              : {
    4050           23 :   return !TREE_PUBLIC (decl_namespace_context (decl));
    4051              : }
    4052              : 
    4053              : /* Returns true if the enclosing scope of DECL has internal or no linkage.  */
    4054              : 
    4055              : bool
    4056   1372820188 : decl_internal_context_p (const_tree decl)
    4057              : {
    4058   2751079811 :   while (TREE_CODE (decl) != NAMESPACE_DECL)
    4059              :     {
    4060              :       /* Classes inside anonymous namespaces have TREE_PUBLIC == 0.  */
    4061   1732741899 :       if (TYPE_P (decl))
    4062    354482276 :         return !TREE_PUBLIC (TYPE_MAIN_DECL (decl));
    4063              : 
    4064   1378259623 :       decl = CP_DECL_CONTEXT (decl);
    4065              :     }
    4066   1018337912 :   return !TREE_PUBLIC (decl);
    4067              : }
    4068              : 
    4069              : /* Subroutine of cp_tree_equal: t1 and t2 are two CALL_EXPRs.
    4070              :    Return whether their CALL_EXPR_FNs are equivalent.  */
    4071              : 
    4072              : static bool
    4073     50010582 : called_fns_equal (tree t1, tree t2)
    4074              : {
    4075              :   /* Core 1321: dependent names are equivalent even if the overload sets
    4076              :      are different.  But do compare explicit template arguments.  */
    4077     50010582 :   tree name1 = call_expr_dependent_name (t1);
    4078     50010582 :   tree name2 = call_expr_dependent_name (t2);
    4079     50010582 :   t1 = CALL_EXPR_FN (t1);
    4080     50010582 :   t2 = CALL_EXPR_FN (t2);
    4081     50010582 :   if (name1 || name2)
    4082              :     {
    4083     42246665 :       tree targs1 = NULL_TREE, targs2 = NULL_TREE;
    4084              : 
    4085     42246665 :       if (name1 != name2)
    4086              :         return false;
    4087              : 
    4088              :       /* FIXME dependent_name currently returns an unqualified name regardless
    4089              :          of whether the function was named with a qualified- or unqualified-id.
    4090              :          Until that's fixed, check that we aren't looking at overload sets from
    4091              :          different scopes.  */
    4092     41183660 :       if (is_overloaded_fn (t1) && is_overloaded_fn (t2)
    4093     82395193 :           && (DECL_CONTEXT (get_first_fn (t1))
    4094     41183657 :               != DECL_CONTEXT (get_first_fn (t2))))
    4095              :         return false;
    4096              : 
    4097     41211536 :       if (TREE_CODE (t1) == TEMPLATE_ID_EXPR)
    4098     25997968 :         targs1 = TREE_OPERAND (t1, 1);
    4099     41211536 :       if (TREE_CODE (t2) == TEMPLATE_ID_EXPR)
    4100     25997968 :         targs2 = TREE_OPERAND (t2, 1);
    4101     41211536 :       return cp_tree_equal (targs1, targs2);
    4102              :     }
    4103              :   else
    4104      7763917 :     return cp_tree_equal (t1, t2);
    4105              : }
    4106              : 
    4107              : /* Return truthvalue of whether T1 is the same tree structure as T2.
    4108              :    Return 1 if they are the same. Return 0 if they are different.  */
    4109              : 
    4110              : bool
    4111   3027122804 : cp_tree_equal (tree t1, tree t2)
    4112              : {
    4113   3034746891 :   enum tree_code code1, code2;
    4114              : 
    4115   3034746891 :   if (t1 == t2)
    4116              :     return true;
    4117   1235045664 :   if (!t1 || !t2)
    4118              :     return false;
    4119              : 
    4120   1234434588 :   code1 = TREE_CODE (t1);
    4121   1234434588 :   code2 = TREE_CODE (t2);
    4122              : 
    4123   1234434588 :   if (comparing_contracts)
    4124              :     {
    4125              :       /* When comparing contracts, one declaration may already be
    4126              :          genericized. Check for invisible references and unravel them
    4127              :          for comparison purposes. Remember that a parameter is an invisible
    4128              :          reference so we can compare the parameter types accordingly.  */
    4129          150 :       if (code1 == VIEW_CONVERT_EXPR
    4130          150 :           && is_invisiref_parm (TREE_OPERAND(t1, 0)))
    4131              :         {
    4132            2 :           t1 = TREE_OPERAND(t1, 0);
    4133            2 :           code1 = TREE_CODE(t1);
    4134              :         }
    4135          150 :       if (code2 == VIEW_CONVERT_EXPR
    4136          150 :           && is_invisiref_parm (TREE_OPERAND(t2, 0)))
    4137              :         {
    4138            0 :           t2 = TREE_OPERAND(t2, 0);
    4139            0 :           code2 = TREE_CODE(t2);
    4140              :         }
    4141              :     }
    4142              : 
    4143   1234434588 :   if (code1 != code2)
    4144              :     return false;
    4145              : 
    4146   1102824400 :   if (CONSTANT_CLASS_P (t1)
    4147   1102824400 :       && !same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
    4148              :     return false;
    4149              : 
    4150   1102752193 :   switch (code1)
    4151              :     {
    4152            0 :     case VOID_CST:
    4153              :       /* There's only a single VOID_CST node, so we should never reach
    4154              :          here.  */
    4155            0 :       gcc_unreachable ();
    4156              : 
    4157    168011749 :     case INTEGER_CST:
    4158    168011749 :       return tree_int_cst_equal (t1, t2);
    4159              : 
    4160       105721 :     case REAL_CST:
    4161       105721 :       return real_identical (&TREE_REAL_CST (t1), &TREE_REAL_CST (t2));
    4162              : 
    4163       121420 :     case STRING_CST:
    4164       121420 :       return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
    4165       121420 :         && !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
    4166       121420 :                     TREE_STRING_LENGTH (t1));
    4167              : 
    4168            0 :     case FIXED_CST:
    4169            0 :       return FIXED_VALUES_IDENTICAL (TREE_FIXED_CST (t1),
    4170              :                                      TREE_FIXED_CST (t2));
    4171              : 
    4172            1 :     case COMPLEX_CST:
    4173            1 :       return cp_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
    4174            2 :         && cp_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
    4175              : 
    4176         7155 :     case VECTOR_CST:
    4177         7155 :       return operand_equal_p (t1, t2, OEP_ONLY_CONST);
    4178              : 
    4179      1660310 :     case CONSTRUCTOR:
    4180              :       /* We need to do this when determining whether or not two
    4181              :          non-type pointer to member function template arguments
    4182              :          are the same.  */
    4183      1660310 :       if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))
    4184      3544166 :           || CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2))
    4185              :         return false;
    4186              :       {
    4187              :         tree field, value;
    4188              :         unsigned int i;
    4189      1785868 :         FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t1), i, field, value)
    4190              :           {
    4191       169138 :             constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i);
    4192       169138 :             if (!cp_tree_equal (field, elt2->index)
    4193       169138 :                 || !cp_tree_equal (value, elt2->value))
    4194           20 :               return false;
    4195              :           }
    4196              :       }
    4197              :       return true;
    4198              : 
    4199      9258827 :     case TREE_LIST:
    4200      9258827 :       if (!cp_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))
    4201              :         return false;
    4202      9258827 :       if (!cp_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2)))
    4203              :         return false;
    4204        22529 :       return cp_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
    4205              : 
    4206          743 :     case SAVE_EXPR:
    4207          743 :       return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
    4208              : 
    4209     50213314 :     case CALL_EXPR:
    4210     50213314 :       {
    4211     50213314 :         if (KOENIG_LOOKUP_P (t1) != KOENIG_LOOKUP_P (t2))
    4212              :           return false;
    4213              : 
    4214     50010582 :         if (!called_fns_equal (t1, t2))
    4215              :           return false;
    4216              : 
    4217     22187089 :         call_expr_arg_iterator iter1, iter2;
    4218     22187089 :         init_call_expr_arg_iterator (t1, &iter1);
    4219     22187089 :         init_call_expr_arg_iterator (t2, &iter2);
    4220     22187089 :         if (iter1.n != iter2.n)
    4221              :           return false;
    4222              : 
    4223     23536661 :         while (more_call_expr_args_p (&iter1))
    4224              :           {
    4225     16055536 :             tree arg1 = next_call_expr_arg (&iter1);
    4226     16055536 :             tree arg2 = next_call_expr_arg (&iter2);
    4227              : 
    4228     16055536 :             gcc_checking_assert (arg1 && arg2);
    4229     16055536 :             if (!cp_tree_equal (arg1, arg2))
    4230              :               return false;
    4231              :           }
    4232              : 
    4233              :         return true;
    4234              :       }
    4235              : 
    4236       482241 :     case TARGET_EXPR:
    4237       482241 :       {
    4238       482241 :         tree o1 = TARGET_EXPR_SLOT (t1);
    4239       482241 :         tree o2 = TARGET_EXPR_SLOT (t2);
    4240              : 
    4241              :         /* Special case: if either target is an unallocated VAR_DECL,
    4242              :            it means that it's going to be unified with whatever the
    4243              :            TARGET_EXPR is really supposed to initialize, so treat it
    4244              :            as being equivalent to anything.  */
    4245       482241 :         if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
    4246       964482 :             && !DECL_RTL_SET_P (o1))
    4247              :           /*Nop*/;
    4248            0 :         else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
    4249            0 :                  && !DECL_RTL_SET_P (o2))
    4250              :           /*Nop*/;
    4251            0 :         else if (!cp_tree_equal (o1, o2))
    4252              :           return false;
    4253              : 
    4254       482241 :         return cp_tree_equal (TARGET_EXPR_INITIAL (t1),
    4255       964482 :                               TARGET_EXPR_INITIAL (t2));
    4256              :       }
    4257              : 
    4258           25 :     case AGGR_INIT_EXPR:
    4259           25 :       {
    4260           25 :         int n = aggr_init_expr_nargs (t1);
    4261           25 :         if (n != aggr_init_expr_nargs (t2))
    4262              :           return false;
    4263              : 
    4264           50 :         if (!cp_tree_equal (AGGR_INIT_EXPR_FN (t1),
    4265           25 :                             AGGR_INIT_EXPR_FN (t2)))
    4266              :           return false;
    4267              : 
    4268           25 :         tree o1 = AGGR_INIT_EXPR_SLOT (t1);
    4269           25 :         tree o2 = AGGR_INIT_EXPR_SLOT (t2);
    4270              : 
    4271              :         /* Similarly to TARGET_EXPRs, if the VAR_DECL is unallocated we're
    4272              :            going to unify the initialization, so treat it as equivalent
    4273              :            to anything.  */
    4274           25 :         if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
    4275           50 :             && !DECL_RTL_SET_P (o1))
    4276              :           /*Nop*/;
    4277            0 :         else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
    4278            0 :                  && !DECL_RTL_SET_P (o2))
    4279              :           /*Nop*/;
    4280            0 :         else if (!cp_tree_equal (o1, o2))
    4281              :           return false;
    4282              : 
    4283           51 :         for (int i = 0; i < n; ++i)
    4284           31 :           if (!cp_tree_equal (AGGR_INIT_EXPR_ARG (t1, i),
    4285           31 :                               AGGR_INIT_EXPR_ARG (t2, i)))
    4286              :             return false;
    4287              : 
    4288              :         return true;
    4289              :       }
    4290              : 
    4291      2466555 :     case PARM_DECL:
    4292              :       /* For comparing uses of parameters in late-specified return types
    4293              :          with an out-of-class definition of the function, but can also come
    4294              :          up for expressions that involve 'this' in a member function
    4295              :          template.  */
    4296              : 
    4297      2466555 :       if (comparing_specializations
    4298      2466555 :           && DECL_CONTEXT (t1) != DECL_CONTEXT (t2))
    4299              :         /* When comparing hash table entries, only an exact match is
    4300              :            good enough; we don't want to replace 'this' with the
    4301              :            version from another function.  But be more flexible
    4302              :            with parameters with identical contexts.  */
    4303              :         return false;
    4304              : 
    4305      2202196 :       if (same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)) || comparing_contracts)
    4306              :         {
    4307              :           /* When comparing contracts, we already know the declarations match,
    4308              :             and that the arguments have the same type. If one of the declarations
    4309              :             has been genericised, then the type of arguments in that declaration
    4310              :             will be adjusted for an invisible reference and the type comparison
    4311              :             would spuriosly fail. The only thing we care about when comparing
    4312              :             contractsis that we're using the same parameter.  */
    4313      1325356 :           if (DECL_ARTIFICIAL (t1) ^ DECL_ARTIFICIAL (t2))
    4314              :             return false;
    4315      1325356 :           if (CONSTRAINT_VAR_P (t1) ^ CONSTRAINT_VAR_P (t2))
    4316              :             return false;
    4317      1325356 :           if (DECL_ARTIFICIAL (t1)
    4318      1325356 :               || (DECL_PARM_LEVEL (t1) == DECL_PARM_LEVEL (t2)
    4319      1324721 :                   && DECL_PARM_INDEX (t1) == DECL_PARM_INDEX (t2)))
    4320              :             return true;
    4321              :         }
    4322              :       return false;
    4323              : 
    4324     26367656 :     case TEMPLATE_DECL:
    4325     26367656 :       if (DECL_TEMPLATE_TEMPLATE_PARM_P (t1)
    4326     26773007 :           && DECL_TEMPLATE_TEMPLATE_PARM_P (t2))
    4327       142415 :         return cp_tree_equal (TREE_TYPE (t1), TREE_TYPE (t2));
    4328              :       /* Fall through.  */
    4329              :     case VAR_DECL:
    4330              :     case CONST_DECL:
    4331              :     case FIELD_DECL:
    4332              :     case FUNCTION_DECL:
    4333              :     case IDENTIFIER_NODE:
    4334              :     case SSA_NAME:
    4335              :     case USING_DECL:
    4336              :     case DEFERRED_PARSE:
    4337              :     case NAMESPACE_DECL:
    4338              :       return false;
    4339              : 
    4340      4806059 :     case BASELINK:
    4341      4806059 :       return (BASELINK_BINFO (t1) == BASELINK_BINFO (t2)
    4342      4038899 :               && BASELINK_ACCESS_BINFO (t1) == BASELINK_ACCESS_BINFO (t2)
    4343      4038899 :               && BASELINK_QUALIFIED_P (t1) == BASELINK_QUALIFIED_P (t2)
    4344      8844946 :               && cp_tree_equal (BASELINK_FUNCTIONS (t1),
    4345      4038887 :                                 BASELINK_FUNCTIONS (t2)));
    4346              : 
    4347     13295679 :     case TEMPLATE_PARM_INDEX:
    4348     13295679 :       return (TEMPLATE_PARM_IDX (t1) == TEMPLATE_PARM_IDX (t2)
    4349     12660813 :               && TEMPLATE_PARM_LEVEL (t1) == TEMPLATE_PARM_LEVEL (t2)
    4350     12145117 :               && (TEMPLATE_PARM_PARAMETER_PACK (t1)
    4351     12145117 :                   == TEMPLATE_PARM_PARAMETER_PACK (t2))
    4352     25396622 :               && same_type_p (TREE_TYPE (TEMPLATE_PARM_DECL (t1)),
    4353              :                               TREE_TYPE (TEMPLATE_PARM_DECL (t2))));
    4354              : 
    4355     29541847 :     case TEMPLATE_ID_EXPR:
    4356     29541847 :       if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)))
    4357              :         return false;
    4358     28859975 :       if (!comp_template_args (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)))
    4359              :         return false;
    4360              :       return true;
    4361              : 
    4362      6974968 :     case CONSTRAINT_INFO:
    4363     20924904 :       return cp_tree_equal (CI_ASSOCIATED_CONSTRAINTS (t1),
    4364     20924904 :                             CI_ASSOCIATED_CONSTRAINTS (t2));
    4365              : 
    4366     53459588 :     case TREE_VEC:
    4367              :       /* These are template args.  Really we should be getting the
    4368              :          caller to do this as it knows it to be true.  */
    4369     53459588 :       if (!comp_template_args (t1, t2))
    4370              :         return false;
    4371              :       return true;
    4372              : 
    4373      1530925 :     case SIZEOF_EXPR:
    4374      1530925 :     case ALIGNOF_EXPR:
    4375      1530925 :       {
    4376      1530925 :         tree o1 = TREE_OPERAND (t1, 0);
    4377      1530925 :         tree o2 = TREE_OPERAND (t2, 0);
    4378              : 
    4379      1530925 :         if (code1 == SIZEOF_EXPR)
    4380              :           {
    4381      1521920 :             if (SIZEOF_EXPR_TYPE_P (t1))
    4382            0 :               o1 = TREE_TYPE (o1);
    4383      1521920 :             if (SIZEOF_EXPR_TYPE_P (t2))
    4384            0 :               o2 = TREE_TYPE (o2);
    4385              :           }
    4386         9005 :         else if (ALIGNOF_EXPR_STD_P (t1) != ALIGNOF_EXPR_STD_P (t2))
    4387              :           return false;
    4388              : 
    4389      1530919 :         if (TREE_CODE (o1) != TREE_CODE (o2))
    4390              :           return false;
    4391              : 
    4392      1530797 :         if (ARGUMENT_PACK_P (o1))
    4393            2 :           return template_args_equal (o1, o2);
    4394      1530795 :         else if (TYPE_P (o1))
    4395      1529881 :           return same_type_p (o1, o2);
    4396              :         else
    4397              :           return cp_tree_equal (o1, o2);
    4398              :       }
    4399              : 
    4400         1406 :     case MODOP_EXPR:
    4401         1406 :       {
    4402         1406 :         tree t1_op1, t2_op1;
    4403              : 
    4404         1406 :         if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)))
    4405              :           return false;
    4406              : 
    4407         1140 :         t1_op1 = TREE_OPERAND (t1, 1);
    4408         1140 :         t2_op1 = TREE_OPERAND (t2, 1);
    4409         1140 :         if (TREE_CODE (t1_op1) != TREE_CODE (t2_op1))
    4410              :           return false;
    4411              : 
    4412          277 :         return cp_tree_equal (TREE_OPERAND (t1, 2), TREE_OPERAND (t2, 2));
    4413              :       }
    4414              : 
    4415          809 :     case PTRMEM_CST:
    4416              :       /* Two pointer-to-members are the same if they point to the same
    4417              :          field or function in the same class.  */
    4418          809 :       if (PTRMEM_CST_MEMBER (t1) != PTRMEM_CST_MEMBER (t2))
    4419              :         return false;
    4420              : 
    4421          810 :       return same_type_p (PTRMEM_CST_CLASS (t1), PTRMEM_CST_CLASS (t2));
    4422              : 
    4423        19590 :     case OVERLOAD:
    4424        19590 :       {
    4425              :         /* Two overloads. Must be exactly the same set of decls.  */
    4426        19590 :         lkp_iterator first (t1);
    4427        19590 :         lkp_iterator second (t2);
    4428              : 
    4429        28803 :         for (; first && second; ++first, ++second)
    4430        20133 :           if (*first != *second)
    4431              :             return false;
    4432         8670 :         return !(first || second);
    4433              :       }
    4434              : 
    4435      9678112 :     case TRAIT_EXPR:
    4436      9678112 :       if (TRAIT_EXPR_KIND (t1) != TRAIT_EXPR_KIND (t2))
    4437              :         return false;
    4438       717692 :       return cp_tree_equal (TRAIT_EXPR_TYPE1 (t1), TRAIT_EXPR_TYPE1 (t2))
    4439      1419746 :         && cp_tree_equal (TRAIT_EXPR_TYPE2 (t1), TRAIT_EXPR_TYPE2 (t2));
    4440              : 
    4441      1046949 :     case NON_LVALUE_EXPR:
    4442      1046949 :     case VIEW_CONVERT_EXPR:
    4443              :       /* Used for location wrappers with possibly NULL types.  */
    4444      1046949 :       if (!TREE_TYPE (t1) || !TREE_TYPE (t2))
    4445              :         {
    4446           23 :           if (TREE_TYPE (t1) || TREE_TYPE (t2))
    4447              :             return false;
    4448              :           break;
    4449              :         }
    4450              :       /* FALLTHROUGH  */
    4451              : 
    4452      2857437 :     case CAST_EXPR:
    4453      2857437 :     case STATIC_CAST_EXPR:
    4454      2857437 :     case REINTERPRET_CAST_EXPR:
    4455      2857437 :     case CONST_CAST_EXPR:
    4456      2857437 :     case DYNAMIC_CAST_EXPR:
    4457      2857437 :     case IMPLICIT_CONV_EXPR:
    4458      2857437 :     case NEW_EXPR:
    4459      2857437 :     case BIT_CAST_EXPR:
    4460      2857437 :     CASE_CONVERT:
    4461      2857437 :       if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
    4462              :         return false;
    4463              :       /* Now compare operands as usual.  */
    4464              :       break;
    4465              : 
    4466            0 :     case DEFERRED_NOEXCEPT:
    4467            0 :       return (cp_tree_equal (DEFERRED_NOEXCEPT_PATTERN (t1),
    4468            0 :                              DEFERRED_NOEXCEPT_PATTERN (t2))
    4469            0 :               && comp_template_args (DEFERRED_NOEXCEPT_ARGS (t1),
    4470            0 :                                      DEFERRED_NOEXCEPT_ARGS (t2)));
    4471              : 
    4472              :     case LAMBDA_EXPR:
    4473              :       /* Two lambda-expressions are never considered equivalent.  */
    4474              :       return false;
    4475              : 
    4476    608003682 :     case TYPE_ARGUMENT_PACK:
    4477    608003682 :     case NONTYPE_ARGUMENT_PACK:
    4478    608003682 :       {
    4479    608003682 :         tree p1 = ARGUMENT_PACK_ARGS (t1);
    4480    608003682 :         tree p2 = ARGUMENT_PACK_ARGS (t2);
    4481    608003682 :         int len = TREE_VEC_LENGTH (p1);
    4482    608003682 :         if (TREE_VEC_LENGTH (p2) != len)
    4483              :           return false;
    4484              : 
    4485    753449617 :         for (int ix = 0; ix != len; ix++)
    4486    660164554 :           if (!template_args_equal (TREE_VEC_ELT (p1, ix),
    4487    660164554 :                                     TREE_VEC_ELT (p2, ix)))
    4488              :             return false;
    4489              :         return true;
    4490              :       }
    4491              : 
    4492      1201434 :     case EXPR_PACK_EXPANSION:
    4493      1201434 :       if (!cp_tree_equal (PACK_EXPANSION_PATTERN (t1),
    4494      1201434 :                           PACK_EXPANSION_PATTERN (t2)))
    4495              :         return false;
    4496        14620 :       if (!comp_template_args (PACK_EXPANSION_EXTRA_ARGS (t1),
    4497        14620 :                                PACK_EXPANSION_EXTRA_ARGS (t2)))
    4498              :         return false;
    4499              :       return true;
    4500              : 
    4501         2198 :     case PACK_INDEX_EXPR:
    4502         2198 :       if (!cp_tree_equal (PACK_INDEX_PACK (t1),
    4503         2198 :                           PACK_INDEX_PACK (t2)))
    4504              :         return false;
    4505          107 :       if (!cp_tree_equal (PACK_INDEX_INDEX (t1),
    4506          107 :                           PACK_INDEX_INDEX (t2)))
    4507              :         return false;
    4508              :       return true;
    4509              : 
    4510          847 :     case REFLECT_EXPR:
    4511          847 :       if (!cp_tree_equal (REFLECT_EXPR_HANDLE (t1), REFLECT_EXPR_HANDLE (t2))
    4512         1668 :           || REFLECT_EXPR_KIND (t1) != REFLECT_EXPR_KIND (t2))
    4513              :         return false;
    4514              :       return true;
    4515              : 
    4516              :     default:
    4517              :       break;
    4518              :     }
    4519              : 
    4520     82071393 :   switch (TREE_CODE_CLASS (code1))
    4521              :     {
    4522     79381359 :     case tcc_unary:
    4523     79381359 :     case tcc_binary:
    4524     79381359 :     case tcc_comparison:
    4525     79381359 :     case tcc_expression:
    4526     79381359 :     case tcc_vl_exp:
    4527     79381359 :     case tcc_reference:
    4528     79381359 :     case tcc_statement:
    4529     79381359 :       {
    4530     79381359 :         int n = cp_tree_operand_length (t1);
    4531     79381359 :         if (TREE_CODE_CLASS (code1) == tcc_vl_exp
    4532     79381359 :             && n != TREE_OPERAND_LENGTH (t2))
    4533              :           return false;
    4534              : 
    4535    135797923 :         for (int i = 0; i < n; ++i)
    4536    105105564 :           if (!cp_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i)))
    4537              :             return false;
    4538              : 
    4539              :         return true;
    4540              :       }
    4541              : 
    4542      2690034 :     case tcc_type:
    4543      2690034 :       return same_type_p (t1, t2);
    4544              : 
    4545            0 :     default:
    4546            0 :       gcc_unreachable ();
    4547              :     }
    4548              : 
    4549              :   /* We can get here with --disable-checking.  */
    4550              :   return false;
    4551              : }
    4552              : 
    4553              : /* The type of ARG when used as an lvalue.  */
    4554              : 
    4555              : tree
    4556   1188065363 : lvalue_type (tree arg)
    4557              : {
    4558   1188065363 :   tree type = TREE_TYPE (arg);
    4559   1188065363 :   return type;
    4560              : }
    4561              : 
    4562              : /* The type of ARG for printing error messages; denote lvalues with
    4563              :    reference types.  */
    4564              : 
    4565              : tree
    4566         3721 : error_type (tree arg)
    4567              : {
    4568         3721 :   tree type = TREE_TYPE (arg);
    4569              : 
    4570         3721 :   if (TREE_CODE (type) == ARRAY_TYPE)
    4571              :     ;
    4572         3610 :   else if (TREE_CODE (type) == ERROR_MARK)
    4573              :     ;
    4574         3610 :   else if (lvalue_p (arg))
    4575         1245 :     type = build_reference_type (lvalue_type (arg));
    4576         2365 :   else if (MAYBE_CLASS_TYPE_P (type))
    4577          748 :     type = lvalue_type (arg);
    4578              : 
    4579         3721 :   return type;
    4580              : }
    4581              : 
    4582              : /* Does FUNCTION use a variable-length argument list?  */
    4583              : 
    4584              : int
    4585       524838 : varargs_function_p (const_tree function)
    4586              : {
    4587       524838 :   return stdarg_p (TREE_TYPE (function));
    4588              : }
    4589              : 
    4590              : /* Returns 1 if decl is a member of a class.  */
    4591              : 
    4592              : int
    4593        10980 : member_p (const_tree decl)
    4594              : {
    4595        10980 :   const_tree const ctx = DECL_CONTEXT (decl);
    4596        10980 :   return (ctx && TYPE_P (ctx));
    4597              : }
    4598              : 
    4599              : /* Create a placeholder for member access where we don't actually have an
    4600              :    object that the access is against.  For a general declval<T> equivalent,
    4601              :    use build_stub_object instead.  */
    4602              : 
    4603              : tree
    4604    114668917 : build_dummy_object (tree type)
    4605              : {
    4606    114668917 :   tree decl = build1 (CONVERT_EXPR, build_pointer_type (type), void_node);
    4607    114668917 :   return cp_build_fold_indirect_ref (decl);
    4608              : }
    4609              : 
    4610              : /* We've gotten a reference to a member of TYPE.  Return *this if appropriate,
    4611              :    or a dummy object otherwise.  If BINFOP is non-0, it is filled with the
    4612              :    binfo path from current_class_type to TYPE, or 0.  */
    4613              : 
    4614              : tree
    4615    107770716 : maybe_dummy_object (tree type, tree* binfop)
    4616              : {
    4617    107770716 :   tree decl, context;
    4618    107770716 :   tree binfo;
    4619    107770716 :   tree current = current_nonlambda_class_type ();
    4620              : 
    4621    107770716 :   if (current
    4622    107770716 :       && (binfo = lookup_base (current, type, ba_any, NULL,
    4623              :                                tf_warning_or_error)))
    4624              :     context = current;
    4625              :   else
    4626              :     {
    4627              :       /* Reference from a nested class member function.  */
    4628      8777449 :       context = type;
    4629      8777449 :       binfo = TYPE_BINFO (type);
    4630              :     }
    4631              : 
    4632    107770716 :   if (binfop)
    4633       105589 :     *binfop = binfo;
    4634              : 
    4635              :   /* current_class_ref might not correspond to current_class_type if
    4636              :      we're in tsubst_default_argument or a lambda-declarator; in either
    4637              :      case, we want to use current_class_ref if it matches CONTEXT.  */
    4638    107770716 :   tree ctype = current_class_ref ? TREE_TYPE (current_class_ref) : NULL_TREE;
    4639     98501035 :   if (ctype
    4640     98501035 :       && same_type_ignoring_top_level_qualifiers_p (ctype, context))
    4641     95084136 :     decl = current_class_ref;
    4642              :   else
    4643              :     {
    4644              :       /* Return a dummy object whose cv-quals are consistent with (the
    4645              :          non-lambda) 'this' if available.  */
    4646     12686580 :       if (ctype)
    4647              :         {
    4648      3416899 :           int quals = TYPE_UNQUALIFIED;
    4649      3416899 :           if (tree lambda = CLASSTYPE_LAMBDA_EXPR (ctype))
    4650              :             {
    4651       402046 :               if (tree cap = lambda_expr_this_capture (lambda, false))
    4652       391280 :                 quals = cp_type_quals (TREE_TYPE (TREE_TYPE (cap)));
    4653              :             }
    4654              :           else
    4655      3014853 :             quals = cp_type_quals (ctype);
    4656      3416899 :           context = cp_build_qualified_type (context, quals);
    4657              :         }
    4658     12686580 :       decl = build_dummy_object (context);
    4659              :     }
    4660              : 
    4661    107770716 :   return decl;
    4662              : }
    4663              : 
    4664              : /* Returns 1 if OB is a placeholder object, or a pointer to one.  */
    4665              : 
    4666              : bool
    4667    607671162 : is_dummy_object (const_tree ob)
    4668              : {
    4669    607671162 :   if (INDIRECT_REF_P (ob))
    4670    455084919 :     ob = TREE_OPERAND (ob, 0);
    4671    607671162 :   return (TREE_CODE (ob) == CONVERT_EXPR
    4672    607671162 :           && TREE_OPERAND (ob, 0) == void_node);
    4673              : }
    4674              : 
    4675              : /* Returns true if TYPE is char, unsigned char, or std::byte.  */
    4676              : 
    4677              : bool
    4678     32223795 : is_byte_access_type (tree type)
    4679              : {
    4680     32223795 :   type = TYPE_MAIN_VARIANT (type);
    4681     32223795 :   if (type == char_type_node
    4682      7283125 :       || type == unsigned_char_type_node)
    4683              :     return true;
    4684              : 
    4685      7133768 :   return (TREE_CODE (type) == ENUMERAL_TYPE
    4686        15169 :           && TYPE_CONTEXT (type) == std_node
    4687      7151858 :           && !strcmp ("byte", TYPE_NAME_STRING (type)));
    4688              : }
    4689              : 
    4690              : /* Returns true if TYPE is unsigned char or std::byte.  */
    4691              : 
    4692              : bool
    4693         1946 : is_byte_access_type_not_plain_char (tree type)
    4694              : {
    4695         1946 :   type = TYPE_MAIN_VARIANT (type);
    4696         1946 :   if (type == char_type_node)
    4697              :     return false;
    4698              : 
    4699         1698 :   return is_byte_access_type (type);
    4700              : }
    4701              : 
    4702              : /* Returns 1 iff type T is something we want to treat as a scalar type for
    4703              :    the purpose of deciding whether it is trivial/POD/standard-layout.  */
    4704              : 
    4705              : bool
    4706    102403699 : scalarish_type_p (const_tree t)
    4707              : {
    4708    102403699 :   if (t == error_mark_node)
    4709              :     return 1;
    4710              : 
    4711    102403498 :   return (SCALAR_TYPE_P (t) || VECTOR_TYPE_P (t));
    4712              : }
    4713              : 
    4714              : /* Returns true iff T requires non-trivial default initialization.  */
    4715              : 
    4716              : bool
    4717            0 : type_has_nontrivial_default_init (const_tree t)
    4718              : {
    4719            0 :   t = strip_array_types (const_cast<tree> (t));
    4720              : 
    4721            0 :   if (CLASS_TYPE_P (t))
    4722            0 :     return TYPE_HAS_COMPLEX_DFLT (t);
    4723              :   else
    4724              :     return 0;
    4725              : }
    4726              : 
    4727              : /* Track classes with only deleted copy/move constructors so that we can warn
    4728              :    if they are used in call/return by value.  */
    4729              : 
    4730              : static GTY(()) hash_set<tree>* deleted_copy_types;
    4731              : static void
    4732            9 : remember_deleted_copy (const_tree t)
    4733              : {
    4734            9 :   if (!deleted_copy_types)
    4735            9 :     deleted_copy_types = hash_set<tree>::create_ggc(37);
    4736            9 :   deleted_copy_types->add (const_cast<tree> (t));
    4737            9 : }
    4738              : void
    4739    413869189 : maybe_warn_parm_abi (tree t, location_t loc)
    4740              : {
    4741    413869189 :   if (!deleted_copy_types
    4742    413869189 :       || !deleted_copy_types->contains (t))
    4743    413869159 :     return;
    4744              : 
    4745           30 :   if ((flag_abi_version == 12 || warn_abi_version == 12)
    4746           36 :       && classtype_has_non_deleted_move_ctor (t))
    4747              :     {
    4748            6 :       bool w;
    4749            6 :       auto_diagnostic_group d;
    4750            6 :       if (flag_abi_version > 12)
    4751            0 :         w = warning_at (loc, OPT_Wabi, "%<-fabi-version=13%> (GCC 8.2) fixes "
    4752              :                         "the calling convention for %qT, which was "
    4753              :                         "accidentally changed in 8.1", t);
    4754              :       else
    4755            6 :         w = warning_at (loc, OPT_Wabi, "%<-fabi-version=12%> (GCC 8.1) "
    4756              :                         "accidentally changes the calling convention for %qT",
    4757              :                         t);
    4758            6 :       if (w)
    4759            6 :         inform (location_of (t), " declared here");
    4760            6 :       return;
    4761            6 :     }
    4762              : 
    4763           30 :   auto_diagnostic_group d;
    4764           30 :   if (warning_at (loc, OPT_Wabi, "the calling convention for %qT changes in "
    4765              :                   "%<-fabi-version=13%> (GCC 8.2)", t))
    4766           30 :     inform (location_of (t), " because all of its copy and move "
    4767              :             "constructors are deleted");
    4768           30 : }
    4769              : 
    4770              : /* Returns true iff copying an object of type T (including via move
    4771              :    constructor) is non-trivial.  That is, T has no non-trivial copy
    4772              :    constructors and no non-trivial move constructors, and not all copy/move
    4773              :    constructors are deleted.  This function implements the ABI notion of
    4774              :    non-trivial copy, which has diverged from the one in the standard.  */
    4775              : 
    4776              : bool
    4777     62919235 : type_has_nontrivial_copy_init (const_tree type)
    4778              : {
    4779     62919235 :   tree t = strip_array_types (const_cast<tree> (type));
    4780              : 
    4781     62919235 :   if (CLASS_TYPE_P (t))
    4782              :     {
    4783     62312050 :       gcc_assert (COMPLETE_TYPE_P (t));
    4784              : 
    4785     62312050 :       if (TYPE_HAS_COMPLEX_COPY_CTOR (t)
    4786     62312050 :           || TYPE_HAS_COMPLEX_MOVE_CTOR (t))
    4787              :         /* Nontrivial.  */
    4788              :         return true;
    4789              : 
    4790     58303500 :       if (cxx_dialect < cxx11)
    4791              :         /* No deleted functions before C++11.  */
    4792              :         return false;
    4793              : 
    4794              :       /* Before ABI v12 we did a bitwise copy of types with only deleted
    4795              :          copy/move constructors.  */
    4796     58212540 :       if (!abi_version_at_least (12)
    4797         8132 :           && !(warn_abi && abi_version_crosses (12)))
    4798              :         return false;
    4799              : 
    4800     58204638 :       bool saw_copy = false;
    4801     58204638 :       bool saw_non_deleted = false;
    4802     58204638 :       bool saw_non_deleted_move = false;
    4803              : 
    4804     58204638 :       if (CLASSTYPE_LAZY_MOVE_CTOR (t))
    4805              :         saw_copy = saw_non_deleted = true;
    4806      5033012 :       else if (CLASSTYPE_LAZY_COPY_CTOR (t))
    4807              :         {
    4808       662945 :           saw_copy = true;
    4809       662945 :           if (classtype_has_move_assign_or_move_ctor_p (t, true))
    4810              :             /* [class.copy]/8 If the class definition declares a move
    4811              :                constructor or move assignment operator, the implicitly declared
    4812              :                copy constructor is defined as deleted.... */;
    4813              :           else
    4814              :             /* Any other reason the implicitly-declared function would be
    4815              :                deleted would also cause TYPE_HAS_COMPLEX_COPY_CTOR to be
    4816              :                set.  */
    4817              :             saw_non_deleted = true;
    4818              :         }
    4819              : 
    4820              :       if (!saw_non_deleted)
    4821     19092700 :         for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
    4822              :           {
    4823     11417404 :             tree fn = *iter;
    4824     11417404 :             if (copy_fn_p (fn))
    4825              :               {
    4826      4370113 :                 saw_copy = true;
    4827      4370113 :                 if (!DECL_DELETED_FN (fn))
    4828              :                   {
    4829              :                     /* Not deleted, therefore trivial.  */
    4830              :                     saw_non_deleted = true;
    4831              :                     break;
    4832              :                   }
    4833              :               }
    4834      7047291 :             else if (move_fn_p (fn))
    4835      3036042 :               if (!DECL_DELETED_FN (fn))
    4836      3015052 :                 saw_non_deleted_move = true;
    4837              :           }
    4838              : 
    4839     58204638 :       gcc_assert (saw_copy);
    4840              : 
    4841              :       /* ABI v12 buggily ignored move constructors.  */
    4842     58204638 :       bool v11nontriv = false;
    4843     58204638 :       bool v12nontriv = !saw_non_deleted;
    4844     58204638 :       bool v13nontriv = !saw_non_deleted && !saw_non_deleted_move;
    4845     58204638 :       bool nontriv = (abi_version_at_least (13) ? v13nontriv
    4846          124 :                       : flag_abi_version == 12 ? v12nontriv
    4847          124 :                       : v11nontriv);
    4848     58205043 :       bool warn_nontriv = (warn_abi_version >= 13 ? v13nontriv
    4849          405 :                            : warn_abi_version == 12 ? v12nontriv
    4850              :                            : v11nontriv);
    4851     58204638 :       if (nontriv != warn_nontriv)
    4852            9 :         remember_deleted_copy (t);
    4853              : 
    4854     58204638 :       return nontriv;
    4855              :     }
    4856              :   else
    4857              :     return 0;
    4858              : }
    4859              : 
    4860              : /* Returns 1 iff type T is a trivially copyable type, as defined in
    4861              :    [basic.types] and [class].  */
    4862              : 
    4863              : bool
    4864       511955 : trivially_copyable_p (const_tree t)
    4865              : {
    4866       511955 :   t = strip_array_types (const_cast<tree> (t));
    4867              : 
    4868       511955 :   if (CLASS_TYPE_P (t))
    4869        79241 :     return ((!TYPE_HAS_COPY_CTOR (t)
    4870        79241 :              || !TYPE_HAS_COMPLEX_COPY_CTOR (t))
    4871        78328 :             && !TYPE_HAS_COMPLEX_MOVE_CTOR (t)
    4872        78294 :             && (!TYPE_HAS_COPY_ASSIGN (t)
    4873        78294 :                 || !TYPE_HAS_COMPLEX_COPY_ASSIGN (t))
    4874        77317 :             && !TYPE_HAS_COMPLEX_MOVE_ASSIGN (t)
    4875       156389 :             && TYPE_HAS_TRIVIAL_DESTRUCTOR (t));
    4876              :   else
    4877              :     /* CWG 2094 makes volatile-qualified scalars trivially copyable again.  */
    4878       432714 :     return scalarish_type_p (t);
    4879              : }
    4880              : 
    4881              : /* Returns 1 iff type T is a trivial type, as defined in [basic.types] and
    4882              :    [class].  */
    4883              : 
    4884              : bool
    4885        72996 : trivial_type_p (const_tree t)
    4886              : {
    4887        72996 :   t = strip_array_types (const_cast<tree> (t));
    4888              : 
    4889        72996 :   if (CLASS_TYPE_P (t))
    4890              :     /* A trivial class is a class that is trivially copyable and has one or
    4891              :        more eligible default constructors, all of which are trivial.  */
    4892        19248 :     return (type_has_non_deleted_trivial_default_ctor (const_cast<tree> (t))
    4893        19248 :             && trivially_copyable_p (t));
    4894              :   else
    4895        53748 :     return scalarish_type_p (t);
    4896              : }
    4897              : 
    4898              : /* Returns 1 iff type T is an implicit-lifetime type, as defined in
    4899              :    [basic.types.general] and [class.prop].  */
    4900              : 
    4901              : bool
    4902          874 : implicit_lifetime_type_p (tree t)
    4903              : {
    4904          874 :   if (SCALAR_TYPE_P (t)
    4905          621 :       || (TREE_CODE (t) == ARRAY_TYPE
    4906           76 :           && !(TYPE_SIZE (t) && integer_zerop (TYPE_SIZE (t))))
    4907              :       /* GNU extension.  */
    4908          549 :       || TREE_CODE (t) == VECTOR_TYPE)
    4909          329 :     return true;
    4910          545 :   if (!CLASS_TYPE_P (t))
    4911              :     return false;
    4912          485 :   t = TYPE_MAIN_VARIANT (t);
    4913          970 :   if (CP_AGGREGATE_TYPE_P (t)
    4914          640 :       && (!CLASSTYPE_DESTRUCTOR (t)
    4915           83 :           || !user_provided_p (CLASSTYPE_DESTRUCTOR (t))))
    4916          132 :     return true;
    4917          353 :   if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t))
    4918              :     return false;
    4919          317 :   if (TYPE_HAS_COMPLEX_DFLT (t)
    4920          116 :       && TYPE_HAS_COMPLEX_COPY_CTOR (t)
    4921          376 :       && TYPE_HAS_COMPLEX_MOVE_CTOR (t))
    4922              :     return false;
    4923          293 :   if (CLASSTYPE_LAZY_DESTRUCTOR (t))
    4924          107 :     lazily_declare_fn (sfk_destructor, t);
    4925          293 :   tree fn = CLASSTYPE_DESTRUCTOR (t);
    4926          293 :   if (!fn || DECL_DELETED_FN (fn))
    4927              :     return false;
    4928          358 :   for (ovl_iterator iter (get_class_binding (t, complete_ctor_identifier));
    4929          358 :        iter; ++iter)
    4930              :     {
    4931          344 :       fn = *iter;
    4932          629 :       if ((default_ctor_p (fn) || copy_fn_p (fn) || move_fn_p (fn))
    4933          344 :           && trivial_fn_p (fn)
    4934          623 :           && !DECL_DELETED_FN (fn))
    4935          279 :         return true;
    4936              :     }
    4937           14 :   return false;
    4938              : }
    4939              : 
    4940              : /* Returns 1 iff type T is a POD type, as defined in [basic.types].  */
    4941              : 
    4942              : bool
    4943        11120 : pod_type_p (const_tree t)
    4944              : {
    4945              :   /* This CONST_CAST is okay because strip_array_types returns its
    4946              :      argument unmodified and we assign it to a const_tree.  */
    4947        11120 :   t = strip_array_types (const_cast<tree>(t));
    4948              : 
    4949        11120 :   if (!CLASS_TYPE_P (t))
    4950          690 :     return scalarish_type_p (t);
    4951        10430 :   else if (cxx_dialect > cxx98)
    4952              :     /* [class]/10: A POD struct is a class that is both a trivial class and a
    4953              :        standard-layout class, and has no non-static data members of type
    4954              :        non-POD struct, non-POD union (or array of such types).
    4955              : 
    4956              :        We don't need to check individual members because if a member is
    4957              :        non-std-layout or non-trivial, the class will be too.  */
    4958        10205 :     return (std_layout_type_p (t) && trivial_type_p (t));
    4959              :   else
    4960              :     /* The C++98 definition of POD is different.  */
    4961          225 :     return !CLASSTYPE_NON_LAYOUT_POD_P (t);
    4962              : }
    4963              : 
    4964              : /* Returns true iff T is POD for the purpose of layout, as defined in the
    4965              :    C++ ABI.  */
    4966              : 
    4967              : bool
    4968     19377058 : layout_pod_type_p (const_tree t)
    4969              : {
    4970     19377058 :   t = strip_array_types (const_cast<tree> (t));
    4971              : 
    4972     19377058 :   if (CLASS_TYPE_P (t))
    4973      4104433 :     return !CLASSTYPE_NON_LAYOUT_POD_P (t);
    4974              :   else
    4975     15272625 :     return scalarish_type_p (t);
    4976              : }
    4977              : 
    4978              : /* Returns true iff T is a standard-layout type, as defined in
    4979              :    [basic.types].  */
    4980              : 
    4981              : bool
    4982     19445678 : std_layout_type_p (const_tree t)
    4983              : {
    4984     19445678 :   t = strip_array_types (const_cast<tree> (t));
    4985              : 
    4986     19445678 :   if (CLASS_TYPE_P (t))
    4987      4117199 :     return !CLASSTYPE_NON_STD_LAYOUT (t);
    4988              :   else
    4989     15328479 :     return scalarish_type_p (t);
    4990              : }
    4991              : 
    4992              : static bool record_has_unique_obj_representations (const_tree, const_tree, bool);
    4993              : 
    4994              : /* Returns true iff T satisfies std::has_unique_object_representations<T>,
    4995              :    as defined in [meta.unary.prop].  If EXPLAIN is true, explain why not.  */
    4996              : 
    4997              : bool
    4998        66643 : type_has_unique_obj_representations (const_tree t, bool explain/*=false*/)
    4999              : {
    5000        66643 :   bool ret;
    5001              : 
    5002        66643 :   t = strip_array_types (const_cast<tree> (t));
    5003              : 
    5004        66643 :   if (t == error_mark_node)
    5005              :     return false;
    5006              : 
    5007        66640 :   location_t loc = input_location;
    5008        66640 :   if (tree m = TYPE_MAIN_DECL (t))
    5009         9167 :     loc = DECL_SOURCE_LOCATION (m);
    5010              : 
    5011        66640 :   if (!trivially_copyable_p (t))
    5012              :     {
    5013           23 :       if (explain)
    5014            6 :         inform (loc, "%qT is not trivially copyable", t);
    5015           23 :       return false;
    5016              :     }
    5017              : 
    5018          215 :   if (CLASS_TYPE_P (t)
    5019          212 :       && CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS_SET (t)
    5020        66725 :       && !explain)
    5021           84 :     return CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS (t);
    5022              : 
    5023        66533 :   switch (TREE_CODE (t))
    5024              :     {
    5025              :     case INTEGER_TYPE:
    5026              :     case POINTER_TYPE:
    5027              :     case REFERENCE_TYPE:
    5028              :       /* If some backend has any paddings in these types, we should add
    5029              :          a target hook for this and handle it there.  */
    5030              :       return true;
    5031              : 
    5032              :     case BOOLEAN_TYPE:
    5033              :       /* For bool values other than 0 and 1 should only appear with
    5034              :          undefined behavior.  */
    5035              :       return true;
    5036              : 
    5037         8937 :     case ENUMERAL_TYPE:
    5038         8937 :       return type_has_unique_obj_representations (ENUM_UNDERLYING_TYPE (t),
    5039         8937 :                                                   explain);
    5040              : 
    5041        30376 :     case REAL_TYPE:
    5042              :       /* XFmode certainly contains padding on x86, which the CPU doesn't store
    5043              :          when storing long double values, so for that we have to return false.
    5044              :          Other kinds of floating point values are questionable due to +.0/-.0
    5045              :          and NaNs, let's play safe for now.  */
    5046        30376 :       if (explain)
    5047            0 :         inform (loc, "%qT is a floating-point type", t);
    5048              :       return false;
    5049              : 
    5050            0 :     case FIXED_POINT_TYPE:
    5051            0 :       if (explain)
    5052            0 :         inform (loc, "%qT is a fixed-point type", t);
    5053              :       return false;
    5054              : 
    5055              :     case OFFSET_TYPE:
    5056              :       return true;
    5057              : 
    5058           18 :     case COMPLEX_TYPE:
    5059           18 :     case VECTOR_TYPE:
    5060           18 :       return type_has_unique_obj_representations (TREE_TYPE (t), explain);
    5061              : 
    5062          110 :     case RECORD_TYPE:
    5063          110 :       ret = record_has_unique_obj_representations (t, TYPE_SIZE (t), explain);
    5064          110 :       if (CLASS_TYPE_P (t))
    5065              :         {
    5066          107 :           CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS_SET (t) = 1;
    5067          107 :           CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS (t) = ret;
    5068              :         }
    5069              :       return ret;
    5070              : 
    5071           21 :     case UNION_TYPE:
    5072           21 :       ret = true;
    5073           21 :       bool any_fields;
    5074           21 :       any_fields = false;
    5075           42 :       for (tree field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
    5076           33 :         if (TREE_CODE (field) == FIELD_DECL)
    5077              :           {
    5078           24 :             any_fields = true;
    5079           24 :             if (simple_cst_equal (DECL_SIZE (field), TYPE_SIZE (t)) != 1)
    5080              :               {
    5081           12 :                 if (explain)
    5082            3 :                   inform (DECL_SOURCE_LOCATION (field),
    5083              :                           "%qD does not fill all bits of %q#T", field, t);
    5084              :                 ret = false;
    5085              :                 break;
    5086              :               }
    5087           12 :             if (!type_has_unique_obj_representations (TREE_TYPE (field)))
    5088              :               {
    5089            0 :                 if (explain)
    5090            0 :                   inform (DECL_SOURCE_LOCATION (field),
    5091              :                           "%qD has type %qT that does not have "
    5092              :                           "unique object representations",
    5093            0 :                           field, TREE_TYPE (field));
    5094              :                 ret = false;
    5095              :                 break;
    5096              :               }
    5097              :           }
    5098            9 :       if (!any_fields && !integer_zerop (TYPE_SIZE (t)))
    5099              :         {
    5100            6 :           if (explain)
    5101            3 :             inform (loc, "%q#T has no data fields", t);
    5102              :           ret = false;
    5103              :         }
    5104           21 :       if (CLASS_TYPE_P (t))
    5105              :         {
    5106           21 :           CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS_SET (t) = 1;
    5107           21 :           CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS (t) = ret;
    5108              :         }
    5109              :       return ret;
    5110              : 
    5111            3 :     case NULLPTR_TYPE:
    5112            3 :       if (explain)
    5113            0 :         inform (loc, "%<std::nullptr_t%> has padding bits and no value bits");
    5114              :       return false;
    5115              : 
    5116            0 :     default:
    5117            0 :       gcc_unreachable ();
    5118              :     }
    5119              : }
    5120              : 
    5121              : /* Helper function for type_has_unique_obj_representations.  */
    5122              : 
    5123              : static bool
    5124          121 : record_has_unique_obj_representations (const_tree t, const_tree sz,
    5125              :                                        bool explain)
    5126              : {
    5127          628 :   for (tree field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
    5128          537 :     if (TREE_CODE (field) != FIELD_DECL)
    5129              :       ;
    5130              :     /* For bases, can't use type_has_unique_obj_representations here, as in
    5131              :         struct S { int i : 24; S (); };
    5132              :         struct T : public S { int j : 8; T (); };
    5133              :         S doesn't have unique obj representations, but T does.  */
    5134          174 :     else if (DECL_FIELD_IS_BASE (field))
    5135              :       {
    5136           11 :         if (!record_has_unique_obj_representations (TREE_TYPE (field),
    5137           11 :                                                     DECL_SIZE (field),
    5138              :                                                     /*explain=*/false))
    5139              :           {
    5140            6 :             if (explain)
    5141            3 :               inform (DECL_SOURCE_LOCATION (field),
    5142              :                       "base %qT does not have unique object representations",
    5143            3 :                       TREE_TYPE (field));
    5144            6 :             return false;
    5145              :           }
    5146              :       }
    5147          163 :     else if (DECL_C_BIT_FIELD (field) && !DECL_UNNAMED_BIT_FIELD (field))
    5148              :       {
    5149           58 :         tree btype = DECL_BIT_FIELD_TYPE (field);
    5150           58 :         if (!type_has_unique_obj_representations (btype))
    5151              :           {
    5152            0 :             if (explain)
    5153            0 :               inform (DECL_SOURCE_LOCATION (field),
    5154              :                       "%qD with type %qT does not have "
    5155              :                       "unique object representations",
    5156              :                       field, btype);
    5157            0 :             return false;
    5158              :           }
    5159              :       }
    5160          105 :     else if (!type_has_unique_obj_representations (TREE_TYPE (field)))
    5161              :       {
    5162           24 :         if (explain)
    5163            6 :           inform (DECL_SOURCE_LOCATION (field),
    5164              :                   "%qD with type %qT does not have "
    5165              :                   "unique object representations",
    5166            6 :                   field, TREE_TYPE (field));
    5167           24 :         return false;
    5168              :       }
    5169              : 
    5170           91 :   offset_int cur = 0;
    5171           91 :   tree last_field = NULL_TREE;
    5172           91 :   tree last_named_field = NULL_TREE;
    5173          529 :   for (tree field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
    5174          469 :     if (TREE_CODE (field) == FIELD_DECL)
    5175              :       {
    5176          138 :         if (DECL_UNNAMED_BIT_FIELD (field))
    5177              :           {
    5178           16 :             last_field = field;
    5179           16 :             continue;
    5180              :           }
    5181          122 :         offset_int fld = wi::to_offset (DECL_FIELD_OFFSET (field));
    5182          122 :         offset_int bitpos = wi::to_offset (DECL_FIELD_BIT_OFFSET (field));
    5183          122 :         fld = fld * BITS_PER_UNIT + bitpos;
    5184          122 :         if (cur != fld)
    5185              :           {
    5186           31 :             if (explain)
    5187              :               {
    5188            6 :                 if (last_named_field)
    5189            3 :                   inform (DECL_SOURCE_LOCATION (last_named_field),
    5190              :                           "padding occurs between %qD and %qD",
    5191              :                           last_named_field, field);
    5192            3 :                 else if (last_field)
    5193            3 :                   inform (DECL_SOURCE_LOCATION (last_field),
    5194              :                           "unnamed bit-field inserts padding before %qD",
    5195              :                           field);
    5196              :                 else
    5197            0 :                   inform (DECL_SOURCE_LOCATION (field),
    5198              :                           "padding occurs before %qD", field);
    5199              :               }
    5200           31 :             return false;
    5201              :           }
    5202           91 :         if (DECL_SIZE (field))
    5203              :           {
    5204           88 :             offset_int size = wi::to_offset (DECL_SIZE (field));
    5205           88 :             cur += size;
    5206              :           }
    5207           91 :         last_named_field = last_field = field;
    5208              :       }
    5209           60 :   if (cur != wi::to_offset (sz))
    5210              :     {
    5211           25 :       if (explain)
    5212              :         {
    5213            3 :           if (last_named_field)
    5214            3 :             inform (DECL_SOURCE_LOCATION (last_named_field),
    5215              :                     "padding occurs after %qD", last_named_field);
    5216              :           else
    5217            0 :             inform (DECL_SOURCE_LOCATION (t),
    5218              :                     "%qT has padding and no data fields", t);
    5219              :         }
    5220           25 :       return false;
    5221              :     }
    5222              : 
    5223              :   return true;
    5224              : }
    5225              : 
    5226              : /* Nonzero iff type T is a class template implicit specialization.  */
    5227              : 
    5228              : bool
    5229    149057560 : class_tmpl_impl_spec_p (const_tree t)
    5230              : {
    5231    149057560 :   return CLASS_TYPE_P (t) && CLASSTYPE_TEMPLATE_INSTANTIATION (t);
    5232              : }
    5233              : 
    5234              : /* Returns 1 iff zero initialization of type T means actually storing
    5235              :    zeros in it.  */
    5236              : 
    5237              : int
    5238     23445977 : zero_init_p (const_tree t)
    5239              : {
    5240              :   /* This CONST_CAST is okay because strip_array_types returns its
    5241              :      argument unmodified and we assign it to a const_tree.  */
    5242     23445977 :   t = strip_array_types (const_cast<tree> (t));
    5243              : 
    5244     23445977 :   if (t == error_mark_node)
    5245              :     return 1;
    5246              : 
    5247              :   /* NULL pointers to data members are initialized with -1.  */
    5248     23445977 :   if (TYPE_PTRDATAMEM_P (t))
    5249              :     return 0;
    5250              : 
    5251              :   /* Classes that contain types that can't be zero-initialized, cannot
    5252              :      be zero-initialized themselves.  */
    5253     23445375 :   if (CLASS_TYPE_P (t) && CLASSTYPE_NON_ZERO_INIT_P (t))
    5254          148 :     return 0;
    5255              : 
    5256              :   return 1;
    5257              : }
    5258              : 
    5259              : /* Returns true if the expression or initializer T is the result of
    5260              :    zero-initialization for its type, taking pointers to members
    5261              :    into consideration.  */
    5262              : 
    5263              : bool
    5264       437048 : zero_init_expr_p (tree t)
    5265              : {
    5266       437048 :   tree type = TREE_TYPE (t);
    5267       437048 :   if (!type || uses_template_parms (type))
    5268            0 :     return false;
    5269       437048 :   if (TYPE_PTRMEM_P (type))
    5270         1251 :     return null_member_pointer_value_p (t);
    5271       435797 :   if (TREE_CODE (t) == CONSTRUCTOR)
    5272              :     {
    5273       179858 :       if (COMPOUND_LITERAL_P (t)
    5274       179858 :           || BRACE_ENCLOSED_INITIALIZER_P (t))
    5275              :         /* Undigested, conversions might change the zeroness.  */
    5276              :         return false;
    5277       542830 :       for (constructor_elt &elt : CONSTRUCTOR_ELTS (t))
    5278              :         {
    5279       182543 :           if (TREE_CODE (type) == UNION_TYPE
    5280       182543 :               && elt.index != first_field (type))
    5281              :             return false;
    5282       182534 :           if (!zero_init_expr_p (elt.value))
    5283              :             return false;
    5284              :         }
    5285              :       return true;
    5286              :     }
    5287       255939 :   if (zero_init_p (type))
    5288       255939 :     return initializer_zerop (t);
    5289              :   return false;
    5290              : }
    5291              : 
    5292              : /* True IFF T is a C++20 structural type (P1907R1) that can be used as a
    5293              :    non-type template parameter.  If EXPLAIN, explain why not.  */
    5294              : 
    5295              : bool
    5296        85699 : structural_type_p (tree t, bool explain)
    5297              : {
    5298              :   /* A structural type is one of the following: */
    5299              : 
    5300              :   /* a scalar type, or */
    5301        85699 :   if (SCALAR_TYPE_P (t))
    5302              :     return true;
    5303              :   /* an lvalue reference type, or */
    5304        44177 :   if (TYPE_REF_P (t) && !TYPE_REF_IS_RVALUE (t))
    5305              :     return true;
    5306              :   /* a literal class type with the following properties:
    5307              :      - all base classes and non-static data members are public and non-mutable
    5308              :        and
    5309              :      - the types of all bases classes and non-static data members are
    5310              :        structural types or (possibly multi-dimensional) array thereof.  */
    5311        44169 :   if (!CLASS_TYPE_P (t))
    5312              :     return false;
    5313        44165 :   if (!literal_type_p (t))
    5314              :     {
    5315           18 :       if (explain)
    5316            8 :         explain_non_literal_class (t);
    5317           18 :       return false;
    5318              :     }
    5319        94461 :   for (tree m = next_aggregate_field (TYPE_FIELDS (t)); m;
    5320        50314 :        m = next_aggregate_field (DECL_CHAIN (m)))
    5321              :     {
    5322        50499 :       if (TREE_PRIVATE (m) || TREE_PROTECTED (m))
    5323              :         {
    5324          137 :           if (explain)
    5325              :             {
    5326           50 :               if (DECL_FIELD_IS_BASE (m))
    5327            3 :                 inform (location_of (m), "base class %qT is not public",
    5328            3 :                         TREE_TYPE (m));
    5329              :               else
    5330           47 :                 inform (location_of (m), "%qD is not public", m);
    5331              :             }
    5332          137 :           return false;
    5333              :         }
    5334        50362 :       if (DECL_MUTABLE_P (m))
    5335              :         {
    5336           12 :           if (explain)
    5337            3 :             inform (location_of (m), "%qD is mutable", m);
    5338           12 :           return false;
    5339              :         }
    5340        50350 :       tree mtype = strip_array_types (TREE_TYPE (m));
    5341        50350 :       if (!structural_type_p (mtype))
    5342              :         {
    5343           36 :           if (explain)
    5344              :             {
    5345            1 :               inform (location_of (m), "%qD has a non-structural type", m);
    5346            1 :               structural_type_p (mtype, true);
    5347              :             }
    5348           36 :           return false;
    5349              :         }
    5350              :     }
    5351              :   return true;
    5352              : }
    5353              : 
    5354              : /* Partially handle the C++11 [[carries_dependency]] attribute.
    5355              :    Just emit a different diagnostics when it is used on something the
    5356              :    spec doesn't allow vs. where it allows and we just choose to ignore
    5357              :    it.  */
    5358              : 
    5359              : static tree
    5360          142 : handle_carries_dependency_attribute (tree *node, tree name,
    5361              :                                      tree ARG_UNUSED (args),
    5362              :                                      int ARG_UNUSED (flags),
    5363              :                                      bool *no_add_attrs)
    5364              : {
    5365          142 :   if (TREE_CODE (*node) != FUNCTION_DECL
    5366          121 :       && TREE_CODE (*node) != PARM_DECL)
    5367              :     {
    5368           76 :       warning (OPT_Wattributes, "%qE attribute can only be applied to "
    5369              :                "functions or parameters", name);
    5370           76 :       *no_add_attrs = true;
    5371              :     }
    5372              :   else
    5373              :     {
    5374           66 :       warning (OPT_Wattributes, "%qE attribute ignored", name);
    5375           66 :       *no_add_attrs = true;
    5376              :     }
    5377          142 :   return NULL_TREE;
    5378              : }
    5379              : 
    5380              : /* Handle the C++17 [[nodiscard]] attribute, which is similar to the GNU
    5381              :    warn_unused_result attribute.  */
    5382              : 
    5383              : static tree
    5384     12675396 : handle_nodiscard_attribute (tree *node, tree name, tree args,
    5385              :                             int /*flags*/, bool *no_add_attrs)
    5386              : {
    5387     12675541 :   if (args && TREE_CODE (TREE_VALUE (args)) != STRING_CST)
    5388              :     {
    5389            6 :       error ("%qE attribute argument must be a string constant", name);
    5390            6 :       *no_add_attrs = true;
    5391              :     }
    5392     12675396 :   if (TREE_CODE (*node) == FUNCTION_DECL)
    5393              :     {
    5394     12674240 :       if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (*node)))
    5395     12773072 :           && !DECL_CONSTRUCTOR_P (*node))
    5396            9 :         warning_at (DECL_SOURCE_LOCATION (*node),
    5397            9 :                     OPT_Wattributes, "%qE attribute applied to %qD with void "
    5398              :                     "return type", name, *node);
    5399              :     }
    5400         1156 :   else if (OVERLOAD_TYPE_P (*node))
    5401              :     /* OK */;
    5402              :   else
    5403              :     {
    5404          148 :       warning (OPT_Wattributes, "%qE attribute can only be applied to "
    5405              :                "functions or to class or enumeration types", name);
    5406          148 :       *no_add_attrs = true;
    5407              :     }
    5408     12675396 :   return NULL_TREE;
    5409              : }
    5410              : 
    5411              : /* Handle a C++20 "no_unique_address" attribute; arguments as in
    5412              :    struct attribute_spec.handler.  */
    5413              : static tree
    5414       648404 : handle_no_unique_addr_attribute (tree* node,
    5415              :                                  tree name,
    5416              :                                  tree /*args*/,
    5417              :                                  int /*flags*/,
    5418              :                                  bool* no_add_attrs)
    5419              : {
    5420       648404 :   if (TREE_CODE (*node) == VAR_DECL)
    5421              :     {
    5422           48 :       DECL_MERGEABLE (*node) = true;
    5423           48 :       if (pedantic)
    5424           42 :         warning (OPT_Wattributes, "%qE attribute can only be applied to "
    5425              :                  "non-static data members", name);
    5426              :     }
    5427       648356 :   else if (TREE_CODE (*node) != FIELD_DECL)
    5428              :     {
    5429           82 :       warning (OPT_Wattributes, "%qE attribute can only be applied to "
    5430              :                "non-static data members", name);
    5431           82 :       *no_add_attrs = true;
    5432              :     }
    5433       648274 :   else if (DECL_C_BIT_FIELD (*node))
    5434              :     {
    5435            6 :       warning (OPT_Wattributes, "%qE attribute cannot be applied to "
    5436              :                "a bit-field", name);
    5437            6 :       *no_add_attrs = true;
    5438              :     }
    5439              : 
    5440       648404 :   return NULL_TREE;
    5441              : }
    5442              : 
    5443              : /* The C++20 [[likely]] and [[unlikely]] attributes on labels map to the GNU
    5444              :    hot/cold attributes.  */
    5445              : 
    5446              : static tree
    5447          392 : handle_likeliness_attribute (tree *node, tree name, tree args,
    5448              :                              int flags, bool *no_add_attrs)
    5449              : {
    5450          392 :   *no_add_attrs = true;
    5451          392 :   if (TREE_CODE (*node) == LABEL_DECL
    5452          392 :       || TREE_CODE (*node) == FUNCTION_DECL)
    5453              :     {
    5454           90 :       if (args)
    5455            0 :         warning (OPT_Wattributes, "%qE attribute takes no arguments", name);
    5456           90 :       tree bname = (is_attribute_p ("likely", name)
    5457           90 :                     ? get_identifier ("hot") : get_identifier ("cold"));
    5458           90 :       if (TREE_CODE (*node) == FUNCTION_DECL)
    5459           33 :         warning (OPT_Wattributes, "ISO C++ %qE attribute does not apply to "
    5460              :                  "functions; treating as %<[[gnu::%E]]%>", name, bname);
    5461           90 :       tree battr = build_tree_list (bname, NULL_TREE);
    5462           90 :       decl_attributes (node, battr, flags);
    5463           90 :       return NULL_TREE;
    5464              :     }
    5465              :   else
    5466          302 :     return error_mark_node;
    5467              : }
    5468              : 
    5469              : /* The C++11 alignment specifier.  It mostly maps to GNU aligned attribute,
    5470              :    but we need to do some extra pedantic checking.  */
    5471              : 
    5472              : static tree
    5473       299587 : handle_alignas_attribute (tree *node, tree name, tree args, int flags,
    5474              :                           bool *no_add_attrs)
    5475              : {
    5476       299587 :   tree t = *node;
    5477       299587 :   tree ret = handle_aligned_attribute (node, name, args, flags, no_add_attrs);
    5478       299587 :   if (pedantic)
    5479              :     {
    5480         1216 :       if (TREE_CODE (*node) == FUNCTION_DECL)
    5481           15 :         pedwarn (input_location, OPT_Wattributes,
    5482              :                  "%<alignas%> on function declaration");
    5483         1201 :       else if (TREE_CODE (*node) == ENUMERAL_TYPE)
    5484            9 :         pedwarn (input_location, OPT_Wattributes,
    5485              :                  "%<alignas%> on enumerated type");
    5486         1192 :       else if (TYPE_P (*node) && t != *node)
    5487           56 :         pedwarn (input_location, OPT_Wattributes,
    5488              :                  "%<alignas%> on a type other than class");
    5489         1136 :       else if (TREE_CODE (*node) == FIELD_DECL && DECL_C_BIT_FIELD (*node))
    5490            9 :         pedwarn (input_location, OPT_Wattributes, "%<alignas%> on bit-field");
    5491         1127 :       else if (TREE_CODE (t) == TYPE_DECL)
    5492            9 :         pedwarn (input_location, OPT_Wattributes,
    5493              :                  "%<alignas%> on a type alias");
    5494              :     }
    5495       299587 :   return ret;
    5496              : }
    5497              : 
    5498              : /* The C++14 [[deprecated]] attribute mostly maps to the GNU deprecated
    5499              :    attribute.  */
    5500              : 
    5501              : static tree
    5502       136945 : handle_std_deprecated_attribute (tree *node, tree name, tree args, int flags,
    5503              :                                  bool *no_add_attrs)
    5504              : {
    5505       136945 :   tree t = *node;
    5506       136945 :   tree ret = handle_deprecated_attribute (node, name, args, flags,
    5507              :                                           no_add_attrs);
    5508       136945 :   if (TYPE_P (*node) && t != *node)
    5509           48 :     pedwarn (input_location, OPT_Wattributes,
    5510              :              "%qE on a type other than class or enumeration definition", name);
    5511       136897 :   else if (TREE_CODE (*node) == FIELD_DECL && DECL_UNNAMED_BIT_FIELD (*node))
    5512            4 :     pedwarn (input_location, OPT_Wattributes, "%qE on unnamed bit-field",
    5513              :              name);
    5514       136945 :   return ret;
    5515              : }
    5516              : 
    5517              : /* The C++17 [[maybe_unused]] attribute mostly maps to the GNU unused
    5518              :    attribute.  */
    5519              : 
    5520              : static tree
    5521        95727 : handle_maybe_unused_attribute (tree *node, tree name, tree args, int flags,
    5522              :                                bool *no_add_attrs)
    5523              : {
    5524        95727 :   tree t = *node;
    5525        95727 :   tree ret = handle_unused_attribute (node, name, args, flags, no_add_attrs);
    5526        95727 :   if (TYPE_P (*node) && t != *node)
    5527           36 :     pedwarn (input_location, OPT_Wattributes,
    5528              :              "%qE on a type other than class or enumeration definition", name);
    5529        95691 :   else if (TREE_CODE (*node) == FIELD_DECL && DECL_UNNAMED_BIT_FIELD (*node))
    5530            3 :     pedwarn (input_location, OPT_Wattributes, "%qE on unnamed bit-field",
    5531              :              name);
    5532        95688 :   else if (TREE_CODE (*node) == LABEL_DECL && DECL_NAME (*node) == NULL_TREE)
    5533            6 :     pedwarn (input_location, OPT_Wattributes,
    5534              :              "%qE on %<case%> or %<default%> label", name);
    5535        95727 :   return ret;
    5536              : }
    5537              : 
    5538              : /* The C++26 [[indeterminate]] attribute.  */
    5539              : 
    5540              : static tree
    5541          231 : handle_indeterminate_attribute (tree *node, tree name, tree, int,
    5542              :                                 bool *no_add_attrs)
    5543              : {
    5544          231 :   if (TREE_CODE (*node) != PARM_DECL
    5545          231 :       && (!VAR_P (*node) || is_global_var (*node)))
    5546              :     {
    5547           67 :       pedwarn (input_location, OPT_Wattributes,
    5548              :                "%qE on declaration other than parameter or automatic variable",
    5549              :                name);
    5550           67 :       *no_add_attrs = true;
    5551              :     }
    5552          231 :   return NULL_TREE;
    5553              : }
    5554              : 
    5555              : /* Table of valid C++ attributes.  */
    5556              : static const attribute_spec cxx_gnu_attributes[] =
    5557              : {
    5558              :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
    5559              :        affects_type_identity, handler, exclude } */
    5560              :   { "init_priority",  1, 1, true,  false, false, false,
    5561              :     handle_init_priority_attribute, NULL },
    5562              :   { "abi_tag", 1, -1, false, false, false, true,
    5563              :     handle_abi_tag_attribute, NULL },
    5564              :   { "no_dangling", 0, 1, false, true, false, false,
    5565              :     handle_no_dangling_attribute, NULL },
    5566              : };
    5567              : 
    5568              : const scoped_attribute_specs cxx_gnu_attribute_table =
    5569              : {
    5570              :   "gnu", { cxx_gnu_attributes }
    5571              : };
    5572              : 
    5573              : /* Table of C++ standard attributes.  */
    5574              : static const attribute_spec std_attributes[] =
    5575              : {
    5576              :   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
    5577              :        affects_type_identity, handler, exclude } */
    5578              :   { "deprecated", 0, 1, false, false, false, false,
    5579              :     handle_std_deprecated_attribute, NULL },
    5580              :   { "maybe_unused", 0, 0, false, false, false, false,
    5581              :     handle_maybe_unused_attribute, NULL },
    5582              :   { "nodiscard", 0, 1, false, false, false, false,
    5583              :     handle_nodiscard_attribute, NULL },
    5584              :   { "no_unique_address", 0, 0, true, false, false, false,
    5585              :     handle_no_unique_addr_attribute, NULL },
    5586              :   { "likely", 0, 0, false, false, false, false,
    5587              :     handle_likeliness_attribute, attr_cold_hot_exclusions },
    5588              :   { "unlikely", 0, 0, false, false, false, false,
    5589              :     handle_likeliness_attribute, attr_cold_hot_exclusions },
    5590              :   { "noreturn", 0, 0, true, false, false, false,
    5591              :     handle_noreturn_attribute, attr_noreturn_exclusions },
    5592              :   { "carries_dependency", 0, 0, true, false, false, false,
    5593              :     handle_carries_dependency_attribute, NULL },
    5594              :   { "indeterminate", 0, 0, true, false, false, false,
    5595              :     handle_indeterminate_attribute, NULL },
    5596              : };
    5597              : 
    5598              : const scoped_attribute_specs std_attribute_table =
    5599              : {
    5600              :   nullptr, { std_attributes }
    5601              : };
    5602              : 
    5603              : /* Table of internal attributes.  */
    5604              : static const attribute_spec internal_attributes[] =
    5605              : {
    5606              :   { "aligned", 0, 1, false, false, false, false,
    5607              :     handle_alignas_attribute, attr_aligned_exclusions },
    5608              :   { "annotation ", 1, 1, false, false, false, false,
    5609              :     handle_annotation_attribute, NULL }
    5610              : };
    5611              : 
    5612              : const scoped_attribute_specs internal_attribute_table =
    5613              : {
    5614              :   "internal ", { internal_attributes }
    5615              : };
    5616              : 
    5617              : /* Handle an "init_priority" attribute; arguments as in
    5618              :    struct attribute_spec.handler.  */
    5619              : static tree
    5620           35 : handle_init_priority_attribute (tree* node,
    5621              :                                 tree name,
    5622              :                                 tree args,
    5623              :                                 int /*flags*/,
    5624              :                                 bool* no_add_attrs)
    5625              : {
    5626           35 :   if (!SUPPORTS_INIT_PRIORITY)
    5627              :     /* Treat init_priority as an unrecognized attribute (mirroring
    5628              :        __has_attribute) if the target doesn't support init priorities.  */
    5629              :     return error_mark_node;
    5630              : 
    5631           35 :   tree initp_expr = TREE_VALUE (args);
    5632           35 :   tree decl = *node;
    5633           35 :   tree type = TREE_TYPE (decl);
    5634           35 :   int pri;
    5635              : 
    5636           35 :   STRIP_NOPS (initp_expr);
    5637           35 :   initp_expr = default_conversion (initp_expr);
    5638           35 :   if (initp_expr)
    5639           35 :     initp_expr = maybe_constant_value (initp_expr);
    5640              : 
    5641           35 :   if (!initp_expr || TREE_CODE (initp_expr) != INTEGER_CST)
    5642              :     {
    5643            0 :       error ("requested %<init_priority%> is not an integer constant");
    5644            0 :       cxx_constant_value (initp_expr);
    5645            0 :       *no_add_attrs = true;
    5646            0 :       return NULL_TREE;
    5647              :     }
    5648              : 
    5649           35 :   pri = TREE_INT_CST_LOW (initp_expr);
    5650              : 
    5651           35 :   type = strip_array_types (type);
    5652              : 
    5653           35 :   if (decl == NULL_TREE
    5654           35 :       || !VAR_P (decl)
    5655           35 :       || !TREE_STATIC (decl)
    5656           35 :       || DECL_EXTERNAL (decl)
    5657           35 :       || (TREE_CODE (type) != RECORD_TYPE
    5658           35 :           && TREE_CODE (type) != UNION_TYPE)
    5659              :       /* Static objects in functions are initialized the
    5660              :          first time control passes through that
    5661              :          function. This is not precise enough to pin down an
    5662              :          init_priority value, so don't allow it.  */
    5663           70 :       || current_function_decl)
    5664              :     {
    5665            0 :       error ("can only use %qE attribute on file-scope definitions "
    5666              :              "of objects of class type", name);
    5667            0 :       *no_add_attrs = true;
    5668            0 :       return NULL_TREE;
    5669              :     }
    5670              : 
    5671           35 :   if (pri > MAX_INIT_PRIORITY || pri <= 0)
    5672              :     {
    5673            0 :       error ("requested %<init_priority%> %i is out of range [0, %i]",
    5674              :              pri, MAX_INIT_PRIORITY);
    5675            0 :       *no_add_attrs = true;
    5676            0 :       return NULL_TREE;
    5677              :     }
    5678              : 
    5679              :   /* Check for init_priorities that are reserved for
    5680              :      language and runtime support implementations.*/
    5681           35 :   if (pri <= MAX_RESERVED_INIT_PRIORITY
    5682           35 :       && !in_system_header_at (input_location))
    5683              :     {
    5684           10 :       warning
    5685           10 :         (OPT_Wprio_ctor_dtor,
    5686              :          "requested %<init_priority%> %i is reserved for internal use",
    5687              :          pri);
    5688              :     }
    5689              : 
    5690           35 :   SET_DECL_INIT_PRIORITY (decl, pri);
    5691           35 :   DECL_HAS_INIT_PRIORITY_P (decl) = 1;
    5692           35 :   return NULL_TREE;
    5693              : }
    5694              : 
    5695              : /* DECL is being redeclared; the old declaration had the abi tags in OLD,
    5696              :    and the new one has the tags in NEW_.  Give an error if there are tags
    5697              :    in NEW_ that weren't in OLD.  */
    5698              : 
    5699              : bool
    5700     10869406 : check_abi_tag_redeclaration (const_tree decl, const_tree old, const_tree new_)
    5701              : {
    5702     10935805 :   if (old && TREE_CODE (TREE_VALUE (old)) == TREE_LIST)
    5703              :     old = TREE_VALUE (old);
    5704     10890678 :   if (new_ && TREE_CODE (TREE_VALUE (new_)) == TREE_LIST)
    5705              :     new_ = TREE_VALUE (new_);
    5706     10869406 :   bool err = false;
    5707     10869406 :   auto_diagnostic_group d;
    5708     10890678 :   for (const_tree t = new_; t; t = TREE_CHAIN (t))
    5709              :     {
    5710        21272 :       tree str = TREE_VALUE (t);
    5711        21272 :       for (const_tree in = old; in; in = TREE_CHAIN (in))
    5712              :         {
    5713        21263 :           tree ostr = TREE_VALUE (in);
    5714        21263 :           if (cp_tree_equal (str, ostr))
    5715        21263 :             goto found;
    5716              :         }
    5717            9 :       error ("redeclaration of %qD adds abi tag %qE", decl, str);
    5718            9 :       err = true;
    5719        21272 :     found:;
    5720              :     }
    5721     10869406 :   if (err)
    5722              :     {
    5723            9 :       inform (DECL_SOURCE_LOCATION (decl), "previous declaration here");
    5724            9 :       return false;
    5725              :     }
    5726              :   return true;
    5727     10869406 : }
    5728              : 
    5729              : /* The abi_tag attribute with the name NAME was given ARGS.  If they are
    5730              :    ill-formed, give an error and return false; otherwise, return true.  */
    5731              : 
    5732              : bool
    5733       416484 : check_abi_tag_args (tree args, tree name)
    5734              : {
    5735       416484 :   if (!args)
    5736              :     {
    5737            0 :       error ("the %qE attribute requires arguments", name);
    5738            0 :       return false;
    5739              :     }
    5740       833007 :   for (tree arg = args; arg; arg = TREE_CHAIN (arg))
    5741              :     {
    5742       416535 :       tree elt = TREE_VALUE (arg);
    5743       416535 :       if (TREE_CODE (elt) != STRING_CST
    5744       833064 :           || (!same_type_ignoring_top_level_qualifiers_p
    5745       416529 :               (strip_array_types (TREE_TYPE (elt)),
    5746              :                char_type_node)))
    5747              :         {
    5748            9 :           error ("arguments to the %qE attribute must be narrow string "
    5749              :                  "literals", name);
    5750            9 :           return false;
    5751              :         }
    5752       416526 :       const char *begin = TREE_STRING_POINTER (elt);
    5753       416526 :       const char *end = begin + TREE_STRING_LENGTH (elt);
    5754      2969422 :       for (const char *p = begin; p != end; ++p)
    5755              :         {
    5756      2552899 :           char c = *p;
    5757      2552899 :           if (p == begin)
    5758              :             {
    5759       416526 :               if (!ISALPHA (c) && c != '_')
    5760              :                 {
    5761            3 :                   auto_diagnostic_group d;
    5762            3 :                   error ("arguments to the %qE attribute must contain valid "
    5763              :                          "identifiers", name);
    5764            3 :                   inform (input_location, "%<%c%> is not a valid first "
    5765              :                           "character for an identifier", c);
    5766            3 :                   return false;
    5767            3 :                 }
    5768              :             }
    5769      2136373 :           else if (p == end - 1)
    5770       416523 :             gcc_assert (c == 0);
    5771              :           else
    5772              :             {
    5773      1719850 :               if (!ISALNUM (c) && c != '_')
    5774              :                 {
    5775            0 :                   auto_diagnostic_group d;
    5776            0 :                   error ("arguments to the %qE attribute must contain valid "
    5777              :                          "identifiers", name);
    5778            0 :                   inform (input_location, "%<%c%> is not a valid character "
    5779              :                           "in an identifier", c);
    5780            0 :                   return false;
    5781            0 :                 }
    5782              :             }
    5783              :         }
    5784              :     }
    5785              :   return true;
    5786              : }
    5787              : 
    5788              : /* Handle an "abi_tag" attribute; arguments as in
    5789              :    struct attribute_spec.handler.  */
    5790              : 
    5791              : static tree
    5792       370640 : handle_abi_tag_attribute (tree* node, tree name, tree args,
    5793              :                           int flags, bool* no_add_attrs)
    5794              : {
    5795       370640 :   if (!check_abi_tag_args (args, name))
    5796           12 :     goto fail;
    5797              : 
    5798       370628 :   if (TYPE_P (*node))
    5799              :     {
    5800        10875 :       if (!OVERLOAD_TYPE_P (*node))
    5801              :         {
    5802            0 :           error ("%qE attribute applied to non-class, non-enum type %qT",
    5803              :                  name, *node);
    5804            0 :           goto fail;
    5805              :         }
    5806        10875 :       else if (!(flags & (int)ATTR_FLAG_TYPE_IN_PLACE))
    5807              :         {
    5808            0 :           error ("%qE attribute applied to %qT after its definition",
    5809              :                  name, *node);
    5810            0 :           goto fail;
    5811              :         }
    5812        10872 :       else if (CLASS_TYPE_P (*node)
    5813        21747 :                && CLASSTYPE_TEMPLATE_INSTANTIATION (*node))
    5814              :         {
    5815            3 :           warning (OPT_Wattributes, "ignoring %qE attribute applied to "
    5816              :                    "template instantiation %qT", name, *node);
    5817            3 :           goto fail;
    5818              :         }
    5819        10869 :       else if (CLASS_TYPE_P (*node)
    5820        21741 :                && CLASSTYPE_TEMPLATE_SPECIALIZATION (*node))
    5821              :         {
    5822            3 :           warning (OPT_Wattributes, "ignoring %qE attribute applied to "
    5823              :                    "template specialization %qT", name, *node);
    5824            3 :           goto fail;
    5825              :         }
    5826              : 
    5827        10869 :       tree attributes = TYPE_ATTRIBUTES (*node);
    5828        10869 :       tree decl = TYPE_NAME (*node);
    5829              : 
    5830              :       /* Make sure all declarations have the same abi tags.  */
    5831        10869 :       if (DECL_SOURCE_LOCATION (decl) != input_location)
    5832              :         {
    5833            6 :           if (!check_abi_tag_redeclaration (decl,
    5834            6 :                                             lookup_attribute ("abi_tag",
    5835              :                                                               attributes),
    5836              :                                             args))
    5837            6 :             goto fail;
    5838              :         }
    5839              :     }
    5840              :   else
    5841              :     {
    5842       359753 :       if (!VAR_OR_FUNCTION_DECL_P (*node))
    5843              :         {
    5844            0 :           error ("%qE attribute applied to non-function, non-variable %qD",
    5845              :                  name, *node);
    5846            0 :           goto fail;
    5847              :         }
    5848       359753 :       else if (DECL_LANGUAGE (*node) == lang_c)
    5849              :         {
    5850            0 :           error ("%qE attribute applied to extern \"C\" declaration %qD",
    5851              :                  name, *node);
    5852            0 :           goto fail;
    5853              :         }
    5854              :     }
    5855              : 
    5856              :   return NULL_TREE;
    5857              : 
    5858           24 :  fail:
    5859           24 :   *no_add_attrs = true;
    5860           24 :   return NULL_TREE;
    5861              : }
    5862              : 
    5863              : /* Handle a "no_dangling" attribute; arguments as in
    5864              :    struct attribute_spec.handler.  */
    5865              : 
    5866              : tree
    5867           96 : handle_no_dangling_attribute (tree *node, tree name, tree args, int,
    5868              :                               bool *no_add_attrs)
    5869              : {
    5870          147 :   if (args && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
    5871              :     {
    5872            3 :       error ("%qE attribute argument must be an expression that evaluates "
    5873              :              "to true or false", name);
    5874            3 :       *no_add_attrs = true;
    5875              :     }
    5876           93 :   else if (!FUNC_OR_METHOD_TYPE_P (*node)
    5877           51 :            && !RECORD_OR_UNION_TYPE_P (*node))
    5878              :     {
    5879           18 :       warning (OPT_Wattributes, "%qE attribute ignored", name);
    5880           18 :       *no_add_attrs = true;
    5881              :     }
    5882              : 
    5883           96 :   return NULL_TREE;
    5884              : }
    5885              : 
    5886              : /* Perform checking for annotations.  */
    5887              : 
    5888              : tree
    5889          392 : handle_annotation_attribute (tree *node, tree ARG_UNUSED (name),
    5890              :                              tree args, int ARG_UNUSED (flags),
    5891              :                              bool *no_add_attrs)
    5892              : {
    5893          392 :   if (TYPE_P (*node)
    5894           59 :       && TREE_CODE (*node) != ENUMERAL_TYPE
    5895           55 :       && TREE_CODE (*node) != RECORD_TYPE
    5896           12 :       && TREE_CODE (*node) != UNION_TYPE)
    5897              :     {
    5898           12 :       error ("annotation on a type other than class or enumeration "
    5899              :              "definition");
    5900           12 :       *no_add_attrs = true;
    5901           12 :       return NULL_TREE;
    5902              :     }
    5903          380 :   if (TREE_CODE (*node) == LABEL_DECL)
    5904              :     {
    5905            3 :       error ("annotation applied to a label");
    5906            3 :       *no_add_attrs = true;
    5907            3 :       return NULL_TREE;
    5908              :     }
    5909          377 :   if (TREE_CODE (*node) == FIELD_DECL && DECL_UNNAMED_BIT_FIELD (*node))
    5910              :     {
    5911            1 :       error ("annotation on unnamed bit-field");
    5912            1 :       *no_add_attrs = true;
    5913            1 :       return NULL_TREE;
    5914              :     }
    5915          376 :   if (TREE_CODE (*node) == PARM_DECL && VOID_TYPE_P (TREE_TYPE (*node)))
    5916              :     {
    5917            1 :       error ("annotation on void parameter");
    5918            1 :       *no_add_attrs = true;
    5919            1 :       return NULL_TREE;
    5920              :     }
    5921          375 :   if (!type_dependent_expression_p (TREE_VALUE (args)))
    5922              :     {
    5923          375 :       if (!structural_type_p (TREE_TYPE (TREE_VALUE (args))))
    5924              :         {
    5925           51 :           auto_diagnostic_group d;
    5926           51 :           error ("annotation does not have structural type");
    5927           51 :           structural_type_p (TREE_TYPE (TREE_VALUE (args)), true);
    5928           51 :           *no_add_attrs = true;
    5929           51 :           return NULL_TREE;
    5930           51 :         }
    5931          324 :       if (CLASS_TYPE_P (TREE_TYPE (TREE_VALUE (args))))
    5932              :         {
    5933           30 :           tree arg = make_tree_vec (1);
    5934           30 :           tree type = TREE_TYPE (TREE_VALUE (args));
    5935           30 :           TREE_VEC_ELT (arg, 0)
    5936           30 :             = build_stub_type (type, cp_type_quals (type) | TYPE_QUAL_CONST,
    5937              :                                /*rvalue=*/false);
    5938           30 :           if (!is_xible (INIT_EXPR, type, arg))
    5939              :             {
    5940            2 :               auto_diagnostic_group d;
    5941            2 :               error ("annotation does not have copy constructible type");
    5942            2 :               is_xible (INIT_EXPR, type, arg, /*explain=*/true);
    5943            2 :               *no_add_attrs = true;
    5944            2 :               return NULL_TREE;
    5945            2 :             }
    5946              :         }
    5947              :     }
    5948          322 :   if (!processing_template_decl)
    5949              :     {
    5950          318 :       location_t loc = EXPR_LOCATION (TREE_VALUE (args));
    5951          318 :       TREE_VALUE (args) = cxx_constant_value (TREE_VALUE (args));
    5952          318 :       if (error_operand_p (TREE_VALUE (args)))
    5953            2 :         *no_add_attrs = true;
    5954          318 :       auto suppression
    5955          318 :         = make_temp_override (suppress_location_wrappers, 0);
    5956          318 :       TREE_VALUE (args) = maybe_wrap_with_location (TREE_VALUE (args), loc);
    5957          318 :     }
    5958          322 :   ATTR_UNIQUE_VALUE_P (args) = 1;
    5959          322 :   return NULL_TREE;
    5960              : }
    5961              : 
    5962              : /* Return a new PTRMEM_CST of the indicated TYPE.  The MEMBER is the
    5963              :    thing pointed to by the constant.  */
    5964              : 
    5965              : tree
    5966        61428 : make_ptrmem_cst (tree type, tree member)
    5967              : {
    5968        61428 :   tree ptrmem_cst = make_node (PTRMEM_CST);
    5969        61428 :   TREE_TYPE (ptrmem_cst) = type;
    5970        61428 :   PTRMEM_CST_MEMBER (ptrmem_cst) = member;
    5971        61428 :   PTRMEM_CST_LOCATION (ptrmem_cst) = input_location;
    5972        61428 :   return ptrmem_cst;
    5973              : }
    5974              : 
    5975              : /* Build a variant of TYPE that has the indicated ATTRIBUTES.  May
    5976              :    return an existing type if an appropriate type already exists.  */
    5977              : 
    5978              : tree
    5979     15905044 : cp_build_type_attribute_variant (tree type, tree attributes)
    5980              : {
    5981     15905044 :   tree new_type;
    5982              : 
    5983     15905044 :   new_type = build_type_attribute_variant (type, attributes);
    5984     15905044 :   if (FUNC_OR_METHOD_TYPE_P (new_type))
    5985     15834421 :     gcc_checking_assert (cxx_type_hash_eq (type, new_type));
    5986              : 
    5987              :   /* Making a new main variant of a class type is broken.  */
    5988     15905044 :   gcc_assert (!CLASS_TYPE_P (type) || new_type == type);
    5989              : 
    5990     15905044 :   return new_type;
    5991              : }
    5992              : 
    5993              : /* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes.
    5994              :    Called only after doing all language independent checks.  */
    5995              : 
    5996              : bool
    5997    333502935 : cxx_type_hash_eq (const_tree typea, const_tree typeb)
    5998              : {
    5999    333502935 :   gcc_assert (FUNC_OR_METHOD_TYPE_P (typea));
    6000              : 
    6001    333502935 :   if (type_memfn_rqual (typea) != type_memfn_rqual (typeb))
    6002              :     return false;
    6003    333497685 :   if (TYPE_HAS_LATE_RETURN_TYPE (typea) != TYPE_HAS_LATE_RETURN_TYPE (typeb))
    6004              :     return false;
    6005    333496667 :   return comp_except_specs (TYPE_RAISES_EXCEPTIONS (typea),
    6006    666993334 :                             TYPE_RAISES_EXCEPTIONS (typeb), ce_exact);
    6007              : }
    6008              : 
    6009              : /* Copy the language-specific type variant modifiers from TYPEB to TYPEA.  For
    6010              :    C++, these are the exception-specifier and ref-qualifier.  */
    6011              : 
    6012              : tree
    6013     26688217 : cxx_copy_lang_qualifiers (const_tree typea, const_tree typeb)
    6014              : {
    6015     26688217 :   tree type = const_cast<tree> (typea);
    6016     26688217 :   if (FUNC_OR_METHOD_TYPE_P (type))
    6017     26687158 :     type = build_cp_fntype_variant (type, type_memfn_rqual (typeb),
    6018     26687158 :                                     TYPE_RAISES_EXCEPTIONS (typeb),
    6019     26687158 :                                     TYPE_HAS_LATE_RETURN_TYPE (typeb));
    6020     26688217 :   return type;
    6021              : }
    6022              : 
    6023              : /* Apply FUNC to all language-specific sub-trees of TP in a pre-order
    6024              :    traversal.  Called from walk_tree.  */
    6025              : 
    6026              : tree
    6027  25121553434 : cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
    6028              :                   void *data, hash_set<tree> *pset)
    6029              : {
    6030  25121553434 :   tree t = *tp;
    6031  25121553434 :   enum tree_code code = TREE_CODE (t);
    6032  25121553434 :   tree result;
    6033              : 
    6034              : #define WALK_SUBTREE(NODE)                              \
    6035              :   do                                                    \
    6036              :     {                                                   \
    6037              :       result = cp_walk_tree (&(NODE), func, data, pset);    \
    6038              :       if (result) goto out;                             \
    6039              :     }                                                   \
    6040              :   while (0)
    6041              : 
    6042  25121553434 :   if (TYPE_P (t))
    6043              :     {
    6044              :       /* If *WALK_SUBTREES_P is 1, we're interested in the syntactic form of
    6045              :          the argument, so don't look through typedefs, but do walk into
    6046              :          template arguments for alias templates (and non-typedefed classes).
    6047              : 
    6048              :          If *WALK_SUBTREES_P > 1, we're interested in type identity or
    6049              :          equivalence, so look through typedefs, ignoring template arguments for
    6050              :          alias templates, and walk into template args of classes.
    6051              : 
    6052              :          See find_abi_tags_r for an example of setting *WALK_SUBTREES_P to 2
    6053              :          when that's the behavior the walk_tree_fn wants.  */
    6054   6753062827 :       if (*walk_subtrees_p == 1 && typedef_variant_p (t))
    6055              :         {
    6056     23990155 :           if (tree ti = TYPE_ALIAS_TEMPLATE_INFO (t))
    6057     16337684 :             WALK_SUBTREE (TI_ARGS (ti));
    6058     23951259 :           *walk_subtrees_p = 0;
    6059     23951259 :           return NULL_TREE;
    6060              :         }
    6061              : 
    6062   6729072672 :       if (tree ti = TYPE_TEMPLATE_INFO (t))
    6063    600832299 :         WALK_SUBTREE (TI_ARGS (ti));
    6064              :     }
    6065              : 
    6066              :   /* Not one of the easy cases.  We must explicitly go through the
    6067              :      children.  */
    6068  25097390792 :   result = NULL_TREE;
    6069  25097390792 :   switch (code)
    6070              :     {
    6071   1749730665 :     case TEMPLATE_TYPE_PARM:
    6072   1749730665 :       if (template_placeholder_p (t))
    6073      1571504 :         WALK_SUBTREE (CLASS_PLACEHOLDER_TEMPLATE (t));
    6074              :       /* Fall through.  */
    6075   1889034281 :     case DEFERRED_PARSE:
    6076   1889034281 :     case TEMPLATE_TEMPLATE_PARM:
    6077   1889034281 :     case BOUND_TEMPLATE_TEMPLATE_PARM:
    6078   1889034281 :     case UNBOUND_CLASS_TEMPLATE:
    6079   1889034281 :     case TEMPLATE_PARM_INDEX:
    6080   1889034281 :     case TYPEOF_TYPE:
    6081              :       /* None of these have subtrees other than those already walked
    6082              :          above.  */
    6083   1889034281 :       *walk_subtrees_p = 0;
    6084   1889034281 :       break;
    6085              : 
    6086    168503870 :     case TYPENAME_TYPE:
    6087    168503870 :       WALK_SUBTREE (TYPE_CONTEXT (t));
    6088    168401140 :       WALK_SUBTREE (TYPENAME_TYPE_FULLNAME (t));
    6089    168399648 :       *walk_subtrees_p = 0;
    6090    168399648 :       break;
    6091              : 
    6092     75973192 :     case BASELINK:
    6093     75973192 :       if (BASELINK_QUALIFIED_P (t))
    6094      1436306 :         WALK_SUBTREE (BINFO_TYPE (BASELINK_ACCESS_BINFO (t)));
    6095     75973192 :       WALK_SUBTREE (BASELINK_FUNCTIONS (t));
    6096     75880116 :       *walk_subtrees_p = 0;
    6097     75880116 :       break;
    6098              : 
    6099       152946 :     case PTRMEM_CST:
    6100       152946 :       WALK_SUBTREE (TREE_TYPE (t));
    6101       152946 :       *walk_subtrees_p = 0;
    6102       152946 :       break;
    6103              : 
    6104    285129130 :     case TREE_LIST:
    6105    285129130 :       WALK_SUBTREE (TREE_PURPOSE (t));
    6106              :       break;
    6107              : 
    6108    282785121 :     case OVERLOAD:
    6109    282785121 :       WALK_SUBTREE (OVL_FUNCTION (t));
    6110    282785116 :       WALK_SUBTREE (OVL_CHAIN (t));
    6111    282785116 :       *walk_subtrees_p = 0;
    6112    282785116 :       break;
    6113              : 
    6114      7658147 :     case USING_DECL:
    6115      7658147 :       WALK_SUBTREE (DECL_NAME (t));
    6116      7658147 :       WALK_SUBTREE (USING_DECL_SCOPE (t));
    6117      7658144 :       WALK_SUBTREE (USING_DECL_DECLS (t));
    6118      7658144 :       *walk_subtrees_p = 0;
    6119      7658144 :       break;
    6120              : 
    6121    689892597 :     case RECORD_TYPE:
    6122    689892597 :       if (TYPE_PTRMEMFUNC_P (t))
    6123      5068433 :         WALK_SUBTREE (TYPE_PTRMEMFUNC_FN_TYPE_RAW (t));
    6124              :       break;
    6125              : 
    6126    122776918 :     case TYPE_ARGUMENT_PACK:
    6127    122776918 :     case NONTYPE_ARGUMENT_PACK:
    6128    122776918 :       {
    6129    122776918 :         tree args = ARGUMENT_PACK_ARGS (t);
    6130    316021587 :         for (tree arg : tree_vec_range (args))
    6131    193337195 :           WALK_SUBTREE (arg);
    6132              :       }
    6133    122684392 :       break;
    6134              : 
    6135     24452624 :     case TYPE_PACK_EXPANSION:
    6136     24452624 :       WALK_SUBTREE (TREE_TYPE (t));
    6137     24446911 :       WALK_SUBTREE (PACK_EXPANSION_EXTRA_ARGS (t));
    6138     24446911 :       *walk_subtrees_p = 0;
    6139     24446911 :       break;
    6140              : 
    6141      5170257 :     case EXPR_PACK_EXPANSION:
    6142      5170257 :       WALK_SUBTREE (TREE_OPERAND (t, 0));
    6143      5167304 :       WALK_SUBTREE (PACK_EXPANSION_EXTRA_ARGS (t));
    6144      5167304 :       *walk_subtrees_p = 0;
    6145      5167304 :       break;
    6146              : 
    6147         7854 :     case PACK_INDEX_TYPE:
    6148         7854 :     case PACK_INDEX_EXPR:
    6149         7854 :       WALK_SUBTREE (PACK_INDEX_PACK (t));
    6150         7854 :       WALK_SUBTREE (PACK_INDEX_INDEX (t));
    6151         7854 :       *walk_subtrees_p = 0;
    6152         7854 :       break;
    6153              : 
    6154     99510085 :     case CAST_EXPR:
    6155     99510085 :     case REINTERPRET_CAST_EXPR:
    6156     99510085 :     case STATIC_CAST_EXPR:
    6157     99510085 :     case CONST_CAST_EXPR:
    6158     99510085 :     case DYNAMIC_CAST_EXPR:
    6159     99510085 :     case IMPLICIT_CONV_EXPR:
    6160     99510085 :     case BIT_CAST_EXPR:
    6161     99510085 :       if (TREE_TYPE (t))
    6162     99510085 :         WALK_SUBTREE (TREE_TYPE (t));
    6163              :       break;
    6164              : 
    6165    122706310 :     case CONSTRUCTOR:
    6166    122706310 :       if (COMPOUND_LITERAL_P (t))
    6167      8474282 :         WALK_SUBTREE (TREE_TYPE (t));
    6168              :       break;
    6169              : 
    6170     13198473 :     case TRAIT_EXPR:
    6171     13198473 :       WALK_SUBTREE (TRAIT_EXPR_TYPE1 (t));
    6172     13198461 :       WALK_SUBTREE (TRAIT_EXPR_TYPE2 (t));
    6173     13198461 :       *walk_subtrees_p = 0;
    6174     13198461 :       break;
    6175              : 
    6176      1236698 :     case TRAIT_TYPE:
    6177      1236698 :       WALK_SUBTREE (TRAIT_TYPE_TYPE1 (t));
    6178      1236698 :       WALK_SUBTREE (TRAIT_TYPE_TYPE2 (t));
    6179      1236698 :       *walk_subtrees_p = 0;
    6180      1236698 :       break;
    6181              : 
    6182     14486072 :     case DECLTYPE_TYPE:
    6183     14486072 :       {
    6184     14486072 :         cp_unevaluated u;
    6185     14486072 :         WALK_SUBTREE (DECLTYPE_TYPE_EXPR (t));
    6186     14125879 :         *walk_subtrees_p = 0;
    6187     14125879 :         break;
    6188     14486072 :       }
    6189              : 
    6190     25594341 :     case ALIGNOF_EXPR:
    6191     25594341 :     case SIZEOF_EXPR:
    6192     25594341 :     case NOEXCEPT_EXPR:
    6193     25594341 :       {
    6194     25594341 :         cp_unevaluated u;
    6195     25594341 :         WALK_SUBTREE (TREE_OPERAND (t, 0));
    6196     22756658 :         *walk_subtrees_p = 0;
    6197     22756658 :         break;
    6198     25594341 :       }
    6199              : 
    6200     12048473 :     case REQUIRES_EXPR:
    6201     12048473 :       {
    6202     12048473 :         cp_unevaluated u;
    6203     20605408 :         for (tree parm = REQUIRES_EXPR_PARMS (t); parm; parm = DECL_CHAIN (parm))
    6204              :           /* Walk the types of each parameter, but not the parameter itself,
    6205              :              since doing so would cause false positives in the unexpanded pack
    6206              :              checker if the requires-expr introduces a function parameter pack,
    6207              :              e.g. requires (Ts... ts) { }.   */
    6208      8557322 :           WALK_SUBTREE (TREE_TYPE (parm));
    6209     12048086 :         WALK_SUBTREE (REQUIRES_EXPR_REQS (t));
    6210     12045117 :         *walk_subtrees_p = 0;
    6211     12045117 :         break;
    6212     12048473 :       }
    6213              : 
    6214    167697084 :     case DECL_EXPR:
    6215              :       /* User variables should be mentioned in BIND_EXPR_VARS
    6216              :          and their initializers and sizes walked when walking
    6217              :          the containing BIND_EXPR.  Compiler temporaries are
    6218              :          handled here.  And also normal variables in templates,
    6219              :          since do_poplevel doesn't build a BIND_EXPR then.  */
    6220    167697084 :       if (VAR_P (TREE_OPERAND (t, 0))
    6221    167697084 :           && (processing_template_decl
    6222    153246550 :               || (DECL_ARTIFICIAL (TREE_OPERAND (t, 0))
    6223     12989015 :                   && !TREE_STATIC (TREE_OPERAND (t, 0)))))
    6224              :         {
    6225     20885719 :           tree decl = TREE_OPERAND (t, 0);
    6226     20885719 :           WALK_SUBTREE (TREE_TYPE (decl));
    6227     20885719 :           WALK_SUBTREE (DECL_INITIAL (decl));
    6228     20885689 :           WALK_SUBTREE (DECL_SIZE (decl));
    6229     20885689 :           WALK_SUBTREE (DECL_SIZE_UNIT (decl));
    6230              :         }
    6231              :       break;
    6232              : 
    6233      1769424 :     case LAMBDA_EXPR:
    6234              :       /* Don't walk into the body of the lambda, but the capture initializers
    6235              :          are part of the enclosing context.  */
    6236      4200160 :       for (tree cap = LAMBDA_EXPR_CAPTURE_LIST (t); cap;
    6237      2430736 :            cap = TREE_CHAIN (cap))
    6238      2430736 :         WALK_SUBTREE (TREE_VALUE (cap));
    6239              :       break;
    6240              : 
    6241         3285 :     case CO_YIELD_EXPR:
    6242         3285 :       if (TREE_OPERAND (t, 1))
    6243              :         /* Operand 1 is the tree for the relevant co_await which has any
    6244              :            interesting sub-trees.  */
    6245          587 :         WALK_SUBTREE (TREE_OPERAND (t, 1));
    6246              :       break;
    6247              : 
    6248        26863 :     case CO_AWAIT_EXPR:
    6249        26863 :       if (TREE_OPERAND (t, 1))
    6250              :         /* Operand 1 is frame variable.  */
    6251        26675 :         WALK_SUBTREE (TREE_OPERAND (t, 1));
    6252        26863 :       if (TREE_OPERAND (t, 2))
    6253              :         /* Operand 2 has the initialiser, and we need to walk any subtrees
    6254              :            there.  */
    6255         5367 :         WALK_SUBTREE (TREE_OPERAND (t, 2));
    6256              :       break;
    6257              : 
    6258          881 :     case CO_RETURN_EXPR:
    6259          881 :       if (TREE_OPERAND (t, 0))
    6260              :         {
    6261          698 :           if (VOID_TYPE_P (TREE_OPERAND (t, 0)))
    6262              :             /* For void expressions, operand 1 is a trivial call, and any
    6263              :                interesting subtrees will be part of operand 0.  */
    6264            0 :             WALK_SUBTREE (TREE_OPERAND (t, 0));
    6265          698 :           else if (TREE_OPERAND (t, 1))
    6266              :             /* Interesting sub-trees will be in the return_value () call
    6267              :                arguments.  */
    6268          656 :             WALK_SUBTREE (TREE_OPERAND (t, 1));
    6269              :         }
    6270              :       break;
    6271              : 
    6272       568694 :     case STATIC_ASSERT:
    6273       568694 :       WALK_SUBTREE (STATIC_ASSERT_CONDITION (t));
    6274       568694 :       WALK_SUBTREE (STATIC_ASSERT_MESSAGE (t));
    6275              :       break;
    6276              : 
    6277    725376766 :     case INTEGER_TYPE:
    6278              :       /* Removed from walk_type_fields in r119481.  */
    6279    725376766 :       WALK_SUBTREE (TYPE_MIN_VALUE (t));
    6280    725376766 :       WALK_SUBTREE (TYPE_MAX_VALUE (t));
    6281              :       break;
    6282              : 
    6283          199 :     case SPLICE_SCOPE:
    6284          199 :       WALK_SUBTREE (SPLICE_SCOPE_EXPR (t));
    6285          199 :       *walk_subtrees_p = 0;
    6286          199 :       break;
    6287              : 
    6288              :     default:
    6289              :       return NULL_TREE;
    6290              :     }
    6291              : 
    6292              :   /* We didn't find what we were looking for.  */
    6293              :  out:
    6294              :   return result;
    6295              : 
    6296              : #undef WALK_SUBTREE
    6297              : }
    6298              : 
    6299              : /* Like save_expr, but for C++.  */
    6300              : 
    6301              : tree
    6302       315184 : cp_save_expr (tree expr)
    6303              : {
    6304              :   /* There is no reason to create a SAVE_EXPR within a template; if
    6305              :      needed, we can create the SAVE_EXPR when instantiating the
    6306              :      template.  Furthermore, the middle-end cannot handle C++-specific
    6307              :      tree codes.  */
    6308       315184 :   if (processing_template_decl)
    6309              :     return expr;
    6310              : 
    6311              :   /* TARGET_EXPRs are only expanded once.  */
    6312       243925 :   if (TREE_CODE (expr) == TARGET_EXPR)
    6313              :     return expr;
    6314              : 
    6315       243925 :   return save_expr (expr);
    6316              : }
    6317              : 
    6318              : /* Initialize tree.cc.  */
    6319              : 
    6320              : void
    6321        98033 : init_tree (void)
    6322              : {
    6323        98033 :   list_hash_table = hash_table<list_hasher>::create_ggc (61);
    6324        98033 : }
    6325              : 
    6326              : /* Returns the kind of special function that DECL (a FUNCTION_DECL)
    6327              :    is.  Note that sfk_none is zero, so this function can be used as a
    6328              :    predicate to test whether or not DECL is a special function.  */
    6329              : 
    6330              : special_function_kind
    6331    177782362 : special_function_p (const_tree decl)
    6332              : {
    6333              :   /* Rather than doing all this stuff with magic names, we should
    6334              :      probably have a field of type `special_function_kind' in
    6335              :      DECL_LANG_SPECIFIC.  */
    6336    355564724 :   if (DECL_INHERITED_CTOR (decl))
    6337              :     return sfk_inheriting_constructor;
    6338    354587954 :   if (DECL_COPY_CONSTRUCTOR_P (decl))
    6339              :     return sfk_copy_constructor;
    6340    315247224 :   if (DECL_MOVE_CONSTRUCTOR_P (decl))
    6341              :     return sfk_move_constructor;
    6342    294367200 :   if (DECL_CONSTRUCTOR_P (decl))
    6343              :     return sfk_constructor;
    6344    123298598 :   if (DECL_ASSIGNMENT_OPERATOR_P (decl)
    6345    123298598 :       && DECL_OVERLOADED_OPERATOR_IS (decl, NOP_EXPR))
    6346              :     {
    6347     17530918 :       if (copy_fn_p (decl))
    6348              :         return sfk_copy_assignment;
    6349      6965768 :       if (move_fn_p (decl))
    6350              :         return sfk_move_assignment;
    6351              :     }
    6352    105969400 :   if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl))
    6353              :     return sfk_destructor;
    6354     62674329 :   if (DECL_COMPLETE_DESTRUCTOR_P (decl))
    6355              :     return sfk_complete_destructor;
    6356     49494944 :   if (DECL_BASE_DESTRUCTOR_P (decl))
    6357              :     return sfk_base_destructor;
    6358     48599043 :   if (DECL_DELETING_DESTRUCTOR_P (decl))
    6359              :     return sfk_deleting_destructor;
    6360     37226519 :   if (DECL_CONV_FN_P (decl))
    6361              :     return sfk_conversion;
    6362     37225192 :   if (deduction_guide_p (decl))
    6363              :     return sfk_deduction_guide;
    6364     37134242 :   if (DECL_OVERLOADED_OPERATOR_CODE_RAW (decl) >= OVL_OP_EQ_EXPR
    6365     37134242 :       && DECL_OVERLOADED_OPERATOR_CODE_RAW (decl) <= OVL_OP_SPACESHIP_EXPR)
    6366      6412504 :     return sfk_comparison;
    6367              : 
    6368              :   return sfk_none;
    6369              : }
    6370              : 
    6371              : /* As above, but only if DECL is a special member function as per 11.3.3
    6372              :    [special]: default/copy/move ctor, copy/move assignment, or destructor.  */
    6373              : 
    6374              : special_function_kind
    6375      2970076 : special_memfn_p (const_tree decl)
    6376              : {
    6377      2970076 :   switch (special_function_kind sfk = special_function_p (decl))
    6378              :     {
    6379      2631807 :     case sfk_constructor:
    6380      2631807 :       if (!default_ctor_p (decl))
    6381              :         break;
    6382              :       gcc_fallthrough();
    6383              :     case sfk_copy_constructor:
    6384              :     case sfk_copy_assignment:
    6385              :     case sfk_move_assignment:
    6386              :     case sfk_move_constructor:
    6387              :     case sfk_destructor:
    6388              :       return sfk;
    6389              : 
    6390              :     default:
    6391              :       break;
    6392              :     }
    6393              :   return sfk_none;
    6394              : }
    6395              : 
    6396              : /* Returns nonzero if TYPE is a character type, including wchar_t.  */
    6397              : 
    6398              : int
    6399     13358947 : char_type_p (tree type)
    6400              : {
    6401     13358947 :   return (same_type_p (type, char_type_node)
    6402     12098806 :           || same_type_p (type, unsigned_char_type_node)
    6403     12022266 :           || same_type_p (type, signed_char_type_node)
    6404     12021728 :           || same_type_p (type, char8_type_node)
    6405     12021609 :           || same_type_p (type, char16_type_node)
    6406     12021111 :           || same_type_p (type, char32_type_node)
    6407     25232277 :           || same_type_p (type, wchar_type_node));
    6408              : }
    6409              : 
    6410              : /* Returns the kind of linkage associated with the indicated DECL.  The
    6411              :    value returned is as specified by the language standard; it is
    6412              :    independent of implementation details regarding template
    6413              :    instantiation, etc.  For example, it is possible that a declaration
    6414              :    to which this function assigns external linkage would not show up
    6415              :    as a global symbol when you run `nm' on the resulting object file.  */
    6416              : 
    6417              : linkage_kind
    6418    470367366 : decl_linkage (tree decl)
    6419              : {
    6420              :   /* This function doesn't attempt to calculate the linkage from first
    6421              :      principles as given in [basic.link].  Instead, it makes use of
    6422              :      the fact that we have already set TREE_PUBLIC appropriately, and
    6423              :      then handles a few special cases.  Ideally, we would calculate
    6424              :      linkage first, and then transform that into a concrete
    6425              :      implementation.  */
    6426              : 
    6427              :   /* An explicit type alias has no linkage.  Nor do the built-in declarations
    6428              :      of 'int' and such.  */
    6429    520631831 :   if (TREE_CODE (decl) == TYPE_DECL
    6430    520631831 :       && !DECL_IMPLICIT_TYPEDEF_P (decl))
    6431              :     {
    6432              :       /* But this could be a typedef name for linkage purposes, in which
    6433              :          case we're interested in the linkage of the main decl.  */
    6434       923559 :       tree type = TREE_TYPE (decl);
    6435       923559 :       if (type == error_mark_node)
    6436              :         return lk_none;
    6437       923557 :       else if (decl == TYPE_NAME (TYPE_MAIN_VARIANT (type))
    6438              :                /* Likewise for the injected-class-name.  */
    6439       923557 :                || DECL_SELF_REFERENCE_P (decl))
    6440        33479 :         decl = TYPE_MAIN_DECL (type);
    6441              :       else
    6442              :         return lk_none;
    6443              :     }
    6444              : 
    6445              :   /* Namespace-scope entities with no name usually have no linkage.  */
    6446    519741751 :   if (NAMESPACE_SCOPE_P (decl)
    6447    983395617 :       && (!DECL_NAME (decl) || IDENTIFIER_ANON_P (DECL_NAME (decl))))
    6448              :     {
    6449      3640725 :       if (TREE_CODE (decl) == TYPE_DECL && !TYPE_UNNAMED_P (TREE_TYPE (decl)))
    6450              :         /* This entity has a name for linkage purposes.  */;
    6451      3626815 :       else if (DECL_DECOMPOSITION_P (decl) && DECL_DECOMP_IS_BASE (decl))
    6452              :         /* Namespace-scope structured bindings can have linkage.  */;
    6453      3626715 :       else if (TREE_CODE (decl) == NAMESPACE_DECL && cxx_dialect >= cxx11)
    6454              :         /* An anonymous namespace has internal linkage since C++11.  */
    6455              :         return lk_internal;
    6456              :       else
    6457              :         return lk_none;
    6458              :     }
    6459              : 
    6460              :   /* Fields and parameters have no linkage.  */
    6461    516115036 :   if (TREE_CODE (decl) == FIELD_DECL || TREE_CODE (decl) == PARM_DECL)
    6462              :     return lk_none;
    6463              : 
    6464              :   /* Things in block scope do not have linkage.  */
    6465    471413450 :   if (decl_function_context (decl))
    6466              :     return lk_none;
    6467              : 
    6468              :   /* Things in class scope have the linkage of their owning class.  */
    6469    465591651 :   if (tree ctype = DECL_CLASS_CONTEXT (decl))
    6470     50264465 :     return decl_linkage (TYPE_NAME (ctype));
    6471              : 
    6472              :   /* Anonymous namespaces don't provide internal linkage in C++98,
    6473              :      but otherwise consider such declarations to be internal.  */
    6474    415327186 :   if (cxx_dialect >= cxx11 && decl_internal_context_p (decl))
    6475              :     return lk_internal;
    6476              : 
    6477              :   /* Templates don't properly propagate TREE_PUBLIC, consider the
    6478              :      template result instead.  Any template that isn't a variable
    6479              :      or function must be external linkage by this point.  */
    6480    415148262 :   if (TREE_CODE (decl) == TEMPLATE_DECL)
    6481              :     {
    6482       714135 :       decl = DECL_TEMPLATE_RESULT (decl);
    6483       714135 :       if (!decl || !VAR_OR_FUNCTION_DECL_P (decl))
    6484              :         return lk_external;
    6485              :     }
    6486              : 
    6487              :   /* Things that are TREE_PUBLIC have external linkage.  */
    6488    414845847 :   if (TREE_PUBLIC (decl))
    6489              :     return lk_external;
    6490              : 
    6491              :   /* All types have external linkage in C++98, since anonymous namespaces
    6492              :      didn't explicitly confer internal linkage.  */
    6493     86161381 :   if (TREE_CODE (decl) == TYPE_DECL && cxx_dialect < cxx11)
    6494              :     return lk_external;
    6495              : 
    6496              :   /* Variables or function decls not marked as TREE_PUBLIC might still
    6497              :      be external linkage, such as for template instantiations on targets
    6498              :      without weak symbols, decls referring to internal-linkage entities,
    6499              :      or compiler-generated entities; in such cases, decls really meant to
    6500              :      have internal linkage will have DECL_THIS_STATIC set.  */
    6501     86161377 :   if (VAR_OR_FUNCTION_DECL_P (decl) && !DECL_THIS_STATIC (decl))
    6502              :     return lk_external;
    6503              : 
    6504              :   /* Everything else has internal linkage.  */
    6505              :   return lk_internal;
    6506              : }
    6507              : 
    6508              : /* Returns the storage duration of the object or reference associated with
    6509              :    the indicated DECL, which should be a VAR_DECL or PARM_DECL.  */
    6510              : 
    6511              : duration_kind
    6512     71468011 : decl_storage_duration (tree decl)
    6513              : {
    6514     71468011 :   if (TREE_CODE (decl) == PARM_DECL)
    6515              :     return dk_auto;
    6516     71468005 :   if (TREE_CODE (decl) == FUNCTION_DECL)
    6517              :     return dk_static;
    6518     71468005 :   gcc_assert (VAR_P (decl));
    6519     71468005 :   if (!TREE_STATIC (decl)
    6520     71468005 :       && !DECL_EXTERNAL (decl))
    6521              :     return dk_auto;
    6522     40300269 :   if (CP_DECL_THREAD_LOCAL_P (decl))
    6523        20184 :     return dk_thread;
    6524              :   return dk_static;
    6525              : }
    6526              : 
    6527              : /* EXP is an expression that we want to pre-evaluate.  Returns (in
    6528              :    *INITP) an expression that will perform the pre-evaluation.  The
    6529              :    value returned by this function is a side-effect free expression
    6530              :    equivalent to the pre-evaluated expression.  Callers must ensure
    6531              :    that *INITP is evaluated before EXP.
    6532              : 
    6533              :    Note that if EXPR is a glvalue, the return value is a glvalue denoting the
    6534              :    same address; this function does not guard against modification of the
    6535              :    stored value like save_expr or get_target_expr do.  */
    6536              : 
    6537              : tree
    6538      5939308 : stabilize_expr (tree exp, tree* initp)
    6539              : {
    6540      5939308 :   tree init_expr;
    6541              : 
    6542      5939308 :   if (!TREE_SIDE_EFFECTS (exp))
    6543              :     init_expr = NULL_TREE;
    6544      1052441 :   else if (VOID_TYPE_P (TREE_TYPE (exp)))
    6545              :     {
    6546            0 :       init_expr = exp;
    6547            0 :       exp = void_node;
    6548              :     }
    6549              :   /* There are no expressions with REFERENCE_TYPE, but there can be call
    6550              :      arguments with such a type; just treat it as a pointer.  */
    6551      1052441 :   else if (TYPE_REF_P (TREE_TYPE (exp))
    6552      1052307 :            || SCALAR_TYPE_P (TREE_TYPE (exp))
    6553      1052487 :            || !glvalue_p (exp))
    6554              :     {
    6555      1052435 :       init_expr = get_target_expr (exp);
    6556      1052435 :       exp = TARGET_EXPR_SLOT (init_expr);
    6557      1052435 :       if (CLASS_TYPE_P (TREE_TYPE (exp)))
    6558            9 :         exp = move (exp);
    6559              :       else
    6560      1052426 :         exp = rvalue (exp);
    6561              :     }
    6562              :   else
    6563              :     {
    6564            6 :       bool xval = !lvalue_p (exp);
    6565            6 :       exp = cp_build_addr_expr (exp, tf_warning_or_error);
    6566            6 :       init_expr = get_target_expr (exp);
    6567            6 :       exp = TARGET_EXPR_SLOT (init_expr);
    6568            6 :       exp = cp_build_fold_indirect_ref (exp);
    6569            6 :       if (xval)
    6570            0 :         exp = move (exp);
    6571              :     }
    6572      5939308 :   *initp = init_expr;
    6573              : 
    6574      5939308 :   gcc_assert (!TREE_SIDE_EFFECTS (exp) || TREE_THIS_VOLATILE (exp));
    6575      5939308 :   return exp;
    6576              : }
    6577              : 
    6578              : /* Add NEW_EXPR, an expression whose value we don't care about, after the
    6579              :    similar expression ORIG.  */
    6580              : 
    6581              : tree
    6582      1261323 : add_stmt_to_compound (tree orig, tree new_expr)
    6583              : {
    6584      1261323 :   if (!new_expr || !TREE_SIDE_EFFECTS (new_expr))
    6585              :     return orig;
    6586       634166 :   if (!orig || !TREE_SIDE_EFFECTS (orig))
    6587              :     return new_expr;
    6588        12562 :   return build2 (COMPOUND_EXPR, void_type_node, orig, new_expr);
    6589              : }
    6590              : 
    6591              : /* Like stabilize_expr, but for a call whose arguments we want to
    6592              :    pre-evaluate.  CALL is modified in place to use the pre-evaluated
    6593              :    arguments, while, upon return, *INITP contains an expression to
    6594              :    compute the arguments.  */
    6595              : 
    6596              : void
    6597       622968 : stabilize_call (tree call, tree *initp)
    6598              : {
    6599       622968 :   tree inits = NULL_TREE;
    6600       622968 :   int i;
    6601       622968 :   int nargs = call_expr_nargs (call);
    6602              : 
    6603       622968 :   if (call == error_mark_node || processing_template_decl)
    6604              :     {
    6605           31 :       *initp = NULL_TREE;
    6606           31 :       return;
    6607              :     }
    6608              : 
    6609       622937 :   gcc_assert (TREE_CODE (call) == CALL_EXPR);
    6610              : 
    6611      1868892 :   for (i = 0; i < nargs; i++)
    6612              :     {
    6613      1245955 :       tree init;
    6614      1245955 :       CALL_EXPR_ARG (call, i) =
    6615      1245955 :         stabilize_expr (CALL_EXPR_ARG (call, i), &init);
    6616      1245955 :       inits = add_stmt_to_compound (inits, init);
    6617              :     }
    6618              : 
    6619       622937 :   *initp = inits;
    6620              : }
    6621              : 
    6622              : /* Like stabilize_expr, but for an AGGR_INIT_EXPR whose arguments we want
    6623              :    to pre-evaluate.  CALL is modified in place to use the pre-evaluated
    6624              :    arguments, while, upon return, *INITP contains an expression to
    6625              :    compute the arguments.  */
    6626              : 
    6627              : static void
    6628            0 : stabilize_aggr_init (tree call, tree *initp)
    6629              : {
    6630            0 :   tree inits = NULL_TREE;
    6631            0 :   int i;
    6632            0 :   int nargs = aggr_init_expr_nargs (call);
    6633              : 
    6634            0 :   if (call == error_mark_node)
    6635              :     return;
    6636              : 
    6637            0 :   gcc_assert (TREE_CODE (call) == AGGR_INIT_EXPR);
    6638              : 
    6639            0 :   for (i = 0; i < nargs; i++)
    6640              :     {
    6641            0 :       tree init;
    6642            0 :       AGGR_INIT_EXPR_ARG (call, i) =
    6643            0 :         stabilize_expr (AGGR_INIT_EXPR_ARG (call, i), &init);
    6644            0 :       inits = add_stmt_to_compound (inits, init);
    6645              :     }
    6646              : 
    6647            0 :   *initp = inits;
    6648              : }
    6649              : 
    6650              : /* Like stabilize_expr, but for an initialization.
    6651              : 
    6652              :    If the initialization is for an object of class type, this function
    6653              :    takes care not to introduce additional temporaries.
    6654              : 
    6655              :    Returns TRUE iff the expression was successfully pre-evaluated,
    6656              :    i.e., if INIT is now side-effect free, except for, possibly, a
    6657              :    single call to a constructor.  */
    6658              : 
    6659              : bool
    6660            0 : stabilize_init (tree init, tree *initp)
    6661              : {
    6662            0 :   tree t = init;
    6663              : 
    6664            0 :   *initp = NULL_TREE;
    6665              : 
    6666            0 :   if (t == error_mark_node || processing_template_decl)
    6667              :     return true;
    6668              : 
    6669            0 :   if (TREE_CODE (t) == INIT_EXPR)
    6670            0 :     t = TREE_OPERAND (t, 1);
    6671            0 :   if (TREE_CODE (t) == TARGET_EXPR)
    6672            0 :     t = TARGET_EXPR_INITIAL (t);
    6673              : 
    6674              :   /* If the RHS can be stabilized without breaking copy elision, stabilize
    6675              :      it.  We specifically don't stabilize class prvalues here because that
    6676              :      would mean an extra copy, but they might be stabilized below.  */
    6677            0 :   if (TREE_CODE (init) == INIT_EXPR
    6678            0 :       && TREE_CODE (t) != CONSTRUCTOR
    6679            0 :       && TREE_CODE (t) != AGGR_INIT_EXPR
    6680            0 :       && (SCALAR_TYPE_P (TREE_TYPE (t))
    6681            0 :           || glvalue_p (t)))
    6682              :     {
    6683            0 :       TREE_OPERAND (init, 1) = stabilize_expr (t, initp);
    6684            0 :       return true;
    6685              :     }
    6686              : 
    6687            0 :   if (TREE_CODE (t) == COMPOUND_EXPR
    6688            0 :       && TREE_CODE (init) == INIT_EXPR)
    6689              :     {
    6690            0 :       tree last = expr_last (t);
    6691              :       /* Handle stabilizing the EMPTY_CLASS_EXPR pattern.  */
    6692            0 :       if (!TREE_SIDE_EFFECTS (last))
    6693              :         {
    6694            0 :           *initp = t;
    6695            0 :           TREE_OPERAND (init, 1) = last;
    6696            0 :           return true;
    6697              :         }
    6698              :     }
    6699              : 
    6700            0 :   if (TREE_CODE (t) == CONSTRUCTOR)
    6701              :     {
    6702              :       /* Aggregate initialization: stabilize each of the field
    6703              :          initializers.  */
    6704            0 :       unsigned i;
    6705            0 :       constructor_elt *ce;
    6706            0 :       bool good = true;
    6707            0 :       vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (t);
    6708            0 :       for (i = 0; vec_safe_iterate (v, i, &ce); ++i)
    6709              :         {
    6710            0 :           tree type = TREE_TYPE (ce->value);
    6711            0 :           tree subinit;
    6712            0 :           if (TYPE_REF_P (type)
    6713            0 :               || SCALAR_TYPE_P (type))
    6714            0 :             ce->value = stabilize_expr (ce->value, &subinit);
    6715            0 :           else if (!stabilize_init (ce->value, &subinit))
    6716            0 :             good = false;
    6717            0 :           *initp = add_stmt_to_compound (*initp, subinit);
    6718              :         }
    6719              :       return good;
    6720              :     }
    6721              : 
    6722            0 :   if (TREE_CODE (t) == CALL_EXPR)
    6723              :     {
    6724            0 :       stabilize_call (t, initp);
    6725            0 :       return true;
    6726              :     }
    6727              : 
    6728            0 :   if (TREE_CODE (t) == AGGR_INIT_EXPR)
    6729              :     {
    6730            0 :       stabilize_aggr_init (t, initp);
    6731            0 :       return true;
    6732              :     }
    6733              : 
    6734              :   /* The initialization is being performed via a bitwise copy -- and
    6735              :      the item copied may have side effects.  */
    6736            0 :   return !TREE_SIDE_EFFECTS (init);
    6737              : }
    6738              : 
    6739              : /* Returns true if a cast to TYPE may appear in an integral constant
    6740              :    expression.  */
    6741              : 
    6742              : bool
    6743     92600590 : cast_valid_in_integral_constant_expression_p (tree type)
    6744              : {
    6745     92600590 :   return (INTEGRAL_OR_ENUMERATION_TYPE_P (type)
    6746     65999714 :           || cxx_dialect >= cxx11
    6747       472090 :           || dependent_type_p (type)
    6748     92977707 :           || type == error_mark_node);
    6749              : }
    6750              : 
    6751              : /* Return true if we need to fix linkage information of DECL.  */
    6752              : 
    6753              : static bool
    6754        74505 : cp_fix_function_decl_p (tree decl)
    6755              : {
    6756              :   /* Skip if DECL is not externally visible.  */
    6757        74505 :   if (!TREE_PUBLIC (decl))
    6758              :     return false;
    6759              : 
    6760              :   /* We need to fix DECL if it a appears to be exported but with no
    6761              :      function body.  Thunks do not have CFGs and we may need to
    6762              :      handle them specially later.   */
    6763        72283 :   if (!gimple_has_body_p (decl)
    6764        27207 :       && !DECL_THUNK_P (decl)
    6765        99104 :       && !DECL_EXTERNAL (decl))
    6766              :     {
    6767        12817 :       struct cgraph_node *node = cgraph_node::get (decl);
    6768              : 
    6769              :       /* Don't fix same_body aliases.  Although they don't have their own
    6770              :          CFG, they share it with what they alias to.  */
    6771        12817 :       if (!node || !node->alias || !node->num_references ())
    6772              :         return true;
    6773              :     }
    6774              : 
    6775              :   return false;
    6776              : }
    6777              : 
    6778              : /* Clean the C++ specific parts of the tree T. */
    6779              : 
    6780              : void
    6781       726340 : cp_free_lang_data (tree t)
    6782              : {
    6783       726340 :   if (FUNC_OR_METHOD_TYPE_P (t))
    6784              :     {
    6785              :       /* Default args are not interesting anymore.  */
    6786        59015 :       tree argtypes = TYPE_ARG_TYPES (t);
    6787       212667 :       while (argtypes)
    6788              :         {
    6789       153652 :           TREE_PURPOSE (argtypes) = 0;
    6790       153652 :           argtypes = TREE_CHAIN (argtypes);
    6791              :         }
    6792              :     }
    6793       667325 :   else if (TREE_CODE (t) == FUNCTION_DECL
    6794       667325 :            && cp_fix_function_decl_p (t))
    6795              :     {
    6796              :       /* If T is used in this translation unit at all,  the definition
    6797              :          must exist somewhere else since we have decided to not emit it
    6798              :          in this TU.  So make it an external reference.  */
    6799         6718 :       DECL_EXTERNAL (t) = 1;
    6800         6718 :       TREE_STATIC (t) = 0;
    6801              :     }
    6802       726340 :   if (TREE_CODE (t) == NAMESPACE_DECL)
    6803              :     /* We do not need the leftover chaining of namespaces from the
    6804              :        binding level.  */
    6805         1646 :     DECL_CHAIN (t) = NULL_TREE;
    6806       726340 : }
    6807              : 
    6808              : /* Stub for c-common.  Please keep in sync with c-decl.cc.
    6809              :    FIXME: If address space support is target specific, then this
    6810              :    should be a C target hook.  But currently this is not possible,
    6811              :    because this function is called via REGISTER_TARGET_PRAGMAS.  */
    6812              : void
    6813       196066 : c_register_addr_space (const char * /*word*/, addr_space_t /*as*/)
    6814              : {
    6815       196066 : }
    6816              : 
    6817              : /* Return the number of operands in T that we care about for things like
    6818              :    mangling.  */
    6819              : 
    6820              : int
    6821    605045230 : cp_tree_operand_length (const_tree t)
    6822              : {
    6823    605045230 :   enum tree_code code = TREE_CODE (t);
    6824              : 
    6825    605045230 :   if (TREE_CODE_CLASS (code) == tcc_vl_exp)
    6826     69410726 :     return VL_EXP_OPERAND_LENGTH (t);
    6827              : 
    6828    535634504 :   return cp_tree_code_length (code);
    6829              : }
    6830              : 
    6831              : /* Like cp_tree_operand_length, but takes a tree_code CODE.  */
    6832              : 
    6833              : int
    6834    541957292 : cp_tree_code_length (enum tree_code code)
    6835              : {
    6836    541957292 :   gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
    6837              : 
    6838    541957292 :   switch (code)
    6839              :     {
    6840              :     case PREINCREMENT_EXPR:
    6841              :     case PREDECREMENT_EXPR:
    6842              :     case POSTINCREMENT_EXPR:
    6843              :     case POSTDECREMENT_EXPR:
    6844              :       return 1;
    6845              : 
    6846      1013310 :     case ARRAY_REF:
    6847      1013310 :       return 2;
    6848              : 
    6849              :     case EXPR_PACK_EXPANSION:
    6850              :       return 1;
    6851              : 
    6852    538433570 :     default:
    6853    538433570 :       return TREE_CODE_LENGTH (code);
    6854              :     }
    6855              : }
    6856              : 
    6857              : /* Implement -Wzero_as_null_pointer_constant.  Return true if the
    6858              :    conditions for the warning hold, false otherwise.  */
    6859              : bool
    6860      7611224 : maybe_warn_zero_as_null_pointer_constant (tree expr, location_t loc)
    6861              : {
    6862      7611224 :   if (c_inhibit_evaluation_warnings == 0
    6863     14248037 :       && !null_node_p (expr) && !NULLPTR_TYPE_P (TREE_TYPE (expr)))
    6864              :     {
    6865      2678674 :       warning_at (loc, OPT_Wzero_as_null_pointer_constant,
    6866              :                   "zero as null pointer constant");
    6867      2678674 :       return true;
    6868              :     }
    6869              :   return false;
    6870              : }
    6871              : 
    6872              : /* FNDECL is a function declaration whose type may have been altered by
    6873              :    adding extra parameters such as this, in-charge, or VTT.  When this
    6874              :    takes place, the positional arguments supplied by the user (as in the
    6875              :    'format' attribute arguments) may refer to the wrong argument.  This
    6876              :    function returns an integer indicating how many arguments should be
    6877              :    skipped.  */
    6878              : 
    6879              : int
    6880     36701554 : maybe_adjust_arg_pos_for_attribute (const_tree fndecl)
    6881              : {
    6882     36701554 :   if (!fndecl)
    6883              :     return 0;
    6884      7127818 :   int n = num_artificial_parms_for (fndecl);
    6885              :   /* The manual states that it's the user's responsibility to account
    6886              :      for the implicit this parameter.  */
    6887      7127818 :   return n > 0 ? n - 1 : 0;
    6888              : }
    6889              : 
    6890              : /* True if ATTR is annotation.  */
    6891              : 
    6892              : bool
    6893     54143214 : annotation_p (tree attr)
    6894              : {
    6895     54143214 :   return is_attribute_p ("annotation ", get_attribute_name (attr));
    6896              : }
    6897              : 
    6898              : 
    6899              : /* Release memory we no longer need after parsing.  */
    6900              : void
    6901        96437 : cp_tree_c_finish_parsing ()
    6902              : {
    6903        96437 :   if (previous_class_level)
    6904        67723 :     invalidate_class_lookup_cache ();
    6905        96437 :   deleted_copy_types = NULL;
    6906        96437 : }
    6907              : 
    6908              : #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
    6909              : /* Complain that some language-specific thing hanging off a tree
    6910              :    node has been accessed improperly.  */
    6911              : 
    6912              : void
    6913            0 : lang_check_failed (const char* file, int line, const char* function)
    6914              : {
    6915            0 :   internal_error ("%<lang_*%> check: failed in %s, at %s:%d",
    6916              :                   function, trim_filename (file), line);
    6917              : }
    6918              : #endif /* ENABLE_TREE_CHECKING */
    6919              : 
    6920              : #if CHECKING_P
    6921              : 
    6922              : namespace selftest {
    6923              : 
    6924              : /* Verify that lvalue_kind () works, for various expressions,
    6925              :    and that location wrappers don't affect the results.  */
    6926              : 
    6927              : static void
    6928            1 : test_lvalue_kind ()
    6929              : {
    6930            1 :   location_t loc = BUILTINS_LOCATION;
    6931              : 
    6932              :   /* Verify constants and parameters, without and with
    6933              :      location wrappers.  */
    6934            1 :   tree int_cst = build_int_cst (integer_type_node, 42);
    6935            1 :   ASSERT_EQ (clk_none, lvalue_kind (int_cst));
    6936              : 
    6937            1 :   tree wrapped_int_cst = maybe_wrap_with_location (int_cst, loc);
    6938            1 :   ASSERT_TRUE (location_wrapper_p (wrapped_int_cst));
    6939            1 :   ASSERT_EQ (clk_none, lvalue_kind (wrapped_int_cst));
    6940              : 
    6941            1 :   tree string_lit = build_string (4, "foo");
    6942            1 :   TREE_TYPE (string_lit) = char_array_type_node;
    6943            1 :   string_lit = fix_string_type (string_lit);
    6944            1 :   ASSERT_EQ (clk_ordinary|clk_mergeable, lvalue_kind (string_lit));
    6945              : 
    6946            1 :   tree wrapped_string_lit = maybe_wrap_with_location (string_lit, loc);
    6947            1 :   ASSERT_TRUE (location_wrapper_p (wrapped_string_lit));
    6948            1 :   ASSERT_EQ (clk_ordinary|clk_mergeable, lvalue_kind (wrapped_string_lit));
    6949              : 
    6950            1 :   tree parm = build_decl (UNKNOWN_LOCATION, PARM_DECL,
    6951              :                           get_identifier ("some_parm"),
    6952              :                           integer_type_node);
    6953            1 :   ASSERT_EQ (clk_ordinary, lvalue_kind (parm));
    6954              : 
    6955            1 :   tree wrapped_parm = maybe_wrap_with_location (parm, loc);
    6956            1 :   ASSERT_TRUE (location_wrapper_p (wrapped_parm));
    6957            1 :   ASSERT_EQ (clk_ordinary, lvalue_kind (wrapped_parm));
    6958              : 
    6959              :   /* Verify that lvalue_kind of std::move on a parm isn't
    6960              :      affected by location wrappers.  */
    6961            1 :   tree rvalue_ref_of_parm = move (parm);
    6962            1 :   ASSERT_EQ (clk_rvalueref, lvalue_kind (rvalue_ref_of_parm));
    6963            1 :   tree rvalue_ref_of_wrapped_parm = move (wrapped_parm);
    6964            1 :   ASSERT_EQ (clk_rvalueref, lvalue_kind (rvalue_ref_of_wrapped_parm));
    6965              : 
    6966              :   /* Verify lvalue_p.  */
    6967            1 :   ASSERT_FALSE (lvalue_p (int_cst));
    6968            1 :   ASSERT_FALSE (lvalue_p (wrapped_int_cst));
    6969            1 :   ASSERT_TRUE (lvalue_p (parm));
    6970            1 :   ASSERT_TRUE (lvalue_p (wrapped_parm));
    6971            1 :   ASSERT_FALSE (lvalue_p (rvalue_ref_of_parm));
    6972            1 :   ASSERT_FALSE (lvalue_p (rvalue_ref_of_wrapped_parm));
    6973            1 : }
    6974              : 
    6975              : /* Run all of the selftests within this file.  */
    6976              : 
    6977              : void
    6978            1 : cp_tree_cc_tests ()
    6979              : {
    6980            1 :   test_lvalue_kind ();
    6981            1 : }
    6982              : 
    6983              : } // namespace selftest
    6984              : 
    6985              : #endif /* #if CHECKING_P */
    6986              : 
    6987              : 
    6988              : #include "gt-cp-tree.h"
        

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.