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