LCOV - code coverage report
Current view: top level - gcc/cp - method.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 97.5 % 1814 1768
Test Date: 2024-09-07 14:08:43 Functions: 100.0 % 75 75
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Handle the hair of processing (but not expanding) inline functions.
       2                 :             :    Also manage function and variable name overloading.
       3                 :             :    Copyright (C) 1987-2024 Free Software Foundation, Inc.
       4                 :             :    Contributed by Michael Tiemann (tiemann@cygnus.com)
       5                 :             : 
       6                 :             : This file is part of GCC.
       7                 :             : 
       8                 :             : GCC is free software; you can redistribute it and/or modify
       9                 :             : it under the terms of the GNU General Public License as published by
      10                 :             : the Free Software Foundation; either version 3, or (at your option)
      11                 :             : any later version.
      12                 :             : 
      13                 :             : GCC is distributed in the hope that it will be useful,
      14                 :             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 :             : GNU General Public License for more details.
      17                 :             : 
      18                 :             : You should have received a copy of the GNU General Public License
      19                 :             : along with GCC; see the file COPYING3.  If not see
      20                 :             : <http://www.gnu.org/licenses/>.  */
      21                 :             : 
      22                 :             : 
      23                 :             : /* Handle method declarations.  */
      24                 :             : #include "config.h"
      25                 :             : #include "system.h"
      26                 :             : #include "coretypes.h"
      27                 :             : #include "target.h"
      28                 :             : #include "cp-tree.h"
      29                 :             : #include "stringpool.h"
      30                 :             : #include "cgraph.h"
      31                 :             : #include "varasm.h"
      32                 :             : #include "toplev.h"
      33                 :             : #include "intl.h"
      34                 :             : #include "common/common-target.h"
      35                 :             : 
      36                 :             : static void do_build_copy_assign (tree);
      37                 :             : static void do_build_copy_constructor (tree);
      38                 :             : static tree make_alias_for_thunk (tree);
      39                 :             : 
      40                 :             : /* Called once to initialize method.cc.  */
      41                 :             : 
      42                 :             : void
      43                 :       92069 : init_method (void)
      44                 :             : {
      45                 :       92069 :   init_mangle ();
      46                 :       92069 : }
      47                 :             : 
      48                 :             : /* Return a this or result adjusting thunk to FUNCTION.  THIS_ADJUSTING
      49                 :             :    indicates whether it is a this or result adjusting thunk.
      50                 :             :    FIXED_OFFSET and VIRTUAL_OFFSET indicate how to do the adjustment
      51                 :             :    (see thunk_adjust).  VIRTUAL_OFFSET can be NULL, but FIXED_OFFSET
      52                 :             :    never is.  VIRTUAL_OFFSET is the /index/ into the vtable for this
      53                 :             :    adjusting thunks, we scale it to a byte offset. For covariant
      54                 :             :    thunks VIRTUAL_OFFSET is the virtual binfo.  You must post process
      55                 :             :    the returned thunk with finish_thunk.  */
      56                 :             : 
      57                 :             : tree
      58                 :     1044141 : make_thunk (tree function, bool this_adjusting,
      59                 :             :             tree fixed_offset, tree virtual_offset)
      60                 :             : {
      61                 :     1044141 :   HOST_WIDE_INT d;
      62                 :     1044141 :   tree thunk;
      63                 :             : 
      64                 :     1044141 :   gcc_assert (TREE_CODE (function) == FUNCTION_DECL);
      65                 :             :   /* We can have this thunks to covariant thunks, but not vice versa.  */
      66                 :     1044141 :   gcc_assert (!DECL_THIS_THUNK_P (function));
      67                 :     1044141 :   gcc_assert (!DECL_RESULT_THUNK_P (function) || this_adjusting);
      68                 :             : 
      69                 :             :   /* Scale the VIRTUAL_OFFSET to be in terms of bytes.  */
      70                 :     1044141 :   if (this_adjusting && virtual_offset)
      71                 :      843614 :     virtual_offset
      72                 :      843614 :       = size_binop (MULT_EXPR,
      73                 :             :                     virtual_offset,
      74                 :             :                     convert (ssizetype,
      75                 :             :                              TYPE_SIZE_UNIT (vtable_entry_type)));
      76                 :             : 
      77                 :     1044141 :   d = tree_to_shwi (fixed_offset);
      78                 :             : 
      79                 :             :   /* See if we already have the thunk in question.  For this_adjusting
      80                 :             :      thunks VIRTUAL_OFFSET will be an INTEGER_CST, for covariant thunks it
      81                 :             :      will be a BINFO.  */
      82                 :     2287878 :   for (thunk = DECL_THUNKS (function); thunk; thunk = DECL_CHAIN (thunk))
      83                 :      757072 :     if (DECL_THIS_THUNK_P (thunk) == this_adjusting
      84                 :      757069 :         && THUNK_FIXED_OFFSET (thunk) == d
      85                 :      557932 :         && !virtual_offset == !THUNK_VIRTUAL_OFFSET (thunk)
      86                 :     1315004 :         && (!virtual_offset
      87                 :      479541 :             || (this_adjusting
      88                 :      479541 :                 ? tree_int_cst_equal (THUNK_VIRTUAL_OFFSET (thunk),
      89                 :             :                                       virtual_offset)
      90                 :         184 :                 : THUNK_VIRTUAL_OFFSET (thunk) == virtual_offset)))
      91                 :      557476 :       return thunk;
      92                 :             : 
      93                 :             :   /* All thunks must be created before FUNCTION is actually emitted;
      94                 :             :      the ABI requires that all thunks be emitted together with the
      95                 :             :      function to which they transfer control.  */
      96                 :      486665 :   gcc_assert (!TREE_ASM_WRITTEN (function));
      97                 :             :   /* Likewise, we can only be adding thunks to a function declared in
      98                 :             :      the class currently being laid out.  */
      99                 :      486665 :   gcc_assert (TYPE_SIZE (DECL_CONTEXT (function))
     100                 :             :               && TYPE_BEING_DEFINED (DECL_CONTEXT (function)));
     101                 :             : 
     102                 :      486665 :   thunk = build_decl (DECL_SOURCE_LOCATION (function),
     103                 :      486665 :                       FUNCTION_DECL, NULL_TREE, TREE_TYPE (function));
     104                 :      486665 :   DECL_LANG_SPECIFIC (thunk) = DECL_LANG_SPECIFIC (function);
     105                 :      486665 :   cxx_dup_lang_specific_decl (thunk);
     106                 :      486665 :   DECL_VIRTUAL_P (thunk) = true;
     107                 :      486665 :   SET_DECL_THUNKS (thunk, NULL_TREE);
     108                 :             : 
     109                 :      486665 :   DECL_CONTEXT (thunk) = DECL_CONTEXT (function);
     110                 :      486665 :   TREE_READONLY (thunk) = TREE_READONLY (function);
     111                 :      486665 :   TREE_THIS_VOLATILE (thunk) = TREE_THIS_VOLATILE (function);
     112                 :      486665 :   TREE_PUBLIC (thunk) = TREE_PUBLIC (function);
     113                 :      486665 :   SET_DECL_THUNK_P (thunk, this_adjusting);
     114                 :      486665 :   THUNK_TARGET (thunk) = function;
     115                 :      486665 :   THUNK_FIXED_OFFSET (thunk) = d;
     116                 :      486665 :   THUNK_VIRTUAL_OFFSET (thunk) = virtual_offset;
     117                 :      486665 :   THUNK_ALIAS (thunk) = NULL_TREE;
     118                 :             : 
     119                 :      486665 :   DECL_INTERFACE_KNOWN (thunk) = 1;
     120                 :      486665 :   DECL_NOT_REALLY_EXTERN (thunk) = 1;
     121                 :      486665 :   DECL_COMDAT (thunk) = DECL_COMDAT (function);
     122                 :      486665 :   DECL_SAVED_AUTO_RETURN_TYPE (thunk) = NULL;
     123                 :             :   /* The thunk itself is not a constructor or destructor, even if
     124                 :             :      the thing it is thunking to is.  */
     125                 :      486665 :   DECL_CXX_DESTRUCTOR_P (thunk) = 0;
     126                 :      486665 :   DECL_CXX_CONSTRUCTOR_P (thunk) = 0;
     127                 :      486665 :   DECL_EXTERNAL (thunk) = 1;
     128                 :      486665 :   DECL_ARTIFICIAL (thunk) = 1;
     129                 :             :   /* The THUNK is not a pending inline, even if the FUNCTION is.  */
     130                 :      486665 :   DECL_PENDING_INLINE_P (thunk) = 0;
     131                 :      486665 :   DECL_DECLARED_INLINE_P (thunk) = 0;
     132                 :             :   /* Nor is it a template instantiation.  */
     133                 :      486665 :   DECL_USE_TEMPLATE (thunk) = 0;
     134                 :      486665 :   DECL_TEMPLATE_INFO (thunk) = NULL;
     135                 :             : 
     136                 :             :   /* Add it to the list of thunks associated with FUNCTION.  */
     137                 :      486665 :   DECL_CHAIN (thunk) = DECL_THUNKS (function);
     138                 :      486665 :   SET_DECL_THUNKS (function, thunk);
     139                 :             : 
     140                 :      486665 :   return thunk;
     141                 :             : }
     142                 :             : 
     143                 :             : /* Finish THUNK, a thunk decl.  */
     144                 :             : 
     145                 :             : void
     146                 :      486665 : finish_thunk (tree thunk)
     147                 :             : {
     148                 :      486665 :   tree function, name;
     149                 :      486665 :   tree fixed_offset = ssize_int (THUNK_FIXED_OFFSET (thunk));
     150                 :      486665 :   tree virtual_offset = THUNK_VIRTUAL_OFFSET (thunk);
     151                 :             : 
     152                 :      486665 :   gcc_assert (!DECL_NAME (thunk) && DECL_THUNK_P (thunk));
     153                 :      486665 :   if (virtual_offset && DECL_RESULT_THUNK_P (thunk))
     154                 :         142 :     virtual_offset = BINFO_VPTR_FIELD (virtual_offset);
     155                 :      486665 :   function = THUNK_TARGET (thunk);
     156                 :      486879 :   name = mangle_thunk (function, DECL_THIS_THUNK_P (thunk),
     157                 :             :                        fixed_offset, virtual_offset, thunk);
     158                 :             : 
     159                 :             :   /* We can end up with declarations of (logically) different
     160                 :             :      covariant thunks, that do identical adjustments.  The two thunks
     161                 :             :      will be adjusting between within different hierarchies, which
     162                 :             :      happen to have the same layout.  We must nullify one of them to
     163                 :             :      refer to the other.  */
     164                 :      486665 :   if (DECL_RESULT_THUNK_P (thunk))
     165                 :             :     {
     166                 :         214 :       tree cov_probe;
     167                 :             : 
     168                 :         214 :       for (cov_probe = DECL_THUNKS (function);
     169                 :         476 :            cov_probe; cov_probe = DECL_CHAIN (cov_probe))
     170                 :         262 :         if (DECL_NAME (cov_probe) == name)
     171                 :             :           {
     172                 :           0 :             gcc_assert (!DECL_THUNKS (thunk));
     173                 :           0 :             THUNK_ALIAS (thunk) = (THUNK_ALIAS (cov_probe)
     174                 :           0 :                                    ? THUNK_ALIAS (cov_probe) : cov_probe);
     175                 :           0 :             break;
     176                 :             :           }
     177                 :             :     }
     178                 :             : 
     179                 :      486665 :   DECL_NAME (thunk) = name;
     180                 :      486665 :   SET_DECL_ASSEMBLER_NAME (thunk, name);
     181                 :      486665 : }
     182                 :             : 
     183                 :             : static GTY (()) int thunk_labelno;
     184                 :             : 
     185                 :             : /* Create a static alias to target.  */
     186                 :             : 
     187                 :             : tree
     188                 :      237047 : make_alias_for (tree target, tree newid)
     189                 :             : {
     190                 :      237047 :   tree alias = build_decl (DECL_SOURCE_LOCATION (target),
     191                 :      237047 :                            TREE_CODE (target), newid, TREE_TYPE (target));
     192                 :      237047 :   DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (target);
     193                 :      237047 :   cxx_dup_lang_specific_decl (alias);
     194                 :      237047 :   DECL_CONTEXT (alias) = DECL_CONTEXT (target);
     195                 :      237047 :   TREE_READONLY (alias) = TREE_READONLY (target);
     196                 :      237047 :   TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (target);
     197                 :      237047 :   TREE_PUBLIC (alias) = 0;
     198                 :      237047 :   DECL_INTERFACE_KNOWN (alias) = 1;
     199                 :      237047 :   if (DECL_LANG_SPECIFIC (alias))
     200                 :             :     {
     201                 :      236863 :       DECL_NOT_REALLY_EXTERN (alias) = 1;
     202                 :      236863 :       DECL_USE_TEMPLATE (alias) = 0;
     203                 :      236863 :       DECL_TEMPLATE_INFO (alias) = NULL;
     204                 :             :     }
     205                 :      237047 :   DECL_EXTERNAL (alias) = 0;
     206                 :      237047 :   DECL_ARTIFICIAL (alias) = 1;
     207                 :      237047 :   DECL_TEMPLATE_INSTANTIATED (alias) = 0;
     208                 :      237047 :   if (TREE_CODE (alias) == FUNCTION_DECL)
     209                 :             :     {
     210                 :      231548 :       DECL_SAVED_AUTO_RETURN_TYPE (alias) = NULL;
     211                 :      231548 :       DECL_CXX_DESTRUCTOR_P (alias) = 0;
     212                 :      231548 :       DECL_CXX_CONSTRUCTOR_P (alias) = 0;
     213                 :      231548 :       DECL_PENDING_INLINE_P (alias) = 0;
     214                 :      231548 :       DECL_DECLARED_INLINE_P (alias) = 0;
     215                 :      231548 :       DECL_INITIAL (alias) = error_mark_node;
     216                 :      231548 :       DECL_ARGUMENTS (alias) = copy_list (DECL_ARGUMENTS (target));
     217                 :             :     }
     218                 :             :   else
     219                 :        5499 :     TREE_STATIC (alias) = 1;
     220                 :      237047 :   TREE_ADDRESSABLE (alias) = 1;
     221                 :      237047 :   TREE_USED (alias) = 1;
     222                 :      237047 :   SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias));
     223                 :      237047 :   return alias;
     224                 :             : }
     225                 :             : 
     226                 :             : static tree
     227                 :        4341 : make_alias_for_thunk (tree function)
     228                 :             : {
     229                 :        4341 :   tree alias;
     230                 :        4341 :   char buf[256];
     231                 :             : 
     232                 :        4341 :   targetm.asm_out.generate_internal_label (buf, "LTHUNK", thunk_labelno);
     233                 :        4341 :   thunk_labelno++;
     234                 :             : 
     235                 :        4341 :   alias = make_alias_for (function, get_identifier (buf));
     236                 :             : 
     237                 :        4341 :   if (!flag_syntax_only)
     238                 :             :     {
     239                 :        4341 :       struct cgraph_node *funcn, *aliasn;
     240                 :        4341 :       funcn = cgraph_node::get (function);
     241                 :        4341 :       gcc_checking_assert (funcn);
     242                 :        4341 :       aliasn = cgraph_node::create_same_body_alias (alias, function);
     243                 :        4341 :       DECL_ASSEMBLER_NAME (function);
     244                 :        4341 :       gcc_assert (aliasn != NULL);
     245                 :             :     }
     246                 :             : 
     247                 :        4341 :   return alias;
     248                 :             : }
     249                 :             : 
     250                 :             : /* Emit the definition of a C++ multiple inheritance or covariant
     251                 :             :    return vtable thunk.  If EMIT_P is nonzero, the thunk is emitted
     252                 :             :    immediately.  */
     253                 :             : 
     254                 :             : void
     255                 :        8383 : use_thunk (tree thunk_fndecl, bool emit_p)
     256                 :             : {
     257                 :        8383 :   tree a, t, function, alias;
     258                 :        8383 :   tree virtual_offset;
     259                 :        8383 :   HOST_WIDE_INT fixed_offset, virtual_value;
     260                 :        8383 :   bool this_adjusting = DECL_THIS_THUNK_P (thunk_fndecl);
     261                 :        8383 :   struct cgraph_node *funcn, *thunk_node;
     262                 :             : 
     263                 :             :   /* We should have called finish_thunk to give it a name.  */
     264                 :        8383 :   gcc_assert (DECL_NAME (thunk_fndecl));
     265                 :             : 
     266                 :             :   /* We should never be using an alias, always refer to the
     267                 :             :      aliased thunk.  */
     268                 :        8383 :   gcc_assert (!THUNK_ALIAS (thunk_fndecl));
     269                 :             : 
     270                 :        8383 :   if (TREE_ASM_WRITTEN (thunk_fndecl))
     271                 :             :     return;
     272                 :             : 
     273                 :        4437 :   function = THUNK_TARGET (thunk_fndecl);
     274                 :        4437 :   if (DECL_RESULT (thunk_fndecl))
     275                 :             :     /* We already turned this thunk into an ordinary function.
     276                 :             :        There's no need to process this thunk again.  */
     277                 :             :     return;
     278                 :             : 
     279                 :        4437 :   if (DECL_THUNK_P (function))
     280                 :             :     /* The target is itself a thunk, process it now.  */
     281                 :         152 :     use_thunk (function, emit_p);
     282                 :             : 
     283                 :             :   /* Thunks are always addressable; they only appear in vtables.  */
     284                 :        4437 :   TREE_ADDRESSABLE (thunk_fndecl) = 1;
     285                 :             : 
     286                 :             :   /* Figure out what function is being thunked to.  It's referenced in
     287                 :             :      this translation unit.  */
     288                 :        4437 :   TREE_ADDRESSABLE (function) = 1;
     289                 :        4437 :   mark_used (function);
     290                 :        4437 :   if (!emit_p)
     291                 :             :     return;
     292                 :             : 
     293                 :        4341 :   if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function))
     294                 :        4341 :    alias = make_alias_for_thunk (function);
     295                 :             :   else
     296                 :             :    alias = function;
     297                 :             : 
     298                 :        4341 :   fixed_offset = THUNK_FIXED_OFFSET (thunk_fndecl);
     299                 :        4341 :   virtual_offset = THUNK_VIRTUAL_OFFSET (thunk_fndecl);
     300                 :             : 
     301                 :        4341 :   if (virtual_offset)
     302                 :             :     {
     303                 :        2824 :       if (!this_adjusting)
     304                 :         112 :         virtual_offset = BINFO_VPTR_FIELD (virtual_offset);
     305                 :        2824 :       virtual_value = tree_to_shwi (virtual_offset);
     306                 :        2824 :       gcc_assert (virtual_value);
     307                 :             :     }
     308                 :             :   else
     309                 :             :     virtual_value = 0;
     310                 :             : 
     311                 :             :   /* And, if we need to emit the thunk, it's used.  */
     312                 :        4341 :   mark_used (thunk_fndecl);
     313                 :             :   /* This thunk is actually defined.  */
     314                 :        4341 :   DECL_EXTERNAL (thunk_fndecl) = 0;
     315                 :             :   /* The linkage of the function may have changed.  FIXME in linkage
     316                 :             :      rewrite.  */
     317                 :        4341 :   gcc_assert (DECL_INTERFACE_KNOWN (function));
     318                 :        4341 :   TREE_PUBLIC (thunk_fndecl) = TREE_PUBLIC (function);
     319                 :        4341 :   DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function);
     320                 :        8682 :   DECL_VISIBILITY_SPECIFIED (thunk_fndecl)
     321                 :        4341 :     = DECL_VISIBILITY_SPECIFIED (function);
     322                 :        4341 :   DECL_COMDAT (thunk_fndecl) = DECL_COMDAT (function);
     323                 :        4341 :   DECL_WEAK (thunk_fndecl) = DECL_WEAK (function);
     324                 :             : 
     325                 :        4341 :   if (flag_syntax_only)
     326                 :             :     {
     327                 :           0 :       TREE_ASM_WRITTEN (thunk_fndecl) = 1;
     328                 :           0 :       return;
     329                 :             :     }
     330                 :             : 
     331                 :        4341 :   push_to_top_level ();
     332                 :             : 
     333                 :        4341 :   if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function)
     334                 :        4341 :       && targetm_common.have_named_sections)
     335                 :             :     {
     336                 :        4341 :       tree fn = function;
     337                 :        4341 :       struct symtab_node *symbol;
     338                 :             : 
     339                 :        4341 :       if ((symbol = symtab_node::get (function))
     340                 :        4341 :           && symbol->alias)
     341                 :             :         {
     342                 :         256 :           if (symbol->analyzed)
     343                 :          65 :             fn = symtab_node::get (function)->ultimate_alias_target ()->decl;
     344                 :             :           else
     345                 :         191 :             fn = symtab_node::get (function)->alias_target;
     346                 :             :         }
     347                 :        4341 :       resolve_unique_section (fn, 0, flag_function_sections);
     348                 :             : 
     349                 :        4341 :       if (DECL_SECTION_NAME (fn) != NULL && DECL_ONE_ONLY (fn))
     350                 :             :         {
     351                 :        3609 :           resolve_unique_section (thunk_fndecl, 0, flag_function_sections);
     352                 :             : 
     353                 :             :           /* Output the thunk into the same section as function.  */
     354                 :        3609 :           set_decl_section_name (thunk_fndecl, fn);
     355                 :        7218 :           symtab_node::get (thunk_fndecl)->implicit_section
     356                 :        3609 :             = symtab_node::get (fn)->implicit_section;
     357                 :             :         }
     358                 :             :     }
     359                 :             : 
     360                 :             :   /* Set up cloned argument trees for the thunk.  */
     361                 :        4341 :   t = NULL_TREE;
     362                 :        9289 :   for (a = DECL_ARGUMENTS (function); a; a = DECL_CHAIN (a))
     363                 :             :     {
     364                 :        4948 :       tree x = copy_node (a);
     365                 :        4948 :       DECL_CHAIN (x) = t;
     366                 :        4948 :       DECL_CONTEXT (x) = thunk_fndecl;
     367                 :        4948 :       SET_DECL_RTL (x, NULL);
     368                 :        4948 :       DECL_HAS_VALUE_EXPR_P (x) = 0;
     369                 :        4948 :       TREE_ADDRESSABLE (x) = 0;
     370                 :        4948 :       t = x;
     371                 :             :     }
     372                 :        4341 :   a = nreverse (t);
     373                 :        4341 :   DECL_ARGUMENTS (thunk_fndecl) = a;
     374                 :        4341 :   TREE_ASM_WRITTEN (thunk_fndecl) = 1;
     375                 :        4341 :   funcn = cgraph_node::get (function);
     376                 :        4341 :   gcc_checking_assert (funcn);
     377                 :        4341 :   thunk_node = funcn->create_thunk (thunk_fndecl, function,
     378                 :             :                                     this_adjusting, fixed_offset, virtual_value,
     379                 :             :                                     0, virtual_offset, alias);
     380                 :        4341 :   if (DECL_ONE_ONLY (function))
     381                 :        3609 :     thunk_node->add_to_same_comdat_group (funcn);
     382                 :             : 
     383                 :        4341 :   pop_from_top_level ();
     384                 :             : }
     385                 :             : 
     386                 :             : /* Code for synthesizing methods which have default semantics defined.  */
     387                 :             : 
     388                 :             : /* True iff CTYPE has a trivial SFK.  */
     389                 :             : 
     390                 :             : static bool
     391                 :    53784139 : type_has_trivial_fn (tree ctype, special_function_kind sfk)
     392                 :             : {
     393                 :    53784139 :   switch (sfk)
     394                 :             :     {
     395                 :     7852468 :     case sfk_constructor:
     396                 :     7852468 :       return !TYPE_HAS_COMPLEX_DFLT (ctype);
     397                 :    10111686 :     case sfk_copy_constructor:
     398                 :    10111686 :       return !TYPE_HAS_COMPLEX_COPY_CTOR (ctype);
     399                 :     7582439 :     case sfk_move_constructor:
     400                 :     7582439 :       return !TYPE_HAS_COMPLEX_MOVE_CTOR (ctype);
     401                 :     4760778 :     case sfk_copy_assignment:
     402                 :     4760778 :       return !TYPE_HAS_COMPLEX_COPY_ASSIGN (ctype);
     403                 :     3210417 :     case sfk_move_assignment:
     404                 :     3210417 :       return !TYPE_HAS_COMPLEX_MOVE_ASSIGN (ctype);
     405                 :    19796067 :     case sfk_destructor:
     406                 :    19796067 :     case sfk_virtual_destructor:
     407                 :    19796067 :       return !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype);
     408                 :             :     case sfk_inheriting_constructor:
     409                 :             :     case sfk_comparison:
     410                 :             :       return false;
     411                 :           0 :     default:
     412                 :           0 :       gcc_unreachable ();
     413                 :             :     }
     414                 :             : }
     415                 :             : 
     416                 :             : /* Note that CTYPE has a non-trivial SFK even though we previously thought
     417                 :             :    it was trivial.  */
     418                 :             : 
     419                 :             : static void
     420                 :      208719 : type_set_nontrivial_flag (tree ctype, special_function_kind sfk)
     421                 :             : {
     422                 :      208719 :   switch (sfk)
     423                 :             :     {
     424                 :      116816 :     case sfk_constructor:
     425                 :      116816 :       TYPE_HAS_COMPLEX_DFLT (ctype) = true;
     426                 :      116816 :       return;
     427                 :           3 :     case sfk_copy_constructor:
     428                 :           3 :       TYPE_HAS_COMPLEX_COPY_CTOR (ctype) = true;
     429                 :           3 :       return;
     430                 :       91459 :     case sfk_move_constructor:
     431                 :       91459 :       TYPE_HAS_COMPLEX_MOVE_CTOR (ctype) = true;
     432                 :       91459 :       return;
     433                 :         182 :     case sfk_copy_assignment:
     434                 :         182 :       TYPE_HAS_COMPLEX_COPY_ASSIGN (ctype) = true;
     435                 :         182 :       return;
     436                 :         259 :     case sfk_move_assignment:
     437                 :         259 :       TYPE_HAS_COMPLEX_MOVE_ASSIGN (ctype) = true;
     438                 :         259 :       return;
     439                 :           0 :     case sfk_destructor:
     440                 :           0 :       TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype) = true;
     441                 :           0 :       return;
     442                 :           0 :     case sfk_inheriting_constructor:
     443                 :           0 :     default:
     444                 :           0 :       gcc_unreachable ();
     445                 :             :     }
     446                 :             : }
     447                 :             : 
     448                 :             : /* True iff FN is a trivial defaulted member function ([cd]tor, op=).  */
     449                 :             : 
     450                 :             : bool
     451                 :   198858256 : trivial_fn_p (tree fn)
     452                 :             : {
     453                 :   198858256 :   if (TREE_CODE (fn) == TEMPLATE_DECL)
     454                 :             :     return false;
     455                 :   198858256 :   if (!DECL_DEFAULTED_FN (fn))
     456                 :             :     return false;
     457                 :             : 
     458                 :             :   /* If fn is a clone, get the primary variant.  */
     459                 :    25139130 :   if (tree prim = DECL_CLONED_FUNCTION (fn))
     460                 :    20417903 :     fn = prim;
     461                 :    25139130 :   return type_has_trivial_fn (DECL_CONTEXT (fn), special_function_p (fn));
     462                 :             : }
     463                 :             : 
     464                 :             : /* PARM is a PARM_DECL for a function which we want to forward to another
     465                 :             :    function without changing its value category, a la std::forward.  */
     466                 :             : 
     467                 :             : tree
     468                 :       65546 : forward_parm (tree parm)
     469                 :             : {
     470                 :       65546 :   tree exp = convert_from_reference (parm);
     471                 :       65546 :   tree type = TREE_TYPE (parm);
     472                 :       65546 :   if (DECL_PACK_P (parm))
     473                 :         524 :     type = PACK_EXPANSION_PATTERN (type);
     474                 :       65546 :   if (!TYPE_REF_P (type))
     475                 :       54209 :     type = cp_build_reference_type (type, /*rval=*/true);
     476                 :       65546 :   warning_sentinel w (warn_useless_cast);
     477                 :       65546 :   exp = build_static_cast (input_location, type, exp,
     478                 :             :                            tf_warning_or_error);
     479                 :       65546 :   if (DECL_PACK_P (parm))
     480                 :         524 :     exp = make_pack_expansion (exp);
     481                 :       65546 :   return exp;
     482                 :       65546 : }
     483                 :             : 
     484                 :             : /* Strip all inheriting constructors, if any, to return the original
     485                 :             :    constructor from a (possibly indirect) base class.  */
     486                 :             : 
     487                 :             : tree
     488                 :   599197510 : strip_inheriting_ctors (tree dfn)
     489                 :             : {
     490                 :   599197510 :   if (!flag_new_inheriting_ctors)
     491                 :             :     return dfn;
     492                 :             :   tree fn = dfn;
     493                 :  1145153833 :   while (tree inh = DECL_INHERITED_CTOR (fn))
     494                 :   599948512 :     fn = OVL_FIRST (inh);
     495                 :             : 
     496                 :   599154945 :   if (TREE_CODE (fn) == TEMPLATE_DECL
     497                 :   384948299 :       && TREE_CODE (dfn) == FUNCTION_DECL)
     498                 :        4714 :     fn = DECL_TEMPLATE_RESULT (fn);
     499                 :             :   return fn;
     500                 :             : }
     501                 :             : 
     502                 :             : /* Find the binfo for the base subobject of BINFO being initialized by
     503                 :             :    inherited constructor FNDECL (a member of a direct base of BINFO).  */
     504                 :             : 
     505                 :             : static tree inherited_ctor_binfo (tree, tree);
     506                 :             : static tree
     507                 :       45773 : inherited_ctor_binfo_1 (tree binfo, tree fndecl)
     508                 :             : {
     509                 :       45773 :   tree base = DECL_CONTEXT (fndecl);
     510                 :       45773 :   tree base_binfo;
     511                 :       46093 :   for (int i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
     512                 :       46093 :     if (BINFO_TYPE (base_binfo) == base)
     513                 :       45773 :       return inherited_ctor_binfo (base_binfo, fndecl);
     514                 :             : 
     515                 :           0 :   gcc_unreachable();
     516                 :             : }
     517                 :             : 
     518                 :             : /* Find the binfo for the base subobject of BINFO being initialized by
     519                 :             :    inheriting constructor FNDECL (a member of BINFO), or BINFO if FNDECL is not
     520                 :             :    an inheriting constructor.  */
     521                 :             : 
     522                 :             : static tree
     523                 :       86895 : inherited_ctor_binfo (tree binfo, tree fndecl)
     524                 :             : {
     525                 :      173790 :   tree inh = DECL_INHERITED_CTOR (fndecl);
     526                 :       86895 :   if (!inh)
     527                 :             :     return binfo;
     528                 :             : 
     529                 :       45548 :   tree results = NULL_TREE;
     530                 :       91546 :   for (ovl_iterator iter (inh); iter; ++iter)
     531                 :             :     {
     532                 :       45773 :       tree one = inherited_ctor_binfo_1 (binfo, *iter);
     533                 :       45773 :       if (!results)
     534                 :             :         results = one;
     535                 :         225 :       else if (one != results)
     536                 :           6 :         results = tree_cons (NULL_TREE, one, results);
     537                 :             :     }
     538                 :       45548 :   return results;
     539                 :             : }
     540                 :             : 
     541                 :             : /* Find the binfo for the base subobject being initialized by inheriting
     542                 :             :    constructor FNDECL, or NULL_TREE if FNDECL is not an inheriting
     543                 :             :    constructor.  */
     544                 :             : 
     545                 :             : tree
     546                 :     3874744 : inherited_ctor_binfo (tree fndecl)
     547                 :             : {
     548                 :     7749488 :   if (!DECL_INHERITED_CTOR (fndecl))
     549                 :             :     return NULL_TREE;
     550                 :       41122 :   tree binfo = TYPE_BINFO (DECL_CONTEXT (fndecl));
     551                 :       41122 :   return inherited_ctor_binfo (binfo, fndecl);
     552                 :             : }
     553                 :             : 
     554                 :             : 
     555                 :             : /* True if we should omit all user-declared parameters from a base
     556                 :             :    construtor built from complete constructor FN.
     557                 :             :    That's when the ctor is inherited from a virtual base.  */
     558                 :             : 
     559                 :             : bool
     560                 :   150971959 : base_ctor_omit_inherited_parms (tree comp_ctor)
     561                 :             : {
     562                 :   150971959 :   gcc_checking_assert (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (comp_ctor));
     563                 :             : 
     564                 :   150971959 :   if (!flag_new_inheriting_ctors)
     565                 :             :     /* We only optimize away the parameters in the new model.  */
     566                 :             :     return false;
     567                 :             : 
     568                 :   150924257 :   if (!CLASSTYPE_VBASECLASSES (DECL_CONTEXT (comp_ctor)))
     569                 :             :     return false;
     570                 :             : 
     571                 :     4747348 :   if (FUNCTION_FIRST_USER_PARMTYPE (comp_ctor) == void_list_node)
     572                 :             :     /* No user-declared parameters to omit.  */
     573                 :             :     return false;
     574                 :             : 
     575                 :     3835344 :   for (tree binfo = inherited_ctor_binfo (comp_ctor);
     576                 :     3836874 :        binfo;
     577                 :        1530 :        binfo = BINFO_INHERITANCE_CHAIN (binfo))
     578                 :        2856 :     if (BINFO_VIRTUAL_P (binfo))
     579                 :             :       return true;
     580                 :             : 
     581                 :             :   return false;
     582                 :             : }
     583                 :             : 
     584                 :             : 
     585                 :             : /* True if we should omit all user-declared parameters from constructor FN,
     586                 :             :    because it is a base clone of a ctor inherited from a virtual base.  */
     587                 :             : 
     588                 :             : bool
     589                 :   715390567 : ctor_omit_inherited_parms (tree fn)
     590                 :             : {
     591                 :   715390567 :   gcc_checking_assert (TREE_CODE (fn) == FUNCTION_DECL);
     592                 :             : 
     593                 :   715390567 :   if (!DECL_BASE_CONSTRUCTOR_P (fn))
     594                 :             :     return false;
     595                 :             : 
     596                 :   110310110 :   return base_ctor_omit_inherited_parms (DECL_CLONED_FUNCTION (fn));
     597                 :             : }
     598                 :             : 
     599                 :             : /* True iff constructor(s) INH inherited into BINFO initializes INIT_BINFO.
     600                 :             :    This can be true for multiple virtual bases as well as one direct
     601                 :             :    non-virtual base.  */
     602                 :             : 
     603                 :             : static bool
     604                 :     4909549 : binfo_inherited_from (tree binfo, tree init_binfo, tree inh)
     605                 :             : {
     606                 :             :   /* inh is an OVERLOAD if we inherited the same constructor along
     607                 :             :      multiple paths, check all of them.  */
     608                 :     4909724 :   for (ovl_iterator iter (inh); iter; ++iter)
     609                 :             :     {
     610                 :       74635 :       tree fn = *iter;
     611                 :       74635 :       tree base = DECL_CONTEXT (fn);
     612                 :       74635 :       tree base_binfo = NULL_TREE;
     613                 :       74687 :       for (int i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
     614                 :       74687 :         if (BINFO_TYPE (base_binfo) == base)
     615                 :             :           break;
     616                 :       74635 :       if (base_binfo == init_binfo
     617                 :       74635 :           || (flag_new_inheriting_ctors
     618                 :         199 :               && binfo_inherited_from (base_binfo, init_binfo,
     619                 :         398 :                                        DECL_INHERITED_CTOR (fn))))
     620                 :       74469 :         return true;
     621                 :             :     }
     622                 :     4835080 :   return false;
     623                 :             : }
     624                 :             : 
     625                 :             : /* Subroutine of do_build_copy_constructor: Add a mem-initializer for BINFO
     626                 :             :    given the parameter or parameters PARM, possibly inherited constructor
     627                 :             :    base INH, or move flag MOVE_P.  */
     628                 :             : 
     629                 :             : static tree
     630                 :      144286 : add_one_base_init (tree binfo, tree parm, bool move_p, tree inh,
     631                 :             :                    tree member_init_list)
     632                 :             : {
     633                 :      144286 :   tree init;
     634                 :      144286 :   if (inh)
     635                 :             :     {
     636                 :             :       /* An inheriting constructor only has a mem-initializer for
     637                 :             :          the base it inherits from.  */
     638                 :       35049 :       if (!binfo_inherited_from (TYPE_BINFO (current_class_type), binfo, inh))
     639                 :             :         return member_init_list;
     640                 :             : 
     641                 :       35001 :       tree *p = &init;
     642                 :       35001 :       init = NULL_TREE;
     643                 :       84829 :       for (; parm; parm = DECL_CHAIN (parm))
     644                 :             :         {
     645                 :       49828 :           tree exp = forward_parm (parm);
     646                 :       49828 :           *p = build_tree_list (NULL_TREE, exp);
     647                 :       49828 :           p = &TREE_CHAIN (*p);
     648                 :             :         }
     649                 :             :     }
     650                 :             :   else
     651                 :             :     {
     652                 :      109237 :       init = build_base_path (PLUS_EXPR, parm, binfo, 1,
     653                 :             :                               tf_warning_or_error);
     654                 :      109237 :       if (move_p)
     655                 :       79114 :         init = move (init);
     656                 :      109237 :       init = build_tree_list (NULL_TREE, init);
     657                 :             :     }
     658                 :      144238 :   return tree_cons (binfo, init, member_init_list);
     659                 :             : }
     660                 :             : 
     661                 :             : /* Generate code for default X(X&) or X(X&&) constructor or an inheriting
     662                 :             :    constructor.  */
     663                 :             : 
     664                 :             : static void
     665                 :      216955 : do_build_copy_constructor (tree fndecl)
     666                 :             : {
     667                 :      216955 :   tree parm = FUNCTION_FIRST_USER_PARM (fndecl);
     668                 :      433910 :   bool move_p = DECL_MOVE_CONSTRUCTOR_P (fndecl);
     669                 :      216955 :   bool trivial = trivial_fn_p (fndecl);
     670                 :      433910 :   tree inh = DECL_INHERITED_CTOR (fndecl);
     671                 :             : 
     672                 :      216955 :   if (!inh)
     673                 :      181969 :     parm = convert_from_reference (parm);
     674                 :             : 
     675                 :      216955 :   if (trivial)
     676                 :             :     {
     677                 :          50 :       if (is_empty_class (current_class_type))
     678                 :             :         /* Don't copy the padding byte; it might not have been allocated
     679                 :             :            if *this is a base subobject.  */;
     680                 :          34 :       else if (tree_int_cst_equal (TYPE_SIZE (current_class_type),
     681                 :          34 :                                    CLASSTYPE_SIZE (current_class_type)))
     682                 :             :         {
     683                 :          21 :           tree t = cp_build_init_expr (current_class_ref, parm);
     684                 :          21 :           finish_expr_stmt (t);
     685                 :             :         }
     686                 :             :       else
     687                 :             :         {
     688                 :             :           /* We must only copy the non-tail padding parts.  */
     689                 :          13 :           tree base_size = CLASSTYPE_SIZE_UNIT (current_class_type);
     690                 :          13 :           base_size = size_binop (MINUS_EXPR, base_size, size_int (1));
     691                 :          13 :           tree array_type = build_array_type (unsigned_char_type_node,
     692                 :             :                                               build_index_type (base_size));
     693                 :          13 :           tree alias_set = build_int_cst (TREE_TYPE (current_class_ptr), 0);
     694                 :          13 :           tree lhs = build2 (MEM_REF, array_type,
     695                 :          13 :                              current_class_ptr, alias_set);
     696                 :          13 :           tree rhs = build2 (MEM_REF, array_type,
     697                 :          13 :                              TREE_OPERAND (parm, 0), alias_set);
     698                 :          13 :           tree t = cp_build_init_expr (lhs, rhs);
     699                 :          13 :           finish_expr_stmt (t);
     700                 :             :         }
     701                 :             :     }
     702                 :             :   else
     703                 :             :     {
     704                 :      216905 :       tree member_init_list = NULL_TREE;
     705                 :      216905 :       int i;
     706                 :      216905 :       tree binfo, base_binfo;
     707                 :      216905 :       vec<tree, va_gc> *vbases;
     708                 :             : 
     709                 :             :       /* Initialize all the base-classes with the parameter converted
     710                 :             :          to their type so that we get their copy constructor and not
     711                 :             :          another constructor that takes current_class_type.  We must
     712                 :             :          deal with the binfo's directly as a direct base might be
     713                 :             :          inaccessible due to ambiguity.  */
     714                 :      216905 :       for (vbases = CLASSTYPE_VBASECLASSES (current_class_type), i = 0;
     715                 :      216998 :            vec_safe_iterate (vbases, i, &binfo); i++)
     716                 :             :         {
     717                 :          93 :           member_init_list = add_one_base_init (binfo, parm, move_p, inh,
     718                 :             :                                                 member_init_list);
     719                 :             :         }
     720                 :             : 
     721                 :      361172 :       for (binfo = TYPE_BINFO (current_class_type), i = 0;
     722                 :      361172 :            BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
     723                 :             :         {
     724                 :      144267 :           if (BINFO_VIRTUAL_P (base_binfo))
     725                 :          74 :             continue;
     726                 :      144193 :           member_init_list = add_one_base_init (base_binfo, parm, move_p,
     727                 :             :                                                 inh, member_init_list);
     728                 :             :         }
     729                 :             : 
     730                 :      216905 :       if (!inh)
     731                 :             :         {
     732                 :      181919 :           int cvquals = cp_type_quals (TREE_TYPE (parm));
     733                 :             : 
     734                 :      181919 :           for (tree fields = TYPE_FIELDS (current_class_type);
     735                 :    11148437 :                fields; fields = DECL_CHAIN (fields))
     736                 :             :             {
     737                 :    10966518 :               tree field = fields;
     738                 :    10966518 :               tree expr_type;
     739                 :             : 
     740                 :    10966518 :               if (TREE_CODE (field) != FIELD_DECL)
     741                 :    10694146 :                 continue;
     742                 :             : 
     743                 :      272372 :               expr_type = TREE_TYPE (field);
     744                 :      272372 :               if (DECL_NAME (field))
     745                 :             :                 {
     746                 :      163258 :                   if (VFIELD_NAME_P (DECL_NAME (field)))
     747                 :         425 :                     continue;
     748                 :             :                 }
     749                 :      109114 :               else if (ANON_AGGR_TYPE_P (expr_type) && TYPE_FIELDS (expr_type))
     750                 :             :                 /* Just use the field; anonymous types can't have
     751                 :             :                    nontrivial copy ctors or assignment ops or this
     752                 :             :                    function would be deleted.  */;
     753                 :             :               else
     754                 :      109102 :                 continue;
     755                 :             : 
     756                 :             :               /* Compute the type of "init->field".  If the copy-constructor
     757                 :             :                  parameter is, for example, "const S&", and the type of
     758                 :             :                  the field is "T", then the type will usually be "const
     759                 :             :                  T".  (There are no cv-qualified variants of reference
     760                 :             :                  types.)  */
     761                 :      162845 :               if (!TYPE_REF_P (expr_type))
     762                 :             :                 {
     763                 :      161775 :                   int quals = cvquals;
     764                 :             : 
     765                 :      161775 :                   if (DECL_MUTABLE_P (field))
     766                 :           1 :                     quals &= ~TYPE_QUAL_CONST;
     767                 :      161775 :                   quals |= cp_type_quals (expr_type);
     768                 :      161775 :                   expr_type = cp_build_qualified_type (expr_type, quals);
     769                 :             :                 }
     770                 :             : 
     771                 :      162845 :               tree init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE);
     772                 :       89718 :               if (move_p && !TYPE_REF_P (expr_type)
     773                 :             :                   /* 'move' breaks bit-fields, and has no effect for scalars.  */
     774                 :      252024 :                   && !scalarish_type_p (expr_type))
     775                 :       78353 :                 init = move (init);
     776                 :      162845 :               init = build_tree_list (NULL_TREE, init);
     777                 :             : 
     778                 :      162845 :               member_init_list = tree_cons (field, init, member_init_list);
     779                 :             :             }
     780                 :             :         }
     781                 :             : 
     782                 :      216905 :       finish_mem_initializers (member_init_list);
     783                 :             :     }
     784                 :      216955 : }
     785                 :             : 
     786                 :             : static void
     787                 :       40851 : do_build_copy_assign (tree fndecl)
     788                 :             : {
     789                 :       40851 :   tree parm = DECL_CHAIN (DECL_ARGUMENTS (fndecl));
     790                 :       40851 :   tree compound_stmt;
     791                 :       40851 :   bool move_p = move_fn_p (fndecl);
     792                 :       40851 :   bool trivial = trivial_fn_p (fndecl);
     793                 :       40851 :   int flags = LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED;
     794                 :             : 
     795                 :       40851 :   compound_stmt = begin_compound_stmt (0);
     796                 :       40851 :   parm = convert_from_reference (parm);
     797                 :             : 
     798                 :             :   /* If we are building a defaulted xobj copy/move assignment operator then
     799                 :             :      current_class_ref will not have been set up.
     800                 :             :      Kind of an icky hack, but what can ya do?  */
     801                 :       81702 :   tree const class_ref = DECL_XOBJ_MEMBER_FUNCTION_P (fndecl)
     802                 :       81702 :     ? cp_build_fold_indirect_ref (DECL_ARGUMENTS (fndecl)) : current_class_ref;
     803                 :             : 
     804                 :       40851 :   if (trivial
     805                 :       40851 :       && is_empty_class (current_class_type))
     806                 :             :     /* Don't copy the padding byte; it might not have been allocated
     807                 :             :        if *this is a base subobject.  */;
     808                 :       40848 :   else if (trivial)
     809                 :             :     {
     810                 :          15 :       tree t = build2 (MODIFY_EXPR, void_type_node, class_ref, parm);
     811                 :          15 :       finish_expr_stmt (t);
     812                 :             :     }
     813                 :             :   else
     814                 :             :     {
     815                 :       40833 :       tree fields;
     816                 :       40833 :       int cvquals = cp_type_quals (TREE_TYPE (parm));
     817                 :       40833 :       int i;
     818                 :       40833 :       tree binfo, base_binfo;
     819                 :             : 
     820                 :             :       /* Assign to each of the direct base classes.  */
     821                 :       40833 :       for (binfo = TYPE_BINFO (current_class_type), i = 0;
     822                 :       60431 :            BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
     823                 :             :         {
     824                 :       19598 :           tree converted_parm;
     825                 :             : 
     826                 :             :           /* We must convert PARM directly to the base class
     827                 :             :              explicitly since the base class may be ambiguous.  */
     828                 :       19598 :           converted_parm = build_base_path (PLUS_EXPR, parm, base_binfo, 1,
     829                 :             :                                             tf_warning_or_error);
     830                 :       19598 :           if (move_p)
     831                 :       19042 :             converted_parm = move (converted_parm);
     832                 :             :           /* Call the base class assignment operator.  */
     833                 :       19598 :           releasing_vec parmvec (make_tree_vector_single (converted_parm));
     834                 :       19598 :           finish_expr_stmt
     835                 :       19598 :             (build_special_member_call (class_ref,
     836                 :             :                                         assign_op_identifier,
     837                 :             :                                         &parmvec,
     838                 :             :                                         base_binfo,
     839                 :             :                                         flags,
     840                 :             :                                         tf_warning_or_error));
     841                 :       19598 :         }
     842                 :             : 
     843                 :             :       /* Assign to each of the non-static data members.  */
     844                 :       40833 :       for (fields = TYPE_FIELDS (current_class_type);
     845                 :     1467007 :            fields;
     846                 :     1426174 :            fields = DECL_CHAIN (fields))
     847                 :             :         {
     848                 :     1426174 :           tree comp = class_ref;
     849                 :     1426174 :           tree init = parm;
     850                 :     1426174 :           tree field = fields;
     851                 :     1426174 :           tree expr_type;
     852                 :     1426174 :           int quals;
     853                 :             : 
     854                 :     1426174 :           if (TREE_CODE (field) != FIELD_DECL || DECL_ARTIFICIAL (field))
     855                 :     1402793 :             continue;
     856                 :             : 
     857                 :       23381 :           expr_type = TREE_TYPE (field);
     858                 :             : 
     859                 :       23381 :           if (CP_TYPE_CONST_P (expr_type))
     860                 :             :             {
     861                 :           2 :               error ("non-static const member %q#D, cannot use default "
     862                 :             :                      "assignment operator", field);
     863                 :           2 :               continue;
     864                 :             :             }
     865                 :       23379 :           else if (TYPE_REF_P (expr_type))
     866                 :             :             {
     867                 :           1 :               error ("non-static reference member %q#D, cannot use "
     868                 :             :                      "default assignment operator", field);
     869                 :           1 :               continue;
     870                 :             :             }
     871                 :             : 
     872                 :       23378 :           if (DECL_NAME (field))
     873                 :             :             {
     874                 :       23375 :               if (VFIELD_NAME_P (DECL_NAME (field)))
     875                 :           0 :                 continue;
     876                 :             :             }
     877                 :           3 :           else if (ANON_AGGR_TYPE_P (expr_type)
     878                 :           6 :                    && TYPE_FIELDS (expr_type) != NULL_TREE)
     879                 :             :             /* Just use the field; anonymous types can't have
     880                 :             :                nontrivial copy ctors or assignment ops or this
     881                 :             :                function would be deleted.  */;
     882                 :             :           else
     883                 :           0 :             continue;
     884                 :             : 
     885                 :       23378 :           comp = build3 (COMPONENT_REF, expr_type, comp, field, NULL_TREE);
     886                 :             : 
     887                 :             :           /* Compute the type of init->field  */
     888                 :       23378 :           quals = cvquals;
     889                 :       23378 :           if (DECL_MUTABLE_P (field))
     890                 :           3 :             quals &= ~TYPE_QUAL_CONST;
     891                 :       23378 :           expr_type = cp_build_qualified_type (expr_type, quals);
     892                 :             : 
     893                 :       23378 :           init = build3 (COMPONENT_REF, expr_type, init, field, NULL_TREE);
     894                 :       21167 :           if (move_p && !TYPE_REF_P (expr_type)
     895                 :             :               /* 'move' breaks bit-fields, and has no effect for scalars.  */
     896                 :       44545 :               && !scalarish_type_p (expr_type))
     897                 :       20986 :             init = move (init);
     898                 :             : 
     899                 :       23378 :           if (DECL_NAME (field))
     900                 :       23375 :             init = cp_build_modify_expr (input_location, comp, NOP_EXPR, init,
     901                 :             :                                          tf_warning_or_error);
     902                 :             :           else
     903                 :           3 :             init = build2 (MODIFY_EXPR, TREE_TYPE (comp), comp, init);
     904                 :       23378 :           finish_expr_stmt (init);
     905                 :             :         }
     906                 :             :     }
     907                 :       40851 :   finish_return_stmt (class_ref);
     908                 :       40851 :   finish_compound_stmt (compound_stmt);
     909                 :       40851 : }
     910                 :             : 
     911                 :             : /* C++20 <compare> comparison category types.  */
     912                 :             : 
     913                 :             : enum comp_cat_tag
     914                 :             : {
     915                 :             :   cc_partial_ordering,
     916                 :             :   cc_weak_ordering,
     917                 :             :   cc_strong_ordering,
     918                 :             :   cc_last
     919                 :             : };
     920                 :             : 
     921                 :             : /* Names of the comparison categories and their value members, to be indexed by
     922                 :             :    comp_cat_tag enumerators.  genericize_spaceship below relies on the ordering
     923                 :             :    of the members.  */
     924                 :             : 
     925                 :             : struct comp_cat_info_t
     926                 :             : {
     927                 :             :   const char *name;
     928                 :             :   const char *members[4];
     929                 :             : };
     930                 :             : static const comp_cat_info_t comp_cat_info[cc_last]
     931                 :             : = {
     932                 :             :    { "partial_ordering", { "equivalent", "greater", "less", "unordered" } },
     933                 :             :    { "weak_ordering", { "equivalent", "greater", "less" } },
     934                 :             :    { "strong_ordering", { "equal", "greater", "less" } }
     935                 :             : };
     936                 :             : 
     937                 :             : /* A cache of the category types to speed repeated lookups.  */
     938                 :             : 
     939                 :             : static GTY((deletable)) tree comp_cat_cache[cc_last];
     940                 :             : 
     941                 :             : /* Look up one of the result variables in the comparison category type.  */
     942                 :             : 
     943                 :             : static tree
     944                 :      266061 : lookup_comparison_result (tree type, const char *name_str,
     945                 :             :                           tsubst_flags_t complain = tf_warning_or_error)
     946                 :             : {
     947                 :      266061 :   tree name = get_identifier (name_str);
     948                 :      266061 :   tree decl = lookup_qualified_name (type, name);
     949                 :      266061 :   if (TREE_CODE (decl) != VAR_DECL)
     950                 :             :     {
     951                 :           3 :       if (complain & tf_error)
     952                 :             :         {
     953                 :           3 :           auto_diagnostic_group d;
     954                 :           3 :           if (decl == error_mark_node || TREE_CODE (decl) == TREE_LIST)
     955                 :           0 :             qualified_name_lookup_error (type, name, decl, input_location);
     956                 :             :           else
     957                 :           3 :             error ("%qD is not a static data member", decl);
     958                 :           3 :           inform (input_location, "determining value of %qs", "operator<=>");
     959                 :           3 :         }
     960                 :           3 :       return error_mark_node;
     961                 :             :     }
     962                 :             :   return decl;
     963                 :             : }
     964                 :             : 
     965                 :             : /* Look up a <compare> comparison category type in std.  */
     966                 :             : 
     967                 :             : static tree
     968                 :      132139 : lookup_comparison_category (comp_cat_tag tag,
     969                 :             :                             tsubst_flags_t complain = tf_warning_or_error)
     970                 :             : {
     971                 :      132139 :   if (tree cached = comp_cat_cache[tag])
     972                 :             :     return cached;
     973                 :             : 
     974                 :       16648 :   tree name = get_identifier (comp_cat_info[tag].name);
     975                 :       16648 :   tree decl = lookup_qualified_name (std_node, name);
     976                 :       16648 :   if (TREE_CODE (decl) != TYPE_DECL)
     977                 :             :     {
     978                 :          15 :       if (complain & tf_error)
     979                 :             :         {
     980                 :           9 :           auto_diagnostic_group d;
     981                 :           9 :           if (decl == error_mark_node || TREE_CODE (decl) == TREE_LIST)
     982                 :           6 :             qualified_name_lookup_error (std_node, name, decl, input_location);
     983                 :             :           else
     984                 :           3 :             error ("%qD is not a type", decl);
     985                 :           9 :           inform (input_location, "forming type of %qs", "operator<=>");
     986                 :           9 :         }
     987                 :          15 :       return error_mark_node;
     988                 :             :     }
     989                 :             :   /* Also make sure we can look up the value members now, since we won't
     990                 :             :      really use them until genericize time.  */
     991                 :       16633 :   tree type = TREE_TYPE (decl);
     992                 :       66613 :   for (int i = 0; i < 4; ++i)
     993                 :             :     {
     994                 :       66523 :       const char *p = comp_cat_info[tag].members[i];
     995                 :       66523 :       if (!p) break;
     996                 :       49983 :       if (lookup_comparison_result (type, p, complain)
     997                 :       49983 :           == error_mark_node)
     998                 :           3 :         return error_mark_node;
     999                 :             :     }
    1000                 :       16630 :   return comp_cat_cache[tag] = type;
    1001                 :             : }
    1002                 :             : 
    1003                 :             : /* Wrapper that takes the tag rather than the type.  */
    1004                 :             : 
    1005                 :             : static tree
    1006                 :         135 : lookup_comparison_result (comp_cat_tag tag, const char *name_str,
    1007                 :             :                           tsubst_flags_t complain = tf_warning_or_error)
    1008                 :             : {
    1009                 :         135 :   tree type = lookup_comparison_category (tag, complain);
    1010                 :         135 :   return lookup_comparison_result (type, name_str, complain);
    1011                 :             : }
    1012                 :             : 
    1013                 :             : /* Wrapper that takes the index into the members array instead of the name.  */
    1014                 :             : 
    1015                 :             : static tree
    1016                 :      215943 : lookup_comparison_result (comp_cat_tag tag, tree type, int idx)
    1017                 :             : {
    1018                 :      215943 :   const char *name_str = comp_cat_info[tag].members[idx];
    1019                 :      215943 :   if (!name_str)
    1020                 :             :     return NULL_TREE;
    1021                 :      215943 :   return lookup_comparison_result (type, name_str);
    1022                 :             : }
    1023                 :             : 
    1024                 :             : /* Does TYPE correspond to TAG?  */
    1025                 :             : 
    1026                 :             : static bool
    1027                 :      214977 : is_cat (tree type, comp_cat_tag tag)
    1028                 :             : {
    1029                 :      214977 :   tree name = TYPE_LINKAGE_IDENTIFIER (type);
    1030                 :      214977 :   return id_equal (name, comp_cat_info[tag].name);
    1031                 :             : }
    1032                 :             : 
    1033                 :             : /* Return the comp_cat_tag for TYPE.  */
    1034                 :             : 
    1035                 :             : static comp_cat_tag
    1036                 :       72113 : cat_tag_for (tree type)
    1037                 :             : {
    1038                 :       72113 :   if (!CLASS_TYPE_P (type) || !decl_in_std_namespace_p (TYPE_MAIN_DECL (type)))
    1039                 :          21 :     return cc_last;
    1040                 :      214977 :   for (int i = 0; i < cc_last; ++i)
    1041                 :             :     {
    1042                 :      214977 :       comp_cat_tag tag = (comp_cat_tag)i;
    1043                 :      214977 :       if (is_cat (type, tag))
    1044                 :       72092 :         return tag;
    1045                 :             :     }
    1046                 :             :   return cc_last;
    1047                 :             : }
    1048                 :             : 
    1049                 :             : /* Return the comparison category tag of a <=> expression with non-class type
    1050                 :             :    OPTYPE.  */
    1051                 :             : 
    1052                 :             : static comp_cat_tag
    1053                 :      131980 : spaceship_comp_cat (tree optype)
    1054                 :             : {
    1055                 :      131980 :   if (INTEGRAL_OR_ENUMERATION_TYPE_P (optype) || TYPE_PTROBV_P (optype))
    1056                 :             :     return cc_strong_ordering;
    1057                 :         499 :   else if (SCALAR_FLOAT_TYPE_P (optype))
    1058                 :             :     return cc_partial_ordering;
    1059                 :             : 
    1060                 :             :   /* ??? should vector <=> produce a vector of one of the above?  */
    1061                 :           0 :   gcc_unreachable ();
    1062                 :             : }
    1063                 :             : 
    1064                 :             : /* Return the comparison category type of a <=> expression with non-class type
    1065                 :             :    OPTYPE.  */
    1066                 :             : 
    1067                 :             : tree
    1068                 :      131980 : spaceship_type (tree optype, tsubst_flags_t complain)
    1069                 :             : {
    1070                 :      131980 :   comp_cat_tag tag = spaceship_comp_cat (optype);
    1071                 :      131980 :   return lookup_comparison_category (tag, complain);
    1072                 :             : }
    1073                 :             : 
    1074                 :             : /* Turn <=> with type TYPE and operands OP0 and OP1 into GENERIC.
    1075                 :             :    This is also used by build_comparison_op for fallback to op< and op==
    1076                 :             :    in a defaulted op<=>.  */
    1077                 :             : 
    1078                 :             : tree
    1079                 :       71788 : genericize_spaceship (location_t loc, tree type, tree op0, tree op1)
    1080                 :             : {
    1081                 :             :   /* ??? maybe optimize based on knowledge of representation? */
    1082                 :       71788 :   comp_cat_tag tag = cat_tag_for (type);
    1083                 :             : 
    1084                 :       71788 :   if (tag == cc_last && is_auto (type))
    1085                 :             :     {
    1086                 :             :       /* build_comparison_op is checking to see if we want to suggest changing
    1087                 :             :          the op<=> return type from auto to a specific comparison category; any
    1088                 :             :          category will do for now.  */
    1089                 :           0 :       tag = cc_strong_ordering;
    1090                 :           0 :       type = lookup_comparison_category (tag, tf_none);
    1091                 :           0 :       if (type == error_mark_node)
    1092                 :             :         return error_mark_node;
    1093                 :             :     }
    1094                 :             : 
    1095                 :       71788 :   gcc_checking_assert (tag < cc_last);
    1096                 :             : 
    1097                 :       71788 :   tree r;
    1098                 :       71788 :   bool scalar = SCALAR_TYPE_P (TREE_TYPE (op0));
    1099                 :       71731 :   if (scalar)
    1100                 :             :     {
    1101                 :       71731 :       op0 = save_expr (op0);
    1102                 :       71731 :       op1 = save_expr (op1);
    1103                 :             :     }
    1104                 :             : 
    1105                 :       71788 :   tree gt = lookup_comparison_result (tag, type, 1);
    1106                 :             : 
    1107                 :       71788 :   int flags = LOOKUP_NORMAL;
    1108                 :       71788 :   tsubst_flags_t complain = tf_none;
    1109                 :       71788 :   tree comp;
    1110                 :             : 
    1111                 :       71788 :   if (tag == cc_partial_ordering)
    1112                 :             :     {
    1113                 :             :       /* op0 == op1 ? equivalent : op0 < op1 ? less :
    1114                 :             :          op1 < op0 ? greater : unordered */
    1115                 :         579 :       tree uo = lookup_comparison_result (tag, type, 3);
    1116                 :         579 :       if (scalar)
    1117                 :             :         {
    1118                 :             :           /* For scalars use the low level operations; using build_new_op causes
    1119                 :             :              trouble with constexpr eval in the middle of genericize (100367).  */
    1120                 :         567 :           comp = fold_build2 (LT_EXPR, boolean_type_node, op1, op0);
    1121                 :         567 :           r = fold_build3 (COND_EXPR, type, comp, gt, uo);
    1122                 :             :         }
    1123                 :             :       else
    1124                 :             :         {
    1125                 :          12 :           comp = build_new_op (loc, LT_EXPR, flags, op1, op0, complain);
    1126                 :          12 :           r = build_conditional_expr (loc, comp, gt, uo, complain);
    1127                 :             :         }
    1128                 :             :     }
    1129                 :             :   else
    1130                 :             :     /* op0 == op1 ? equal : op0 < op1 ? less : greater */
    1131                 :             :     r = gt;
    1132                 :             : 
    1133                 :       71788 :   tree lt = lookup_comparison_result (tag, type, 2);
    1134                 :       71788 :   if (scalar)
    1135                 :             :     {
    1136                 :       71731 :       comp = fold_build2 (LT_EXPR, boolean_type_node, op0, op1);
    1137                 :       71731 :       r = fold_build3 (COND_EXPR, type, comp, lt, r);
    1138                 :             :     }
    1139                 :             :   else
    1140                 :             :     {
    1141                 :          57 :       comp = build_new_op (loc, LT_EXPR, flags, op0, op1, complain);
    1142                 :          57 :       r = build_conditional_expr (loc, comp, lt, r, complain);
    1143                 :             :     }
    1144                 :             : 
    1145                 :       71788 :   tree eq = lookup_comparison_result (tag, type, 0);
    1146                 :       71788 :   if (scalar)
    1147                 :             :     {
    1148                 :       71731 :       comp = fold_build2 (EQ_EXPR, boolean_type_node, op0, op1);
    1149                 :       71731 :       r = fold_build3 (COND_EXPR, type, comp, eq, r);
    1150                 :             :     }
    1151                 :             :   else
    1152                 :             :     {
    1153                 :          57 :       comp = build_new_op (loc, EQ_EXPR, flags, op0, op1, complain);
    1154                 :          57 :       r = build_conditional_expr (loc, comp, eq, r, complain);
    1155                 :             :     }
    1156                 :             : 
    1157                 :             :   return r;
    1158                 :             : }
    1159                 :             : 
    1160                 :             : /* Check that the signature of a defaulted comparison operator is
    1161                 :             :    well-formed.  */
    1162                 :             : 
    1163                 :             : static bool
    1164                 :       48279 : early_check_defaulted_comparison (tree fn)
    1165                 :             : {
    1166                 :       48279 :   location_t loc = DECL_SOURCE_LOCATION (fn);
    1167                 :       48279 :   tree ctx;
    1168                 :       48279 :   if (DECL_CLASS_SCOPE_P (fn))
    1169                 :        6510 :     ctx = DECL_CONTEXT (fn);
    1170                 :             :   else
    1171                 :       83538 :     ctx = DECL_FRIEND_CONTEXT (fn);
    1172                 :       48279 :   bool ok = true;
    1173                 :             : 
    1174                 :       48279 :   if (cxx_dialect < cxx20)
    1175                 :             :     {
    1176                 :           4 :       error_at (loc, "defaulted %qD only available with %<-std=c++20%> or "
    1177                 :             :                      "%<-std=gnu++20%>", fn);
    1178                 :           4 :       return false;
    1179                 :             :     }
    1180                 :             : 
    1181                 :       48275 :   if (!DECL_OVERLOADED_OPERATOR_IS (fn, SPACESHIP_EXPR)
    1182                 :       48275 :       && !same_type_p (TREE_TYPE (TREE_TYPE (fn)), boolean_type_node))
    1183                 :             :     {
    1184                 :           6 :       diagnostic_t kind = DK_UNSPECIFIED;
    1185                 :           6 :       int opt = 0;
    1186                 :           6 :       if (is_auto (TREE_TYPE (fn)))
    1187                 :             :         kind = DK_PEDWARN;
    1188                 :             :       else
    1189                 :           6 :         kind = DK_ERROR;
    1190                 :           6 :       emit_diagnostic (kind, loc, opt,
    1191                 :             :                        "defaulted %qD must return %<bool%>", fn);
    1192                 :           6 :       if (kind == DK_ERROR)
    1193                 :       48275 :         ok = false;
    1194                 :             :     }
    1195                 :             : 
    1196                 :       48275 :   bool mem = DECL_IOBJ_MEMBER_FUNCTION_P (fn);
    1197                 :       48275 :   if (mem && type_memfn_quals (TREE_TYPE (fn)) != TYPE_QUAL_CONST)
    1198                 :             :     {
    1199                 :           3 :       error_at (loc, "defaulted %qD must be %<const%>", fn);
    1200                 :           3 :       ok = false;
    1201                 :             :     }
    1202                 :       48275 :   if (mem && type_memfn_rqual (TREE_TYPE (fn)) == REF_QUAL_RVALUE)
    1203                 :             :     {
    1204                 :           3 :       error_at (loc, "defaulted %qD must not have %<&&%> ref-qualifier", fn);
    1205                 :           3 :       ok = false;
    1206                 :             :     }
    1207                 :       48275 :   tree parmnode = FUNCTION_FIRST_USER_PARMTYPE (fn);
    1208                 :       48275 :   bool saw_byval = false;
    1209                 :       48275 :   bool saw_byref = mem;
    1210                 :       48275 :   bool saw_bad = false;
    1211                 :      138323 :   for (; parmnode != void_list_node; parmnode = TREE_CHAIN (parmnode))
    1212                 :             :     {
    1213                 :       90048 :       tree parmtype = TREE_VALUE (parmnode);
    1214                 :       90048 :       if (CLASS_TYPE_P (parmtype))
    1215                 :             :         saw_byval = true;
    1216                 :       71608 :       else if (TREE_CODE (parmtype) == REFERENCE_TYPE
    1217                 :       71605 :                && !TYPE_REF_IS_RVALUE (parmtype)
    1218                 :      143207 :                && TYPE_QUALS (TREE_TYPE (parmtype)) == TYPE_QUAL_CONST)
    1219                 :             :         {
    1220                 :       71599 :           saw_byref = true;
    1221                 :       71599 :           parmtype = TREE_TYPE (parmtype);
    1222                 :             :         }
    1223                 :             :       else
    1224                 :             :         saw_bad = true;
    1225                 :             : 
    1226                 :       90048 :       if (!saw_bad && !ctx)
    1227                 :             :         {
    1228                 :             :           /* Defaulted outside the class body.  */
    1229                 :          21 :           ctx = TYPE_MAIN_VARIANT (parmtype);
    1230                 :          21 :           if (!is_friend (ctx, fn))
    1231                 :             :             {
    1232                 :          15 :               auto_diagnostic_group d;
    1233                 :          15 :               error_at (loc, "defaulted %qD is not a friend of %qT", fn, ctx);
    1234                 :          15 :               inform (location_of (ctx), "declared here");
    1235                 :          15 :               ok = false;
    1236                 :          15 :             }
    1237                 :             :         }
    1238                 :       90027 :       else if (!same_type_ignoring_top_level_qualifiers_p (parmtype, ctx))
    1239                 :           9 :         saw_bad = true;
    1240                 :             :     }
    1241                 :             : 
    1242                 :       48275 :   if (saw_bad || (saw_byval && saw_byref))
    1243                 :             :     {
    1244                 :          48 :       if (DECL_IOBJ_MEMBER_FUNCTION_P (fn))
    1245                 :          24 :         error_at (loc, "defaulted member %qD must have parameter type "
    1246                 :             :                   "%<const %T&%>", fn, ctx);
    1247                 :          24 :       else if (saw_bad)
    1248                 :           3 :         error_at (loc, "defaulted %qD must have parameters of either type "
    1249                 :             :                   "%<const %T&%> or %qT", fn, ctx, ctx);
    1250                 :             :       else
    1251                 :          21 :         error_at (loc, "defaulted %qD must have parameters of either type "
    1252                 :             :                   "%<const %T&%> or %qT, not both", fn, ctx, ctx);
    1253                 :             :       ok = false;
    1254                 :             :     }
    1255                 :             : 
    1256                 :             :   /* We still need to deduce deleted/constexpr/noexcept and maybe return. */
    1257                 :       48275 :   DECL_MAYBE_DELETED (fn) = ok;
    1258                 :             : 
    1259                 :       48275 :   return ok;
    1260                 :             : }
    1261                 :             : 
    1262                 :             : /* Subroutine of build_comparison_op.  Given the vec of memberwise
    1263                 :             :    comparisons COMPS, calculate the overall comparison category for
    1264                 :             :    operator<=>.  */
    1265                 :             : 
    1266                 :             : static tree
    1267                 :         103 : common_comparison_type (vec<tree> &comps)
    1268                 :             : {
    1269                 :         103 :   tree seen[cc_last] = {};
    1270                 :             : 
    1271                 :         370 :   for (unsigned i = 0; i < comps.length(); ++i)
    1272                 :             :     {
    1273                 :          94 :       tree comp = comps[i];
    1274                 :          94 :       if (TREE_CODE (comp) == TREE_LIST)
    1275                 :           3 :         comp = TREE_VALUE (comp);
    1276                 :          94 :       tree ctype = TREE_TYPE (comp);
    1277                 :          94 :       comp_cat_tag tag = cat_tag_for (ctype);
    1278                 :             :       /* build_comparison_op already checked this.  */
    1279                 :          94 :       gcc_checking_assert (tag < cc_last);
    1280                 :          94 :       seen[tag] = ctype;
    1281                 :             :     }
    1282                 :             : 
    1283                 :             :   /* Otherwise, if at least one T i is std::partial_ordering, U is
    1284                 :             :      std::partial_ordering.  */
    1285                 :         103 :   if (tree t = seen[cc_partial_ordering]) return t;
    1286                 :             : 
    1287                 :             :   /* Otherwise, if at least one T i is std::weak_ordering, U is
    1288                 :             :      std::weak_ordering.  */
    1289                 :          85 :   if (tree t = seen[cc_weak_ordering]) return t;
    1290                 :             : 
    1291                 :             :   /* Otherwise, U is std::strong_ordering.  */
    1292                 :          85 :   if (tree t = seen[cc_strong_ordering]) return t;
    1293                 :          24 :   return lookup_comparison_category (cc_strong_ordering);
    1294                 :             : }
    1295                 :             : 
    1296                 :             : /* Data structure for build_comparison_op.  */
    1297                 :             : 
    1298                 :             : struct comp_info
    1299                 :             : {
    1300                 :             :   tree fndecl;
    1301                 :             :   location_t loc;
    1302                 :             :   tsubst_flags_t complain;
    1303                 :             :   tree_code code;
    1304                 :             :   comp_cat_tag retcat;
    1305                 :             :   bool first_time;
    1306                 :             :   bool constexp;
    1307                 :             :   bool was_constexp;
    1308                 :             :   bool noex;
    1309                 :             : 
    1310                 :       14930 :   comp_info (tree fndecl, tsubst_flags_t complain)
    1311                 :       14930 :     : fndecl (fndecl), complain (complain)
    1312                 :             :   {
    1313                 :       14930 :     loc = DECL_SOURCE_LOCATION (fndecl);
    1314                 :             : 
    1315                 :       14930 :     first_time = DECL_MAYBE_DELETED (fndecl);
    1316                 :       14930 :     DECL_MAYBE_DELETED (fndecl) = false;
    1317                 :             : 
    1318                 :             :     /* Do we want to try to set constexpr?  */
    1319                 :       14930 :     was_constexp = DECL_DECLARED_CONSTEXPR_P (fndecl);
    1320                 :       14930 :     constexp = first_time;
    1321                 :       14930 :     if (constexp)
    1322                 :             :       /* Set this for var_in_constexpr_fn.  */
    1323                 :       14843 :       DECL_DECLARED_CONSTEXPR_P (fndecl) = true;
    1324                 :             : 
    1325                 :             :     /* Do we want to try to set noexcept?  */
    1326                 :       14930 :     noex = first_time;
    1327                 :       14930 :     if (noex)
    1328                 :             :       {
    1329                 :       14843 :         tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fndecl));
    1330                 :       19934 :         if (raises && !UNEVALUATED_NOEXCEPT_SPEC_P (raises))
    1331                 :             :           /* There was an explicit exception-specification.  */
    1332                 :        5091 :           noex = false;
    1333                 :             :       }
    1334                 :       14930 :   }
    1335                 :             : 
    1336                 :             :   /* EXPR is an expression built as part of the function body.
    1337                 :             :      Adjust the properties appropriately.  */
    1338                 :       22264 :   void check (tree expr)
    1339                 :             :   {
    1340                 :       22264 :     if (expr == error_mark_node)
    1341                 :           0 :       DECL_DELETED_FN (fndecl) = true;
    1342                 :          62 :     if ((constexp || was_constexp)
    1343                 :       22291 :         && !potential_rvalue_constant_expression (expr))
    1344                 :             :       {
    1345                 :         152 :         if (was_constexp)
    1346                 :          12 :           require_potential_rvalue_constant_expression_fncheck (expr);
    1347                 :             :         else
    1348                 :         140 :           constexp = false;
    1349                 :             :       }
    1350                 :       22264 :     if (noex && !expr_noexcept_p (expr, tf_none))
    1351                 :          47 :       noex = false;
    1352                 :       22264 :   }
    1353                 :             : 
    1354                 :       14930 :   ~comp_info ()
    1355                 :             :   {
    1356                 :       14930 :     if (first_time)
    1357                 :             :       {
    1358                 :       14843 :         DECL_DECLARED_CONSTEXPR_P (fndecl) = constexp || was_constexp;
    1359                 :       14843 :         tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fndecl));
    1360                 :       19934 :         if (!raises || UNEVALUATED_NOEXCEPT_SPEC_P (raises))
    1361                 :             :           {
    1362                 :        9752 :             raises = noex ? noexcept_true_spec : noexcept_false_spec;
    1363                 :        9752 :             TREE_TYPE (fndecl) = build_exception_variant (TREE_TYPE (fndecl),
    1364                 :             :                                                           raises);
    1365                 :             :           }
    1366                 :             :       }
    1367                 :       14930 :   }
    1368                 :             : };
    1369                 :             : 
    1370                 :             : /* Subroutine of build_comparison_op, to compare a single subobject.  */
    1371                 :             : 
    1372                 :             : static tree
    1373                 :       22169 : do_one_comp (location_t loc, const comp_info &info, tree sub, tree lhs, tree rhs)
    1374                 :             : {
    1375                 :       22169 :   const tree_code code = info.code;
    1376                 :       22169 :   const tree fndecl = info.fndecl;
    1377                 :       22169 :   const comp_cat_tag retcat = info.retcat;
    1378                 :       22169 :   const tsubst_flags_t complain = info.complain;
    1379                 :             : 
    1380                 :       22169 :   tree overload = NULL_TREE;
    1381                 :       22169 :   int flags = LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED;
    1382                 :             :   /* If we have an explicit comparison category return type we can fall back
    1383                 :             :      to </=, so don't give an error yet if <=> lookup fails.  */
    1384                 :       22169 :   bool tentative = retcat != cc_last;
    1385                 :       44205 :   tree comp = build_new_op (loc, code, flags, lhs, rhs,
    1386                 :             :                             NULL_TREE, NULL_TREE, &overload,
    1387                 :             :                             tentative ? tf_none : complain);
    1388                 :             : 
    1389                 :       22169 :   if (code != SPACESHIP_EXPR)
    1390                 :             :     return comp;
    1391                 :             : 
    1392                 :         293 :   tree rettype = TREE_TYPE (TREE_TYPE (fndecl));
    1393                 :             : 
    1394                 :         293 :   if (comp == error_mark_node)
    1395                 :             :     {
    1396                 :          90 :       if (overload == NULL_TREE && (tentative || complain))
    1397                 :             :         {
    1398                 :             :           /* No viable <=>, try using op< and op==.  */
    1399                 :          57 :           tree lteq = genericize_spaceship (loc, rettype, lhs, rhs);
    1400                 :          57 :           if (lteq != error_mark_node)
    1401                 :             :             {
    1402                 :             :               /* We found usable < and ==.  */
    1403                 :          27 :               if (retcat != cc_last)
    1404                 :             :                 /* Return type is a comparison category, use them.  */
    1405                 :             :                 comp = lteq;
    1406                 :           9 :               else if (complain & tf_error)
    1407                 :             :                 /* Return type is auto, suggest changing it.  */
    1408                 :           9 :                 inform (info.loc, "changing the return type from %qs "
    1409                 :             :                         "to a comparison category type will allow the "
    1410                 :             :                         "comparison to use %qs and %qs", "auto",
    1411                 :             :                         "operator<", "operator==");
    1412                 :             :             }
    1413                 :          30 :           else if (tentative && complain)
    1414                 :             :             /* No usable < and ==, give an error for op<=>.  */
    1415                 :          12 :             build_new_op (loc, code, flags, lhs, rhs, complain);
    1416                 :             :         }
    1417                 :          90 :       if (comp == error_mark_node)
    1418                 :             :         return error_mark_node;
    1419                 :             :     }
    1420                 :             : 
    1421                 :         221 :   if (FNDECL_USED_AUTO (fndecl)
    1422                 :         221 :       && cat_tag_for (TREE_TYPE (comp)) == cc_last)
    1423                 :             :     {
    1424                 :             :       /* The operator function is defined as deleted if ... Ri is not a
    1425                 :             :          comparison category type.  */
    1426                 :           6 :       if (complain & tf_error)
    1427                 :           3 :         inform (loc,
    1428                 :             :                 "three-way comparison of %qD has type %qT, not a "
    1429                 :           3 :                 "comparison category type", sub, TREE_TYPE (comp));
    1430                 :           6 :       return error_mark_node;
    1431                 :             :     }
    1432                 :         215 :   else if (!FNDECL_USED_AUTO (fndecl)
    1433                 :         215 :            && !can_convert (rettype, TREE_TYPE (comp), complain))
    1434                 :             :     {
    1435                 :          24 :       if (complain & tf_error)
    1436                 :          12 :         error_at (loc,
    1437                 :             :                   "three-way comparison of %qD has type %qT, which "
    1438                 :             :                   "does not convert to %qT",
    1439                 :          12 :                   sub, TREE_TYPE (comp), rettype);
    1440                 :          24 :       return error_mark_node;
    1441                 :             :     }
    1442                 :             : 
    1443                 :             :   return comp;
    1444                 :             : }
    1445                 :             : 
    1446                 :             : /* Build up the definition of a defaulted comparison operator.  Unlike other
    1447                 :             :    defaulted functions that use synthesized_method_walk to determine whether
    1448                 :             :    the function is e.g. deleted, for comparisons we use the same code.  We try
    1449                 :             :    to use synthesize_method at the earliest opportunity and bail out if the
    1450                 :             :    function ends up being deleted.  */
    1451                 :             : 
    1452                 :             : void
    1453                 :       14930 : build_comparison_op (tree fndecl, bool defining, tsubst_flags_t complain)
    1454                 :             : {
    1455                 :       14930 :   comp_info info (fndecl, complain);
    1456                 :             : 
    1457                 :       14930 :   if (!defining && !(complain & tf_error) && !DECL_MAYBE_DELETED (fndecl))
    1458                 :             :     return;
    1459                 :             : 
    1460                 :       14921 :   int flags = LOOKUP_NORMAL;
    1461                 :       14921 :   const ovl_op_info_t *op = IDENTIFIER_OVL_OP_INFO (DECL_NAME (fndecl));
    1462                 :       14921 :   tree_code code = info.code = op->tree_code;
    1463                 :             : 
    1464                 :       14921 :   tree lhs = DECL_ARGUMENTS (fndecl);
    1465                 :       14921 :   tree rhs = DECL_CHAIN (lhs);
    1466                 :       14921 :   if (is_this_parameter (lhs))
    1467                 :        7680 :     lhs = cp_build_fold_indirect_ref (lhs);
    1468                 :             :   else
    1469                 :        7241 :     lhs = convert_from_reference (lhs);
    1470                 :       14921 :   rhs = convert_from_reference (rhs);
    1471                 :       14921 :   tree ctype = TYPE_MAIN_VARIANT (TREE_TYPE (lhs));
    1472                 :       14921 :   gcc_assert (!defining || COMPLETE_TYPE_P (ctype));
    1473                 :             : 
    1474                 :       14921 :   iloc_sentinel ils (info.loc);
    1475                 :             : 
    1476                 :             :   /* A defaulted comparison operator function for class C is defined as
    1477                 :             :      deleted if ... C has variant members.  */
    1478                 :       14921 :   if (TREE_CODE (ctype) == UNION_TYPE
    1479                 :       14921 :       && next_aggregate_field (TYPE_FIELDS (ctype)))
    1480                 :             :     {
    1481                 :           6 :       if (complain & tf_error)
    1482                 :           3 :         inform (info.loc, "cannot default compare union %qT", ctype);
    1483                 :           6 :       DECL_DELETED_FN (fndecl) = true;
    1484                 :           6 :       return;
    1485                 :             :     }
    1486                 :             : 
    1487                 :       14915 :   tree compound_stmt = NULL_TREE;
    1488                 :       14915 :   if (defining)
    1489                 :       14846 :     compound_stmt = begin_compound_stmt (0);
    1490                 :             :   else
    1491                 :          69 :     ++cp_unevaluated_operand;
    1492                 :             : 
    1493                 :       14915 :   tree rettype = TREE_TYPE (TREE_TYPE (fndecl));
    1494                 :       14915 :   if (code != SPACESHIP_EXPR && is_auto (rettype))
    1495                 :             :     {
    1496                 :           0 :       rettype = boolean_type_node;
    1497                 :           0 :       apply_deduced_return_type (fndecl, rettype);
    1498                 :             :     }
    1499                 :             : 
    1500                 :       14915 :   if (code == EQ_EXPR || code == SPACESHIP_EXPR)
    1501                 :             :     {
    1502                 :       14840 :       comp_cat_tag &retcat = (info.retcat = cc_last);
    1503                 :       15083 :       if (code == SPACESHIP_EXPR && !FNDECL_USED_AUTO (fndecl))
    1504                 :         119 :         retcat = cat_tag_for (rettype);
    1505                 :             : 
    1506                 :       14840 :       bool bad = false;
    1507                 :       14840 :       auto_vec<tree> comps;
    1508                 :             : 
    1509                 :             :       /* Compare the base subobjects.  We handle them this way, rather than in
    1510                 :             :          the field loop below, because maybe_instantiate_noexcept might bring
    1511                 :             :          us here before we've built the base fields.  */
    1512                 :       14972 :       for (tree base_binfo : BINFO_BASE_BINFOS (TYPE_BINFO (ctype)))
    1513                 :             :         {
    1514                 :         132 :           tree lhs_base
    1515                 :         132 :             = build_base_path (PLUS_EXPR, lhs, base_binfo, 0, complain);
    1516                 :         132 :           tree rhs_base
    1517                 :         132 :             = build_base_path (PLUS_EXPR, rhs, base_binfo, 0, complain);
    1518                 :             : 
    1519                 :         132 :           location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (ctype));
    1520                 :         132 :           tree comp = do_one_comp (loc, info, BINFO_TYPE (base_binfo),
    1521                 :         132 :                                    lhs_base, rhs_base);
    1522                 :         132 :           if (comp == error_mark_node)
    1523                 :             :             {
    1524                 :          12 :               bad = true;
    1525                 :          12 :               continue;
    1526                 :             :             }
    1527                 :             : 
    1528                 :         120 :           comps.safe_push (comp);
    1529                 :             :         }
    1530                 :             : 
    1531                 :             :       /* Now compare the field subobjects.  */
    1532                 :       14840 :       for (tree field = next_aggregate_field (TYPE_FIELDS (ctype));
    1533                 :       37033 :            field;
    1534                 :       22193 :            field = next_aggregate_field (DECL_CHAIN (field)))
    1535                 :             :         {
    1536                 :       44386 :           if (DECL_VIRTUAL_P (field) || DECL_FIELD_IS_BASE (field))
    1537                 :             :             /* We ignore the vptr, and we already handled bases.  */
    1538                 :         255 :             continue;
    1539                 :             : 
    1540                 :       22061 :           tree expr_type = TREE_TYPE (field);
    1541                 :             : 
    1542                 :       22061 :           location_t field_loc = DECL_SOURCE_LOCATION (field);
    1543                 :             : 
    1544                 :             :           /* A defaulted comparison operator function for class C is defined as
    1545                 :             :              deleted if any non-static data member of C is of reference type or
    1546                 :             :              C has variant members.  */
    1547                 :       22061 :           if (TREE_CODE (expr_type) == REFERENCE_TYPE)
    1548                 :             :             {
    1549                 :           6 :               if (complain & tf_error)
    1550                 :           3 :                 inform (field_loc, "cannot default compare "
    1551                 :             :                         "reference member %qD", field);
    1552                 :           6 :               bad = true;
    1553                 :           6 :               continue;
    1554                 :             :             }
    1555                 :           6 :           else if (ANON_UNION_TYPE_P (expr_type)
    1556                 :       22061 :                    && next_aggregate_field (TYPE_FIELDS (expr_type)))
    1557                 :             :             {
    1558                 :           6 :               if (complain & tf_error)
    1559                 :           3 :                 inform (field_loc, "cannot default compare "
    1560                 :             :                         "anonymous union member");
    1561                 :           6 :               bad = true;
    1562                 :           6 :               continue;
    1563                 :             :             }
    1564                 :             : 
    1565                 :       22049 :           tree lhs_mem = build3_loc (field_loc, COMPONENT_REF, expr_type, lhs,
    1566                 :             :                                      field, NULL_TREE);
    1567                 :       22049 :           tree rhs_mem = build3_loc (field_loc, COMPONENT_REF, expr_type, rhs,
    1568                 :             :                                      field, NULL_TREE);
    1569                 :       22049 :           tree loop_indexes = NULL_TREE;
    1570                 :       44104 :           while (TREE_CODE (expr_type) == ARRAY_TYPE)
    1571                 :             :             {
    1572                 :             :               /* Flexible array member.  */
    1573                 :          18 :               if (TYPE_DOMAIN (expr_type) == NULL_TREE
    1574                 :          18 :                   || TYPE_MAX_VALUE (TYPE_DOMAIN (expr_type)) == NULL_TREE)
    1575                 :             :                 {
    1576                 :           6 :                   if (complain & tf_error)
    1577                 :           3 :                     inform (field_loc, "cannot default compare "
    1578                 :             :                                        "flexible array member");
    1579                 :             :                   bad = true;
    1580                 :             :                   break;
    1581                 :             :                 }
    1582                 :          12 :               tree maxval = TYPE_MAX_VALUE (TYPE_DOMAIN (expr_type));
    1583                 :             :               /* [0] array.  No subobjects to compare, just skip it.  */
    1584                 :          12 :               if (integer_all_onesp (maxval))
    1585                 :             :                 break;
    1586                 :           6 :               tree idx;
    1587                 :             :               /* [1] array, no loop needed, just add [0] ARRAY_REF.
    1588                 :             :                  Similarly if !defining.  */
    1589                 :           6 :               if (integer_zerop (maxval) || !defining)
    1590                 :           3 :                 idx = size_zero_node;
    1591                 :             :               /* Some other array, will need runtime loop.  */
    1592                 :             :               else
    1593                 :             :                 {
    1594                 :           3 :                   idx = force_target_expr (sizetype, maxval, complain);
    1595                 :           3 :                   loop_indexes = tree_cons (idx, NULL_TREE, loop_indexes);
    1596                 :             :                 }
    1597                 :           6 :               expr_type = TREE_TYPE (expr_type);
    1598                 :           6 :               lhs_mem = build4_loc (field_loc, ARRAY_REF, expr_type, lhs_mem,
    1599                 :             :                                     idx, NULL_TREE, NULL_TREE);
    1600                 :           6 :               rhs_mem = build4_loc (field_loc, ARRAY_REF, expr_type, rhs_mem,
    1601                 :             :                                     idx, NULL_TREE, NULL_TREE);
    1602                 :             :             }
    1603                 :       22049 :           if (TREE_CODE (expr_type) == ARRAY_TYPE)
    1604                 :          12 :             continue;
    1605                 :             : 
    1606                 :       22037 :           tree comp = do_one_comp (field_loc, info, field, lhs_mem, rhs_mem);
    1607                 :       22037 :           if (comp == error_mark_node)
    1608                 :             :             {
    1609                 :          99 :               bad = true;
    1610                 :          99 :               continue;
    1611                 :             :             }
    1612                 :             : 
    1613                 :             :           /* Most of the time, comp is the expression that should be evaluated
    1614                 :             :              to compare the two members.  If the expression needs to be
    1615                 :             :              evaluated more than once in a loop, it will be a TREE_LIST
    1616                 :             :              instead, whose TREE_VALUE is the expression for one array element,
    1617                 :             :              TREE_PURPOSE is innermost iterator temporary and if the array
    1618                 :             :              is multidimensional, TREE_CHAIN will contain another TREE_LIST
    1619                 :             :              with second innermost iterator in its TREE_PURPOSE and so on.  */
    1620                 :       21938 :           if (loop_indexes)
    1621                 :             :             {
    1622                 :           3 :               TREE_VALUE (loop_indexes) = comp;
    1623                 :           3 :               comp = loop_indexes;
    1624                 :             :             }
    1625                 :       21938 :           comps.safe_push (comp);
    1626                 :             :         }
    1627                 :       14840 :       if (code == SPACESHIP_EXPR && is_auto (rettype))
    1628                 :             :         {
    1629                 :         103 :           rettype = common_comparison_type (comps);
    1630                 :         103 :           apply_deduced_return_type (fndecl, rettype);
    1631                 :             :         }
    1632                 :       14840 :       if (bad)
    1633                 :             :         {
    1634                 :         129 :           DECL_DELETED_FN (fndecl) = true;
    1635                 :         129 :           goto out;
    1636                 :             :         }
    1637                 :       73442 :       for (unsigned i = 0; i < comps.length(); ++i)
    1638                 :             :         {
    1639                 :       22028 :           tree comp = comps[i];
    1640                 :       22028 :           tree eq, retval = NULL_TREE, if_ = NULL_TREE;
    1641                 :       22028 :           tree loop_indexes = NULL_TREE;
    1642                 :       22028 :           if (defining)
    1643                 :             :             {
    1644                 :       22022 :               if (TREE_CODE (comp) == TREE_LIST)
    1645                 :             :                 {
    1646                 :           3 :                   loop_indexes = comp;
    1647                 :           3 :                   comp = TREE_VALUE (comp);
    1648                 :           3 :                   loop_indexes = nreverse (loop_indexes);
    1649                 :           6 :                   for (tree loop_index = loop_indexes; loop_index;
    1650                 :           3 :                        loop_index = TREE_CHAIN (loop_index))
    1651                 :             :                     {
    1652                 :           3 :                       tree for_stmt = begin_for_stmt (NULL_TREE, NULL_TREE);
    1653                 :           3 :                       tree idx = TREE_PURPOSE (loop_index);
    1654                 :           3 :                       tree maxval = TARGET_EXPR_INITIAL (idx);
    1655                 :           3 :                       TARGET_EXPR_INITIAL (idx) = size_zero_node;
    1656                 :           3 :                       add_stmt (idx);
    1657                 :           3 :                       finish_init_stmt (for_stmt);
    1658                 :           3 :                       finish_for_cond (build2 (LE_EXPR, boolean_type_node, idx,
    1659                 :             :                                                maxval), for_stmt, false, 0,
    1660                 :             :                                                false);
    1661                 :           3 :                       finish_for_expr (cp_build_unary_op (PREINCREMENT_EXPR,
    1662                 :           3 :                                                           TARGET_EXPR_SLOT (idx),
    1663                 :             :                                                           false, complain),
    1664                 :             :                                                           for_stmt);
    1665                 :             :                       /* Store in TREE_VALUE the for_stmt tree, so that we can
    1666                 :             :                          later on call finish_for_stmt on it (in the reverse
    1667                 :             :                          order).  */
    1668                 :           3 :                       TREE_VALUE (loop_index) = for_stmt;
    1669                 :             :                     }
    1670                 :           3 :                   loop_indexes = nreverse (loop_indexes);
    1671                 :             :                 }
    1672                 :       22022 :               if_ = begin_if_stmt ();
    1673                 :             :             }
    1674                 :             :           /* Spaceship is specified to use !=, but for the comparison category
    1675                 :             :              types, != is equivalent to !(==), so let's use == directly.  */
    1676                 :       22028 :           if (code == EQ_EXPR)
    1677                 :             :             {
    1678                 :             :               /* if (x==y); else return false; */
    1679                 :       21867 :               eq = comp;
    1680                 :       21867 :               retval = boolean_false_node;
    1681                 :             :             }
    1682                 :             :           else
    1683                 :             :             {
    1684                 :             :               /* if (auto v = x<=>y, v == 0); else return v; */
    1685                 :         161 :               if (TREE_CODE (comp) == SPACESHIP_EXPR)
    1686                 :           0 :                 TREE_TYPE (comp) = rettype;
    1687                 :             :               else
    1688                 :         161 :                 comp = build_static_cast (input_location, rettype, comp,
    1689                 :             :                                           complain);
    1690                 :         161 :               info.check (comp);
    1691                 :         161 :               if (defining)
    1692                 :             :                 {
    1693                 :         161 :                   tree var = create_temporary_var (rettype);
    1694                 :         161 :                   DECL_NAME (var) = get_identifier ("retval");
    1695                 :         161 :                   pushdecl (var);
    1696                 :         161 :                   cp_finish_decl (var, comp, false, NULL_TREE, flags);
    1697                 :         161 :                   comp = retval = var;
    1698                 :             :                 }
    1699                 :         161 :               eq = build_new_op (info.loc, EQ_EXPR, flags, comp,
    1700                 :             :                                  integer_zero_node, NULL_TREE, NULL_TREE,
    1701                 :             :                                  NULL, complain);
    1702                 :             :             }
    1703                 :       22028 :           tree ceq = contextual_conv_bool (eq, complain);
    1704                 :       22028 :           info.check (ceq);
    1705                 :       22028 :           if (defining)
    1706                 :             :             {
    1707                 :       22022 :               finish_if_stmt_cond (ceq, if_);
    1708                 :       22022 :               finish_then_clause (if_);
    1709                 :       22022 :               begin_else_clause (if_);
    1710                 :       22022 :               finish_return_stmt (retval);
    1711                 :       22022 :               finish_else_clause (if_);
    1712                 :       22022 :               finish_if_stmt (if_);
    1713                 :       22025 :               for (tree loop_index = loop_indexes; loop_index;
    1714                 :           3 :                    loop_index = TREE_CHAIN (loop_index))
    1715                 :           3 :                 finish_for_stmt (TREE_VALUE (loop_index));
    1716                 :             :             }
    1717                 :             :         }
    1718                 :       14711 :       if (defining)
    1719                 :             :         {
    1720                 :       14705 :           tree val;
    1721                 :       14705 :           if (code == EQ_EXPR)
    1722                 :       14570 :             val = boolean_true_node;
    1723                 :             :           else
    1724                 :             :             {
    1725                 :         135 :               tree seql = lookup_comparison_result (cc_strong_ordering,
    1726                 :             :                                                     "equal", complain);
    1727                 :         135 :               val = build_static_cast (input_location, rettype, seql,
    1728                 :             :                                        complain);
    1729                 :             :             }
    1730                 :       14705 :           finish_return_stmt (val);
    1731                 :             :         }
    1732                 :       14840 :     }
    1733                 :          75 :   else if (code == NE_EXPR)
    1734                 :             :     {
    1735                 :          27 :       tree comp = build_new_op (info.loc, EQ_EXPR, flags, lhs, rhs,
    1736                 :             :                                 NULL_TREE, NULL_TREE, NULL, complain);
    1737                 :          27 :       comp = contextual_conv_bool (comp, complain);
    1738                 :          27 :       info.check (comp);
    1739                 :          27 :       if (defining)
    1740                 :             :         {
    1741                 :          24 :           tree neg = build1 (TRUTH_NOT_EXPR, boolean_type_node, comp);
    1742                 :          24 :           finish_return_stmt (neg);
    1743                 :             :         }
    1744                 :             :     }
    1745                 :             :   else
    1746                 :             :     {
    1747                 :          48 :       tree comp = build_new_op (info.loc, SPACESHIP_EXPR, flags, lhs, rhs,
    1748                 :             :                                 NULL_TREE, NULL_TREE, NULL, complain);
    1749                 :          48 :       tree comp2 = build_new_op (info.loc, code, flags, comp, integer_zero_node,
    1750                 :             :                                  NULL_TREE, NULL_TREE, NULL, complain);
    1751                 :          48 :       info.check (comp2);
    1752                 :          48 :       if (defining)
    1753                 :          48 :         finish_return_stmt (comp2);
    1754                 :             :     }
    1755                 :             : 
    1756                 :       14912 :  out:
    1757                 :       14912 :   if (defining)
    1758                 :       14846 :     finish_compound_stmt (compound_stmt);
    1759                 :             :   else
    1760                 :          69 :     --cp_unevaluated_operand;
    1761                 :       14930 : }
    1762                 :             : 
    1763                 :             : /* True iff DECL is an implicitly-declared special member function with no real
    1764                 :             :    source location, so we can use its DECL_SOURCE_LOCATION to remember where we
    1765                 :             :    triggered its synthesis.  */
    1766                 :             : 
    1767                 :             : bool
    1768                 :     2126472 : decl_remember_implicit_trigger_p (tree decl)
    1769                 :             : {
    1770                 :     2126472 :   if (!DECL_ARTIFICIAL (decl))
    1771                 :             :     return false;
    1772                 :     1025360 :   special_function_kind sfk = special_function_p (decl);
    1773                 :             :   /* Inherited constructors have the location of their using-declaration, and
    1774                 :             :      operator== has the location of the corresponding operator<=>.  */
    1775                 :     1025360 :   return (sfk != sfk_inheriting_constructor
    1776                 :     1025360 :           && sfk != sfk_comparison);
    1777                 :             : }
    1778                 :             : 
    1779                 :             : /* Synthesize FNDECL, a non-static member function.   */
    1780                 :             : 
    1781                 :             : void
    1782                 :     1070957 : synthesize_method (tree fndecl)
    1783                 :             : {
    1784                 :     1070957 :   bool need_body = true;
    1785                 :     1070957 :   tree stmt;
    1786                 :     1070957 :   location_t save_input_location = input_location;
    1787                 :     1070957 :   int error_count = errorcount;
    1788                 :     1070957 :   int warning_count = warningcount + werrorcount;
    1789                 :     1070957 :   special_function_kind sfk = special_function_p (fndecl);
    1790                 :     1070957 :   auto_diagnostic_group d;
    1791                 :             : 
    1792                 :             :   /* Reset the source location, we might have been previously
    1793                 :             :      deferred, and thus have saved where we were first needed.  */
    1794                 :     1070957 :   if (decl_remember_implicit_trigger_p (fndecl))
    1795                 :      955346 :     DECL_SOURCE_LOCATION (fndecl)
    1796                 :      477673 :       = DECL_SOURCE_LOCATION (TYPE_NAME (DECL_CONTEXT (fndecl)));
    1797                 :             : 
    1798                 :             :   /* If we've been asked to synthesize a clone, just synthesize the
    1799                 :             :      cloned function instead.  Doing so will automatically fill in the
    1800                 :             :      body for the clone.  */
    1801                 :     1070957 :   if (DECL_CLONED_FUNCTION_P (fndecl))
    1802                 :     1014808 :     fndecl = DECL_CLONED_FUNCTION (fndecl);
    1803                 :             : 
    1804                 :             :   /* We may be in the middle of deferred access check.  Disable
    1805                 :             :      it now.  */
    1806                 :     1070957 :   push_deferring_access_checks (dk_no_deferred);
    1807                 :             : 
    1808                 :     1070957 :   bool push_to_top = maybe_push_to_top_level (fndecl);
    1809                 :             : 
    1810                 :     1070957 :   input_location = DECL_SOURCE_LOCATION (fndecl);
    1811                 :             : 
    1812                 :     1070957 :   start_preparsed_function (fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
    1813                 :     1070957 :   stmt = begin_function_body ();
    1814                 :             : 
    1815                 :     1070957 :   if (DECL_ASSIGNMENT_OPERATOR_P (fndecl)
    1816                 :     1070957 :       && DECL_OVERLOADED_OPERATOR_IS (fndecl, NOP_EXPR))
    1817                 :             :     {
    1818                 :       40851 :       do_build_copy_assign (fndecl);
    1819                 :       40851 :       need_body = false;
    1820                 :             :     }
    1821                 :     2060212 :   else if (DECL_CONSTRUCTOR_P (fndecl))
    1822                 :             :     {
    1823                 :      598590 :       tree arg_chain = FUNCTION_FIRST_USER_PARMTYPE (fndecl);
    1824                 :      598590 :       if (arg_chain != void_list_node)
    1825                 :      216955 :         do_build_copy_constructor (fndecl);
    1826                 :             :       else
    1827                 :      381635 :         finish_mem_initializers (NULL_TREE);
    1828                 :             :     }
    1829                 :      431516 :   else if (sfk == sfk_comparison)
    1830                 :             :     {
    1831                 :             :       /* Pass tf_none so the function is just deleted if there's a problem.  */
    1832                 :       14849 :       build_comparison_op (fndecl, true, tf_none);
    1833                 :       14849 :       need_body = false;
    1834                 :             :     }
    1835                 :             : 
    1836                 :             :   /* If we haven't yet generated the body of the function, just
    1837                 :             :      generate an empty compound statement.  */
    1838                 :      654290 :   if (need_body)
    1839                 :             :     {
    1840                 :     1015257 :       tree compound_stmt;
    1841                 :     1015257 :       compound_stmt = begin_compound_stmt (BCS_FN_BODY);
    1842                 :     1015257 :       finish_compound_stmt (compound_stmt);
    1843                 :             :     }
    1844                 :             : 
    1845                 :     1070957 :   finish_function_body (stmt);
    1846                 :     1070957 :   finish_function (/*inline_p=*/false);
    1847                 :             : 
    1848                 :     1070957 :   if (!DECL_DELETED_FN (fndecl))
    1849                 :     1070882 :     expand_or_defer_fn (fndecl);
    1850                 :             : 
    1851                 :     1070957 :   input_location = save_input_location;
    1852                 :             : 
    1853                 :     1070957 :   maybe_pop_from_top_level (push_to_top);
    1854                 :             : 
    1855                 :     1070957 :   pop_deferring_access_checks ();
    1856                 :             : 
    1857                 :     1070957 :   if (error_count != errorcount || warning_count != warningcount + werrorcount)
    1858                 :          35 :     if (DECL_ARTIFICIAL (fndecl))
    1859                 :          28 :       inform (input_location, "synthesized method %qD first required here",
    1860                 :             :               fndecl);
    1861                 :     1070957 : }
    1862                 :             : 
    1863                 :             : /* Like synthesize_method, but don't actually synthesize defaulted comparison
    1864                 :             :    methods if their class is still incomplete.  Just deduce the return
    1865                 :             :    type in that case.  */
    1866                 :             : 
    1867                 :             : void
    1868                 :        7488 : maybe_synthesize_method (tree fndecl)
    1869                 :             : {
    1870                 :        7488 :   if (special_function_p (fndecl) == sfk_comparison)
    1871                 :             :     {
    1872                 :        7488 :       tree lhs = DECL_ARGUMENTS (fndecl);
    1873                 :        7488 :       if (is_this_parameter (lhs))
    1874                 :         256 :         lhs = cp_build_fold_indirect_ref (lhs);
    1875                 :             :       else
    1876                 :        7232 :         lhs = convert_from_reference (lhs);
    1877                 :        7488 :       tree ctype = TYPE_MAIN_VARIANT (TREE_TYPE (lhs));
    1878                 :        7488 :       if (!COMPLETE_TYPE_P (ctype))
    1879                 :             :         {
    1880                 :           9 :           push_deferring_access_checks (dk_no_deferred);
    1881                 :           9 :           build_comparison_op (fndecl, false, tf_none);
    1882                 :           9 :           pop_deferring_access_checks ();
    1883                 :           9 :           return;
    1884                 :             :         }
    1885                 :             :     }
    1886                 :        7479 :   return synthesize_method (fndecl);
    1887                 :             : }
    1888                 :             : 
    1889                 :             : /* Build a reference to type TYPE with cv-quals QUALS, which is an
    1890                 :             :    rvalue if RVALUE is true.  */
    1891                 :             : 
    1892                 :             : static tree
    1893                 :     6518729 : build_stub_type (tree type, int quals, bool rvalue)
    1894                 :             : {
    1895                 :     6518729 :   tree argtype = cp_build_qualified_type (type, quals);
    1896                 :     6518729 :   return cp_build_reference_type (argtype, rvalue);
    1897                 :             : }
    1898                 :             : 
    1899                 :             : /* Build a dummy glvalue from dereferencing a dummy reference of type
    1900                 :             :    REFTYPE.  */
    1901                 :             : 
    1902                 :             : tree
    1903                 :    33890644 : build_stub_object (tree reftype)
    1904                 :             : {
    1905                 :    33890644 :   if (!TYPE_REF_P (reftype))
    1906                 :     2044655 :     reftype = cp_build_reference_type (reftype, /*rval*/true);
    1907                 :    33890644 :   tree stub = build1 (CONVERT_EXPR, reftype, integer_one_node);
    1908                 :    33890644 :   return convert_from_reference (stub);
    1909                 :             : }
    1910                 :             : 
    1911                 :             : /* Build a std::declval<TYPE>() expression and return it.  */
    1912                 :             : 
    1913                 :             : tree
    1914                 :     2647627 : build_trait_object (tree type)
    1915                 :             : {
    1916                 :             :   /* TYPE can't be a function with cv-/ref-qualifiers: std::declval is
    1917                 :             :      defined as
    1918                 :             : 
    1919                 :             :        template<class T>
    1920                 :             :        typename std::add_rvalue_reference<T>::type declval() noexcept;
    1921                 :             : 
    1922                 :             :      and std::add_rvalue_reference yields T when T is a function with
    1923                 :             :      cv- or ref-qualifiers, making the definition ill-formed.  */
    1924                 :     2647627 :   if (FUNC_OR_METHOD_TYPE_P (type)
    1925                 :     2647627 :       && (type_memfn_quals (type) != TYPE_UNQUALIFIED
    1926                 :         206 :           || type_memfn_rqual (type) != REF_QUAL_NONE))
    1927                 :          14 :     return error_mark_node;
    1928                 :             : 
    1929                 :     2647613 :   return build_stub_object (type);
    1930                 :             : }
    1931                 :             : 
    1932                 :             : /* [func.require] Build an expression of INVOKE(FN_TYPE, ARG_TYPES...).  If the
    1933                 :             :    given is not invocable, returns error_mark_node.  */
    1934                 :             : 
    1935                 :             : tree
    1936                 :        6656 : build_invoke (tree fn_type, const_tree arg_types, tsubst_flags_t complain)
    1937                 :             : {
    1938                 :        6656 :   if (error_operand_p (fn_type) || error_operand_p (arg_types))
    1939                 :           0 :     return error_mark_node;
    1940                 :             : 
    1941                 :        6656 :   gcc_assert (TYPE_P (fn_type));
    1942                 :        6656 :   gcc_assert (TREE_CODE (arg_types) == TREE_VEC);
    1943                 :             : 
    1944                 :             :   /* Access check is required to determine if the given is invocable.  */
    1945                 :        6656 :   deferring_access_check_sentinel acs (dk_no_deferred);
    1946                 :             : 
    1947                 :             :   /* INVOKE is an unevaluated context.  */
    1948                 :        6656 :   cp_unevaluated cp_uneval_guard;
    1949                 :             : 
    1950                 :        6656 :   bool is_ptrdatamem;
    1951                 :        6656 :   bool is_ptrmemfunc;
    1952                 :        6656 :   if (TREE_CODE (fn_type) == REFERENCE_TYPE)
    1953                 :             :     {
    1954                 :        4841 :       tree non_ref_fn_type = TREE_TYPE (fn_type);
    1955                 :        4841 :       is_ptrdatamem = TYPE_PTRDATAMEM_P (non_ref_fn_type);
    1956                 :        4841 :       is_ptrmemfunc = TYPE_PTRMEMFUNC_P (non_ref_fn_type);
    1957                 :             : 
    1958                 :             :       /* Dereference fn_type if it is a pointer to member.  */
    1959                 :        4841 :       if (is_ptrdatamem || is_ptrmemfunc)
    1960                 :         226 :         fn_type = non_ref_fn_type;
    1961                 :             :     }
    1962                 :             :   else
    1963                 :             :     {
    1964                 :        1815 :       is_ptrdatamem = TYPE_PTRDATAMEM_P (fn_type);
    1965                 :        1815 :       is_ptrmemfunc = TYPE_PTRMEMFUNC_P (fn_type);
    1966                 :             :     }
    1967                 :             : 
    1968                 :        7128 :   if (is_ptrdatamem && TREE_VEC_LENGTH (arg_types) != 1)
    1969                 :             :     {
    1970                 :          39 :       if (complain & tf_error)
    1971                 :           0 :         error ("pointer to data member type %qT can only be invoked with "
    1972                 :             :                "one argument", fn_type);
    1973                 :          39 :       return error_mark_node;
    1974                 :             :     }
    1975                 :        6886 :   if (is_ptrmemfunc && TREE_VEC_LENGTH (arg_types) == 0)
    1976                 :             :     {
    1977                 :          21 :       if (complain & tf_error)
    1978                 :           0 :         error ("pointer to member function type %qT must be invoked with "
    1979                 :             :                "at least one argument", fn_type);
    1980                 :          21 :       return error_mark_node;
    1981                 :             :     }
    1982                 :             : 
    1983                 :             :   /* Construct an expression of a pointer to member.  */
    1984                 :        6596 :   tree ptrmem_expr;
    1985                 :        6596 :   if (is_ptrdatamem || is_ptrmemfunc)
    1986                 :             :     {
    1987                 :         681 :       tree datum_type = TREE_VEC_ELT (arg_types, 0);
    1988                 :         681 :       tree non_ref_datum_type = datum_type;
    1989                 :         681 :       if (TYPE_REF_P (datum_type))
    1990                 :         383 :         non_ref_datum_type = TREE_TYPE (datum_type);
    1991                 :             : 
    1992                 :             :       /* datum must be a class type or a pointer to a class type.  */
    1993                 :         460 :       if (!CLASS_TYPE_P (non_ref_datum_type)
    1994                 :         681 :           && !(POINTER_TYPE_P (non_ref_datum_type)
    1995                 :         145 :                && CLASS_TYPE_P (TREE_TYPE (non_ref_datum_type))))
    1996                 :             :         {
    1997                 :          82 :           if (complain & tf_error)
    1998                 :           0 :             error ("first argument type %qT of a pointer to member must be a "
    1999                 :             :                    "class type or a pointer to a class type", datum_type);
    2000                 :          82 :           return error_mark_node;
    2001                 :             :         }
    2002                 :             : 
    2003                 :             :       /* 1.1 & 1.4.  */
    2004                 :         599 :       tree ptrmem_class_type = TYPE_PTRMEM_CLASS_TYPE (fn_type);
    2005                 :         599 :       const bool ptrmem_is_same_or_base_of_datum =
    2006                 :         599 :         (same_type_ignoring_top_level_qualifiers_p (ptrmem_class_type,
    2007                 :             :                                                     non_ref_datum_type)
    2008                 :         599 :          || (NON_UNION_CLASS_TYPE_P (ptrmem_class_type)
    2009                 :         202 :              && NON_UNION_CLASS_TYPE_P (non_ref_datum_type)
    2010                 :          63 :              && DERIVED_FROM_P (ptrmem_class_type, non_ref_datum_type)));
    2011                 :             : 
    2012                 :         190 :       bool datum_is_refwrap = false;
    2013                 :         190 :       if (!ptrmem_is_same_or_base_of_datum && CLASS_TYPE_P (non_ref_datum_type))
    2014                 :             :         {
    2015                 :          51 :           tree datum_decl = TYPE_NAME (TYPE_MAIN_VARIANT (non_ref_datum_type));
    2016                 :          51 :           if (decl_in_std_namespace_p (datum_decl))
    2017                 :             :             {
    2018                 :           6 :               const_tree name = DECL_NAME (datum_decl);
    2019                 :           6 :               if (name && (id_equal (name, "reference_wrapper")))
    2020                 :             :                 {
    2021                 :             :                   /* 1.2 & 1.5: Retrieve T from std::reference_wrapper<T>,
    2022                 :             :                      i.e., decltype(datum.get()).  */
    2023                 :           8 :                   datum_type =
    2024                 :           8 :                     TREE_VEC_ELT (TYPE_TI_ARGS (non_ref_datum_type), 0);
    2025                 :           4 :                   datum_is_refwrap = true;
    2026                 :             :                 }
    2027                 :             :             }
    2028                 :             :         }
    2029                 :             : 
    2030                 :         599 :       tree datum_expr = build_trait_object (datum_type);
    2031                 :         599 :       if (!ptrmem_is_same_or_base_of_datum && !datum_is_refwrap)
    2032                 :             :         /* 1.3 & 1.6: Try to dereference datum_expr.  */
    2033                 :         186 :         datum_expr = build_x_indirect_ref (UNKNOWN_LOCATION, datum_expr,
    2034                 :             :                                            RO_UNARY_STAR, NULL_TREE, complain);
    2035                 :             : 
    2036                 :         599 :       tree fn_expr = build_trait_object (fn_type);
    2037                 :         599 :       ptrmem_expr = build_m_component_ref (datum_expr, fn_expr, complain);
    2038                 :             : 
    2039                 :         599 :       if (error_operand_p (ptrmem_expr))
    2040                 :          53 :         return error_mark_node;
    2041                 :             : 
    2042                 :         546 :       if (is_ptrdatamem)
    2043                 :             :         return ptrmem_expr;
    2044                 :             :     }
    2045                 :             : 
    2046                 :             :   /* Construct expressions for arguments to INVOKE.  For a pointer to member
    2047                 :             :      function, the first argument, which is the object, is not arguments to
    2048                 :             :      the function.  */
    2049                 :        6086 :   releasing_vec args;
    2050                 :       20585 :   for (int i = is_ptrmemfunc ? 1 : 0; i < TREE_VEC_LENGTH (arg_types); ++i)
    2051                 :             :     {
    2052                 :        8413 :       tree arg_type = TREE_VEC_ELT (arg_types, i);
    2053                 :        8413 :       tree arg = build_trait_object (arg_type);
    2054                 :        8413 :       vec_safe_push (args, arg);
    2055                 :             :     }
    2056                 :             : 
    2057                 :        6086 :   tree invoke_expr;
    2058                 :        6086 :   if (is_ptrmemfunc)
    2059                 :         171 :     invoke_expr = build_offset_ref_call_from_tree (ptrmem_expr, &args,
    2060                 :             :                                                    complain);
    2061                 :             :   else  /* 1.7.  */
    2062                 :        5915 :     invoke_expr = finish_call_expr (build_trait_object (fn_type), &args, false,
    2063                 :             :                                     false, complain);
    2064                 :        6086 :   return invoke_expr;
    2065                 :        6656 : }
    2066                 :             : 
    2067                 :             : /* Determine which function will be called when looking up NAME in TYPE,
    2068                 :             :    called with a single ARGTYPE argument, or no argument if ARGTYPE is
    2069                 :             :    null.  FLAGS and COMPLAIN are as for build_new_method_call.
    2070                 :             : 
    2071                 :             :    Returns a FUNCTION_DECL if all is well.
    2072                 :             :    Returns NULL_TREE if overload resolution failed.
    2073                 :             :    Returns error_mark_node if the chosen function cannot be called.  */
    2074                 :             : 
    2075                 :             : static tree
    2076                 :    21537217 : locate_fn_flags (tree type, tree name, tree argtype, int flags,
    2077                 :             :                  tsubst_flags_t complain)
    2078                 :             : {
    2079                 :    21537217 :   tree ob, fn, fns, binfo, rval;
    2080                 :             : 
    2081                 :    21537217 :   if (TYPE_P (type))
    2082                 :     8471366 :     binfo = TYPE_BINFO (type);
    2083                 :             :   else
    2084                 :             :     {
    2085                 :    13065851 :       binfo = type;
    2086                 :    13065851 :       type = BINFO_TYPE (binfo);
    2087                 :             :     }
    2088                 :             : 
    2089                 :    21537217 :   ob = build_stub_object (cp_build_reference_type (type, false));
    2090                 :    21537217 :   releasing_vec args;
    2091                 :    21537217 :   if (argtype)
    2092                 :             :     {
    2093                 :     7911198 :       if (TREE_CODE (argtype) == TREE_LIST)
    2094                 :             :         {
    2095                 :       94663 :           for (tree elt = argtype; elt && elt != void_list_node;
    2096                 :       55255 :                elt = TREE_CHAIN (elt))
    2097                 :             :             {
    2098                 :       55255 :               tree type = TREE_VALUE (elt);
    2099                 :       55255 :               tree arg = build_stub_object (type);
    2100                 :       55255 :               vec_safe_push (args, arg);
    2101                 :             :             }
    2102                 :             :         }
    2103                 :             :       else
    2104                 :             :         {
    2105                 :     7871790 :           tree arg = build_stub_object (argtype);
    2106                 :     7871790 :           args->quick_push (arg);
    2107                 :             :         }
    2108                 :             :     }
    2109                 :             : 
    2110                 :    21537217 :   fns = lookup_fnfields (binfo, name, 0, complain);
    2111                 :    21537217 :   rval = build_new_method_call (ob, fns, &args, binfo, flags, &fn, complain);
    2112                 :             : 
    2113                 :    21537217 :   if (fn && rval == error_mark_node)
    2114                 :             :     return rval;
    2115                 :             :   else
    2116                 :    20873899 :     return fn;
    2117                 :    21537217 : }
    2118                 :             : 
    2119                 :             : /* Locate the dtor of TYPE.  */
    2120                 :             : 
    2121                 :             : tree
    2122                 :        1900 : get_dtor (tree type, tsubst_flags_t complain)
    2123                 :             : {
    2124                 :        1900 :   tree fn = locate_fn_flags (type, complete_dtor_identifier, NULL_TREE,
    2125                 :             :                              LOOKUP_NORMAL, complain);
    2126                 :        1900 :   if (fn == error_mark_node)
    2127                 :           9 :     return NULL_TREE;
    2128                 :             :   return fn;
    2129                 :             : }
    2130                 :             : 
    2131                 :             : /* Locate the default ctor of TYPE.  */
    2132                 :             : 
    2133                 :             : tree
    2134                 :       20701 : locate_ctor (tree type)
    2135                 :             : {
    2136                 :       20701 :   tree fn;
    2137                 :             : 
    2138                 :       20701 :   push_deferring_access_checks (dk_no_check);
    2139                 :       20701 :   fn = locate_fn_flags (type, complete_ctor_identifier, NULL_TREE,
    2140                 :             :                         LOOKUP_SPECULATIVE, tf_none);
    2141                 :       20701 :   pop_deferring_access_checks ();
    2142                 :       20701 :   if (fn == error_mark_node)
    2143                 :         186 :     return NULL_TREE;
    2144                 :             :   return fn;
    2145                 :             : }
    2146                 :             : 
    2147                 :             : /* Likewise, but give any appropriate errors.  */
    2148                 :             : 
    2149                 :             : tree
    2150                 :        1254 : get_default_ctor (tree type)
    2151                 :             : {
    2152                 :        1254 :   tree fn = locate_fn_flags (type, complete_ctor_identifier, NULL_TREE,
    2153                 :             :                              LOOKUP_NORMAL, tf_warning_or_error);
    2154                 :        1254 :   if (fn == error_mark_node)
    2155                 :           3 :     return NULL_TREE;
    2156                 :             :   return fn;
    2157                 :             : }
    2158                 :             : 
    2159                 :             : /* Locate the copy ctor of TYPE.  */
    2160                 :             : 
    2161                 :             : tree
    2162                 :         541 : get_copy_ctor (tree type, tsubst_flags_t complain)
    2163                 :             : {
    2164                 :         541 :   int quals = (TYPE_HAS_CONST_COPY_CTOR (type)
    2165                 :         541 :                ? TYPE_QUAL_CONST : TYPE_UNQUALIFIED);
    2166                 :         541 :   tree argtype = build_stub_type (type, quals, false);
    2167                 :         541 :   tree fn = locate_fn_flags (type, complete_ctor_identifier, argtype,
    2168                 :             :                              LOOKUP_NORMAL, complain);
    2169                 :         541 :   if (fn == error_mark_node)
    2170                 :           6 :     return NULL_TREE;
    2171                 :             :   return fn;
    2172                 :             : }
    2173                 :             : 
    2174                 :             : /* Locate the copy assignment operator of TYPE.  */
    2175                 :             : 
    2176                 :             : tree
    2177                 :         397 : get_copy_assign (tree type)
    2178                 :             : {
    2179                 :         397 :   int quals = (TYPE_HAS_CONST_COPY_ASSIGN (type)
    2180                 :         397 :                ? TYPE_QUAL_CONST : TYPE_UNQUALIFIED);
    2181                 :         397 :   tree argtype = build_stub_type (type, quals, false);
    2182                 :         397 :   tree fn = locate_fn_flags (type, assign_op_identifier, argtype,
    2183                 :             :                              LOOKUP_NORMAL, tf_warning_or_error);
    2184                 :         397 :   if (fn == error_mark_node)
    2185                 :           3 :     return NULL_TREE;
    2186                 :             :   return fn;
    2187                 :             : }
    2188                 :             : 
    2189                 :             : /* walk_tree helper function for is_trivially_xible.  If *TP is a call,
    2190                 :             :    return it if it calls something other than a trivial special member
    2191                 :             :    function.  */
    2192                 :             : 
    2193                 :             : static tree
    2194                 :       82506 : check_nontriv (tree *tp, int *, void *)
    2195                 :             : {
    2196                 :       82506 :   tree fn = cp_get_callee (*tp);
    2197                 :       82506 :   if (fn == NULL_TREE)
    2198                 :             :     return NULL_TREE;
    2199                 :             : 
    2200                 :        1096 :   if (TREE_CODE (fn) == ADDR_EXPR)
    2201                 :        1093 :     fn = TREE_OPERAND (fn, 0);
    2202                 :             : 
    2203                 :        1096 :   if (TREE_CODE (fn) != FUNCTION_DECL
    2204                 :        1096 :       || !trivial_fn_p (fn))
    2205                 :        1096 :     return fn;
    2206                 :             :   return NULL_TREE;
    2207                 :             : }
    2208                 :             : 
    2209                 :             : /* Return declval<T>() = declval<U>() treated as an unevaluated operand.  */
    2210                 :             : 
    2211                 :             : static tree
    2212                 :      785740 : assignable_expr (tree to, tree from)
    2213                 :             : {
    2214                 :      785740 :   cp_unevaluated cp_uneval_guard;
    2215                 :      785740 :   to = build_trait_object (to);
    2216                 :      785740 :   from = build_trait_object (from);
    2217                 :      785740 :   tree r = cp_build_modify_expr (input_location, to, NOP_EXPR, from, tf_none);
    2218                 :     1571480 :   return r;
    2219                 :      785740 : }
    2220                 :             : 
    2221                 :             : /* The predicate condition for a template specialization
    2222                 :             :    is_constructible<T, Args...> shall be satisfied if and only if the
    2223                 :             :    following variable definition would be well-formed for some invented
    2224                 :             :    variable t: T t(create<Args>()...);
    2225                 :             : 
    2226                 :             :    Return something equivalent in well-formedness and triviality.  */
    2227                 :             : 
    2228                 :             : static tree
    2229                 :     1443689 : constructible_expr (tree to, tree from)
    2230                 :             : {
    2231                 :     1443689 :   tree expr;
    2232                 :     1443689 :   cp_unevaluated cp_uneval_guard;
    2233                 :     1443689 :   const int len = TREE_VEC_LENGTH (from);
    2234                 :     1443689 :   if (CLASS_TYPE_P (to))
    2235                 :             :     {
    2236                 :      793130 :       tree ctype = to;
    2237                 :      793130 :       vec<tree, va_gc> *args = NULL;
    2238                 :      793130 :       if (!TYPE_REF_P (to))
    2239                 :      793130 :         to = cp_build_reference_type (to, /*rval*/false);
    2240                 :      793130 :       tree ob = build_stub_object (to);
    2241                 :      793130 :       if (len == 0)
    2242                 :      340506 :         expr = build_value_init (ctype, tf_none);
    2243                 :             :       else
    2244                 :             :         {
    2245                 :      452624 :           vec_alloc (args, len);
    2246                 :      908650 :           for (tree arg : tree_vec_range (from))
    2247                 :      456026 :             args->quick_push (build_stub_object (arg));
    2248                 :      452624 :           expr = build_special_member_call (ob, complete_ctor_identifier, &args,
    2249                 :             :                                             ctype, LOOKUP_NORMAL, tf_none);
    2250                 :             :         }
    2251                 :      793130 :       if (expr == error_mark_node)
    2252                 :        3485 :         return error_mark_node;
    2253                 :             :       /* The current state of the standard vis-a-vis LWG 2116 is that
    2254                 :             :          is_*constructible involves destruction as well.  */
    2255                 :      789655 :       if (type_build_dtor_call (ctype))
    2256                 :             :         {
    2257                 :      152871 :           tree dtor = build_special_member_call (ob, complete_dtor_identifier,
    2258                 :             :                                                  NULL, ctype, LOOKUP_NORMAL,
    2259                 :             :                                                  tf_none);
    2260                 :      152871 :           if (dtor == error_mark_node)
    2261                 :             :             return error_mark_node;
    2262                 :      152861 :           if (!TYPE_HAS_TRIVIAL_DESTRUCTOR (ctype))
    2263                 :      142876 :             expr = build2 (COMPOUND_EXPR, void_type_node, expr, dtor);
    2264                 :             :         }
    2265                 :             :     }
    2266                 :             :   else
    2267                 :             :     {
    2268                 :      650559 :       if (len == 0)
    2269                 :      121186 :         return build_value_init (strip_array_types (to), tf_none);
    2270                 :      529373 :       if (len > 1)
    2271                 :             :         {
    2272                 :         158 :           if (cxx_dialect < cxx20)
    2273                 :             :             /* Too many initializers.  */
    2274                 :         126 :             return error_mark_node;
    2275                 :             : 
    2276                 :             :           /* In C++20 this is well-formed:
    2277                 :             :                using T = int[2];
    2278                 :             :                T t(1, 2);
    2279                 :             :              which means that std::is_constructible_v<int[2], int, int>
    2280                 :             :              should be true.  */
    2281                 :          32 :           vec<constructor_elt, va_gc> *v;
    2282                 :          32 :           vec_alloc (v, len);
    2283                 :          96 :           for (tree arg : tree_vec_range (from))
    2284                 :             :             {
    2285                 :          64 :               tree stub = build_stub_object (arg);
    2286                 :          64 :               constructor_elt elt = { NULL_TREE, stub };
    2287                 :          64 :               v->quick_push (elt);
    2288                 :             :             }
    2289                 :          32 :           from = build_constructor (init_list_type_node, v);
    2290                 :          32 :           CONSTRUCTOR_IS_DIRECT_INIT (from) = true;
    2291                 :          32 :           CONSTRUCTOR_IS_PAREN_INIT (from) = true;
    2292                 :             :         }
    2293                 :             :       else
    2294                 :      529215 :         from = build_stub_object (TREE_VEC_ELT (from, 0));
    2295                 :      529247 :       expr = perform_direct_initialization_if_possible (to, from,
    2296                 :             :                                                         /*cast*/false,
    2297                 :             :                                                         tf_none);
    2298                 :             :       /* If t(e) didn't work, maybe t{e} will.  */
    2299                 :      529247 :       if (expr == NULL_TREE
    2300                 :      529247 :           && len == 1
    2301                 :        2978 :           && cxx_dialect >= cxx20)
    2302                 :             :         {
    2303                 :        1191 :           from = build_constructor_single (init_list_type_node, NULL_TREE,
    2304                 :             :                                            from);
    2305                 :        1191 :           CONSTRUCTOR_IS_DIRECT_INIT (from) = true;
    2306                 :        1191 :           CONSTRUCTOR_IS_PAREN_INIT (from) = true;
    2307                 :        1191 :           expr = perform_direct_initialization_if_possible (to, from,
    2308                 :             :                                                             /*cast*/false,
    2309                 :             :                                                             tf_none);
    2310                 :             :         }
    2311                 :             :     }
    2312                 :             :   return expr;
    2313                 :     1443689 : }
    2314                 :             : 
    2315                 :             : /* Returns a tree iff TO is assignable (if CODE is MODIFY_EXPR) or
    2316                 :             :    constructible (otherwise) from FROM, which is a single type for
    2317                 :             :    assignment or a list of types for construction.  */
    2318                 :             : 
    2319                 :             : static tree
    2320                 :     2229847 : is_xible_helper (enum tree_code code, tree to, tree from, bool trivial)
    2321                 :             : {
    2322                 :     2229847 :   to = complete_type (to);
    2323                 :     2229847 :   deferring_access_check_sentinel acs (dk_no_deferred);
    2324                 :     2229716 :   if (VOID_TYPE_P (to) || ABSTRACT_CLASS_TYPE_P (to)
    2325                 :     4459523 :       || (from && FUNC_OR_METHOD_TYPE_P (from)
    2326                 :          25 :           && (TYPE_READONLY (from) || FUNCTION_REF_QUALIFIED (from))))
    2327                 :         188 :     return error_mark_node;
    2328                 :     2229659 :   tree expr;
    2329                 :     2229659 :   if (code == MODIFY_EXPR)
    2330                 :      785740 :     expr = assignable_expr (to, from);
    2331                 :        4207 :   else if (trivial && TREE_VEC_LENGTH (from) > 1
    2332                 :     1443933 :            && cxx_dialect < cxx20)
    2333                 :           6 :     return error_mark_node; // only 0- and 1-argument ctors can be trivial
    2334                 :             :                             // before C++20 aggregate paren init
    2335                 :     1443913 :   else if (TREE_CODE (to) == ARRAY_TYPE && !TYPE_DOMAIN (to))
    2336                 :         224 :     return error_mark_node; // can't construct an array of unknown bound
    2337                 :             :   else
    2338                 :     1443689 :     expr = constructible_expr (to, from);
    2339                 :             :   return expr;
    2340                 :             : }
    2341                 :             : 
    2342                 :             : /* Returns true iff TO is trivially assignable (if CODE is MODIFY_EXPR) or
    2343                 :             :    constructible (otherwise) from FROM, which is a single type for
    2344                 :             :    assignment or a list of types for construction.  */
    2345                 :             : 
    2346                 :             : bool
    2347                 :       12446 : is_trivially_xible (enum tree_code code, tree to, tree from)
    2348                 :             : {
    2349                 :       12446 :   tree expr = is_xible_helper (code, to, from, /*trivial*/true);
    2350                 :       12446 :   if (expr == NULL_TREE || expr == error_mark_node)
    2351                 :             :     return false;
    2352                 :       11411 :   tree nt = cp_walk_tree_without_duplicates (&expr, check_nontriv, NULL);
    2353                 :       11411 :   return !nt;
    2354                 :             : }
    2355                 :             : 
    2356                 :             : /* Returns true iff TO is nothrow assignable (if CODE is MODIFY_EXPR) or
    2357                 :             :    constructible (otherwise) from FROM, which is a single type for
    2358                 :             :    assignment or a list of types for construction.  */
    2359                 :             : 
    2360                 :             : bool
    2361                 :      711094 : is_nothrow_xible (enum tree_code code, tree to, tree from)
    2362                 :             : {
    2363                 :      711094 :   ++cp_noexcept_operand;
    2364                 :      711094 :   tree expr = is_xible_helper (code, to, from, /*trivial*/false);
    2365                 :      711094 :   --cp_noexcept_operand;
    2366                 :      711094 :   if (expr == NULL_TREE || expr == error_mark_node)
    2367                 :             :     return false;
    2368                 :      710800 :   return expr_noexcept_p (expr, tf_none);
    2369                 :             : }
    2370                 :             : 
    2371                 :             : /* Returns true iff TO is assignable (if CODE is MODIFY_EXPR) or
    2372                 :             :    constructible (otherwise) from FROM, which is a single type for
    2373                 :             :    assignment or a list of types for construction.  */
    2374                 :             : 
    2375                 :             : bool
    2376                 :     1506307 : is_xible (enum tree_code code, tree to, tree from)
    2377                 :             : {
    2378                 :     1506307 :   tree expr = is_xible_helper (code, to, from, /*trivial*/false);
    2379                 :     1506307 :   if (expr == error_mark_node)
    2380                 :             :     return false;
    2381                 :     1456255 :   return !!expr;
    2382                 :             : }
    2383                 :             : 
    2384                 :             : /* Return true iff conjunction_v<is_reference<T>, is_constructible<T, U>> is
    2385                 :             :    true, and the initialization
    2386                 :             :      T t(VAL<U>); // DIRECT_INIT_P
    2387                 :             :    or
    2388                 :             :      T t = VAL<U>; // !DIRECT_INIT_P
    2389                 :             :    binds t to a temporary object whose lifetime is extended.
    2390                 :             :    VAL<T> is defined in [meta.unary.prop]:
    2391                 :             :    -- If T is a reference or function type, VAL<T> is an expression with the
    2392                 :             :    same type and value category as declval<T>().
    2393                 :             :    -- Otherwise, VAL<T> is a prvalue that initially has type T.   */
    2394                 :             : 
    2395                 :             : bool
    2396                 :       93970 : ref_xes_from_temporary (tree to, tree from, bool direct_init_p)
    2397                 :             : {
    2398                 :             :   /* Check is_reference<T>.  */
    2399                 :       93970 :   if (!TYPE_REF_P (to))
    2400                 :             :     return false;
    2401                 :             :   /* We don't check is_constructible<T, U>: if T isn't constructible
    2402                 :             :      from U, we won't be able to create a conversion.  */
    2403                 :        1861 :   tree val = build_trait_object (from);
    2404                 :        1861 :   if (val == error_mark_node)
    2405                 :             :     return false;
    2406                 :        1861 :   if (!TYPE_REF_P (from) && TREE_CODE (from) != FUNCTION_TYPE)
    2407                 :         390 :     val = CLASS_TYPE_P (from) ? force_rvalue (val, tf_none) : rvalue (val);
    2408                 :        1861 :   return ref_conv_binds_to_temporary (to, val, direct_init_p).is_true ();
    2409                 :             : }
    2410                 :             : 
    2411                 :             : /* Worker for is_{,nothrow_}convertible.  Attempt to perform an implicit
    2412                 :             :    conversion from FROM to TO and return the result.  */
    2413                 :             : 
    2414                 :             : static tree
    2415                 :     1058804 : is_convertible_helper (tree from, tree to)
    2416                 :             : {
    2417                 :     1058804 :   if (VOID_TYPE_P (from) && VOID_TYPE_P (to))
    2418                 :          44 :     return integer_one_node;
    2419                 :     1058760 :   cp_unevaluated u;
    2420                 :     1058760 :   tree expr = build_trait_object (from);
    2421                 :             :   /* std::is_{,nothrow_}convertible test whether the imaginary function
    2422                 :             :      definition
    2423                 :             : 
    2424                 :             :        To test() { return std::declval<From>(); }
    2425                 :             : 
    2426                 :             :      is well-formed.  A function can't return a function.  */
    2427                 :     1058760 :   if (FUNC_OR_METHOD_TYPE_P (to) || expr == error_mark_node)
    2428                 :          83 :     return error_mark_node;
    2429                 :     1058677 :   deferring_access_check_sentinel acs (dk_no_deferred);
    2430                 :     1058677 :   return perform_implicit_conversion (to, expr, tf_none);
    2431                 :     1058760 : }
    2432                 :             : 
    2433                 :             : /* Return true if FROM can be converted to TO using implicit conversions,
    2434                 :             :    or both FROM and TO are possibly cv-qualified void.  NB: This doesn't
    2435                 :             :    implement the "Access checks are performed as if from a context unrelated
    2436                 :             :    to either type" restriction.  */
    2437                 :             : 
    2438                 :             : bool
    2439                 :     1034614 : is_convertible (tree from, tree to)
    2440                 :             : {
    2441                 :     1034614 :   tree expr = is_convertible_helper (from, to);
    2442                 :     1034614 :   if (expr == error_mark_node)
    2443                 :             :     return false;
    2444                 :      863999 :   return !!expr;
    2445                 :             : }
    2446                 :             : 
    2447                 :             : /* Like is_convertible, but the conversion is also noexcept.  */
    2448                 :             : 
    2449                 :             : bool
    2450                 :       24190 : is_nothrow_convertible (tree from, tree to)
    2451                 :             : {
    2452                 :       24190 :   tree expr = is_convertible_helper (from, to);
    2453                 :       24190 :   if (expr == NULL_TREE || expr == error_mark_node)
    2454                 :             :     return false;
    2455                 :       23841 :   return expr_noexcept_p (expr, tf_none);
    2456                 :             : }
    2457                 :             : 
    2458                 :             : /* Categorize various special_function_kinds.  */
    2459                 :             : #define SFK_CTOR_P(sfk) \
    2460                 :             :   ((sfk) >= sfk_constructor && (sfk) <= sfk_move_constructor)
    2461                 :             : #define SFK_DTOR_P(sfk) \
    2462                 :             :   ((sfk) == sfk_destructor || (sfk) == sfk_virtual_destructor)
    2463                 :             : #define SFK_ASSIGN_P(sfk) \
    2464                 :             :   ((sfk) == sfk_copy_assignment || (sfk) == sfk_move_assignment)
    2465                 :             : #define SFK_COPY_P(sfk) \
    2466                 :             :   ((sfk) == sfk_copy_constructor || (sfk) == sfk_copy_assignment)
    2467                 :             : #define SFK_MOVE_P(sfk) \
    2468                 :             :   ((sfk) == sfk_move_constructor || (sfk) == sfk_move_assignment)
    2469                 :             : 
    2470                 :             : /* Subroutine of synthesized_method_walk.  Update SPEC_P, TRIVIAL_P and
    2471                 :             :    DELETED_P or give an error message MSG with argument ARG.  */
    2472                 :             : 
    2473                 :             : static void
    2474                 :    20159363 : process_subob_fn (tree fn, special_function_kind sfk, tree *spec_p,
    2475                 :             :                   bool *trivial_p, bool *deleted_p, bool *constexpr_p,
    2476                 :             :                   bool diag, tree arg, bool dtor_from_ctor = false)
    2477                 :             : {
    2478                 :    20159363 :   if (!fn || fn == error_mark_node)
    2479                 :             :     {
    2480                 :      668570 :       if (deleted_p)
    2481                 :      668549 :         *deleted_p = true;
    2482                 :      668570 :       return;
    2483                 :             :     }
    2484                 :             : 
    2485                 :    19490793 :   if (spec_p)
    2486                 :             :     {
    2487                 :     3309575 :       if (!maybe_instantiate_noexcept (fn))
    2488                 :           3 :         *spec_p = error_mark_node;
    2489                 :             :       else
    2490                 :             :         {
    2491                 :     3309572 :           tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
    2492                 :     3309572 :           *spec_p = merge_exception_specifiers (*spec_p, raises);
    2493                 :             :         }
    2494                 :             :     }
    2495                 :             : 
    2496                 :    19490793 :   if (!trivial_fn_p (fn) && !dtor_from_ctor)
    2497                 :             :     {
    2498                 :     6214587 :       if (trivial_p)
    2499                 :     3698684 :         *trivial_p = false;
    2500                 :     6214587 :       if (TREE_CODE (arg) == FIELD_DECL
    2501                 :     6214587 :           && TREE_CODE (DECL_CONTEXT (arg)) == UNION_TYPE)
    2502                 :             :         {
    2503                 :        1741 :           if (deleted_p)
    2504                 :        1737 :             *deleted_p = true;
    2505                 :        1741 :           if (diag)
    2506                 :          25 :             error ("union member %q+D with non-trivial %qD", arg, fn);
    2507                 :             :         }
    2508                 :             :     }
    2509                 :             : 
    2510                 :    19490793 :   if (constexpr_p && !DECL_DECLARED_CONSTEXPR_P (fn))
    2511                 :             :     {
    2512                 :     4240972 :       *constexpr_p = false;
    2513                 :     4240972 :       if (diag)
    2514                 :             :         {
    2515                 :          10 :           inform (DECL_SOURCE_LOCATION (fn),
    2516                 :          10 :                   SFK_DTOR_P (sfk)
    2517                 :             :                   ? G_("defaulted destructor calls non-%<constexpr%> %qD")
    2518                 :             :                   : G_("defaulted constructor calls non-%<constexpr%> %qD"),
    2519                 :             :                   fn);
    2520                 :          10 :           explain_invalid_constexpr_fn (fn);
    2521                 :             :         }
    2522                 :             :     }
    2523                 :             : }
    2524                 :             : 
    2525                 :             : /* Subroutine of synthesized_method_walk to allow recursion into anonymous
    2526                 :             :    aggregates.  If DTOR_FROM_CTOR is true, we're walking subobject destructors
    2527                 :             :    called from a synthesized constructor, in which case we don't consider
    2528                 :             :    the triviality of the subobject destructor.  */
    2529                 :             : 
    2530                 :             : static void
    2531                 :    37413753 : walk_field_subobs (tree fields, special_function_kind sfk, tree fnname,
    2532                 :             :                    int quals, tree *spec_p, bool *trivial_p,
    2533                 :             :                    bool *deleted_p, bool *constexpr_p,
    2534                 :             :                    bool diag, int flags, tsubst_flags_t complain,
    2535                 :             :                    bool dtor_from_ctor)
    2536                 :             : {
    2537                 :    37413753 :   if (!fields)
    2538                 :             :     return;
    2539                 :             : 
    2540                 :    37413749 :   tree ctx = DECL_CONTEXT (fields);
    2541                 :             : 
    2542                 :             :   /* CWG2084: A defaulted default ctor for a union with a DMI only initializes
    2543                 :             :      that member, so don't check other members.  */
    2544                 :    37413749 :   enum { unknown, no, yes }
    2545                 :    37413749 :   only_dmi_mem = (sfk == sfk_constructor && TREE_CODE (ctx) == UNION_TYPE
    2546                 :    37413749 :                   ? unknown : no);
    2547                 :             : 
    2548                 :    37462511 :  again:
    2549                 :   732183252 :   for (tree field = fields; field; field = DECL_CHAIN (field))
    2550                 :             :     {
    2551                 :   694865507 :       tree mem_type, argtype, rval;
    2552                 :             : 
    2553                 :  1360801575 :       if (TREE_CODE (field) != FIELD_DECL
    2554                 :    36351715 :           || DECL_ARTIFICIAL (field)
    2555                 :   723804407 :           || DECL_UNNAMED_BIT_FIELD (field))
    2556                 :   665936068 :         continue;
    2557                 :             : 
    2558                 :             :       /* Variant members only affect deletedness.  In particular, they don't
    2559                 :             :          affect the exception-specification of a user-provided destructor,
    2560                 :             :          which we're figuring out via get_defaulted_eh_spec.  So if we aren't
    2561                 :             :          asking if this is deleted, don't even look up the function; we don't
    2562                 :             :          want an error about a deleted function we aren't actually calling.  */
    2563                 :    28929439 :       if (sfk == sfk_destructor && deleted_p == NULL
    2564                 :     2276360 :           && TREE_CODE (ctx) == UNION_TYPE)
    2565                 :             :         break;
    2566                 :             : 
    2567                 :    28784673 :       if (only_dmi_mem != no)
    2568                 :             :         {
    2569                 :      128339 :           if (DECL_INITIAL (field))
    2570                 :             :             only_dmi_mem = yes;
    2571                 :             :           else
    2572                 :             :             /* Don't check this until we know there's no DMI.  */
    2573                 :      128180 :             continue;
    2574                 :             :         }
    2575                 :             : 
    2576                 :    28656493 :       mem_type = strip_array_types (TREE_TYPE (field));
    2577                 :    28656493 :       if (SFK_ASSIGN_P (sfk))
    2578                 :             :         {
    2579                 :     2669992 :           bool bad = true;
    2580                 :     2669992 :           if (CP_TYPE_CONST_P (mem_type) && !CLASS_TYPE_P (mem_type))
    2581                 :             :             {
    2582                 :          92 :               if (diag)
    2583                 :           7 :                 error ("non-static const member %q#D, cannot use default "
    2584                 :             :                        "assignment operator", field);
    2585                 :             :             }
    2586                 :     2669900 :           else if (TYPE_REF_P (mem_type))
    2587                 :             :             {
    2588                 :        1144 :               if (diag)
    2589                 :           2 :                 error ("non-static reference member %q#D, cannot use "
    2590                 :             :                        "default assignment operator", field);
    2591                 :             :             }
    2592                 :             :           else
    2593                 :             :             bad = false;
    2594                 :             : 
    2595                 :     2669992 :           if (bad && deleted_p)
    2596                 :        1236 :             *deleted_p = true;
    2597                 :             :         }
    2598                 :    25986501 :       else if (sfk == sfk_constructor || sfk == sfk_inheriting_constructor)
    2599                 :             :         {
    2600                 :     2145840 :           bool bad;
    2601                 :             : 
    2602                 :     2145840 :           if (DECL_INITIAL (field))
    2603                 :             :             {
    2604                 :      512274 :               if (diag && DECL_INITIAL (field) == error_mark_node)
    2605                 :           0 :                 inform (DECL_SOURCE_LOCATION (field),
    2606                 :             :                         "initializer for %q#D is invalid", field);
    2607                 :      512274 :               if (trivial_p)
    2608                 :      404605 :                 *trivial_p = false;
    2609                 :             :               /* Core 1351: If the field has an NSDMI that could throw, the
    2610                 :             :                  default constructor is noexcept(false).  */
    2611                 :      512274 :               if (spec_p)
    2612                 :             :                 {
    2613                 :      111971 :                   tree nsdmi = get_nsdmi (field, /*ctor*/false, complain);
    2614                 :      111971 :                   if (nsdmi == error_mark_node)
    2615                 :         121 :                     *spec_p = error_mark_node;
    2616                 :      111850 :                   else if (*spec_p != error_mark_node
    2617                 :      111850 :                            && !expr_noexcept_p (nsdmi, tf_none))
    2618                 :         456 :                     *spec_p = noexcept_false_spec;
    2619                 :             :                 }
    2620                 :             :               /* Don't do the normal processing.  */
    2621                 :      512274 :               continue;
    2622                 :      512274 :             }
    2623                 :             : 
    2624                 :     1633566 :           bad = false;
    2625                 :     1633566 :           if (CP_TYPE_CONST_P (mem_type)
    2626                 :     1633566 :               && default_init_uninitialized_part (mem_type))
    2627                 :             :             {
    2628                 :         263 :               if (diag)
    2629                 :             :                 {
    2630                 :          53 :                   error ("uninitialized const member in %q#T",
    2631                 :             :                          current_class_type);
    2632                 :          53 :                   inform (DECL_SOURCE_LOCATION (field),
    2633                 :             :                           "%q#D should be initialized", field);
    2634                 :             :                 }
    2635                 :             :               bad = true;
    2636                 :             :             }
    2637                 :     1633303 :           else if (TYPE_REF_P (mem_type))
    2638                 :             :             {
    2639                 :        9817 :               if (diag)
    2640                 :             :                 {
    2641                 :          48 :                   error ("uninitialized reference member in %q#T",
    2642                 :             :                          current_class_type);
    2643                 :          48 :                   inform (DECL_SOURCE_LOCATION (field),
    2644                 :             :                           "%q#D should be initialized", field);
    2645                 :             :                 }
    2646                 :             :               bad = true;
    2647                 :             :             }
    2648                 :             : 
    2649                 :     1633566 :           if (bad && deleted_p)
    2650                 :       10080 :             *deleted_p = true;
    2651                 :             : 
    2652                 :             :           /* Before C++20, for an implicitly-defined default constructor to
    2653                 :             :              be constexpr, every member must have a user-provided default
    2654                 :             :              constructor or an explicit initializer.  */
    2655                 :     1633566 :           if (constexpr_p
    2656                 :     1449880 :               && cxx_dialect < cxx20
    2657                 :      952287 :               && !CLASS_TYPE_P (mem_type)
    2658                 :     2318778 :               && TREE_CODE (ctx) != UNION_TYPE)
    2659                 :             :             {
    2660                 :      596720 :               *constexpr_p = false;
    2661                 :      596720 :               if (diag)
    2662                 :           2 :                 inform (DECL_SOURCE_LOCATION (field),
    2663                 :             :                         "defaulted default constructor does not "
    2664                 :             :                         "initialize %q#D", field);
    2665                 :             :             }
    2666                 :             :         }
    2667                 :    23840661 :       else if (sfk == sfk_copy_constructor)
    2668                 :             :         {
    2669                 :             :           /* 12.8p11b5 */
    2670                 :     3959433 :           if (TYPE_REF_P (mem_type)
    2671                 :     3959433 :               && TYPE_REF_IS_RVALUE (mem_type))
    2672                 :             :             {
    2673                 :         260 :               if (diag)
    2674                 :           3 :                 error ("copying non-static data member %q#D of rvalue "
    2675                 :             :                        "reference type", field);
    2676                 :         260 :               if (deleted_p)
    2677                 :         260 :                 *deleted_p = true;
    2678                 :             :             }
    2679                 :             :         }
    2680                 :             : 
    2681                 :    28144219 :       if (!CLASS_TYPE_P (mem_type))
    2682                 :    20878360 :         continue;
    2683                 :             : 
    2684                 :     7265859 :       if (ANON_AGGR_TYPE_P (mem_type))
    2685                 :             :         {
    2686                 :      172347 :           walk_field_subobs (TYPE_FIELDS (mem_type), sfk, fnname, quals,
    2687                 :             :                              spec_p, trivial_p, deleted_p, constexpr_p,
    2688                 :             :                              diag, flags, complain, dtor_from_ctor);
    2689                 :      172347 :           continue;
    2690                 :             :         }
    2691                 :             : 
    2692                 :     7093512 :       if (SFK_COPY_P (sfk) || SFK_MOVE_P (sfk))
    2693                 :             :         {
    2694                 :     2448024 :           int mem_quals = cp_type_quals (mem_type) | quals;
    2695                 :     2448024 :           if (DECL_MUTABLE_P (field))
    2696                 :         224 :             mem_quals &= ~TYPE_QUAL_CONST;
    2697                 :     2448024 :           argtype = build_stub_type (mem_type, mem_quals, SFK_MOVE_P (sfk));
    2698                 :     2448024 :         }
    2699                 :             :       else
    2700                 :             :         argtype = NULL_TREE;
    2701                 :             : 
    2702                 :     7093512 :       rval = locate_fn_flags (mem_type, fnname, argtype, flags, complain);
    2703                 :             : 
    2704                 :     7093512 :       process_subob_fn (rval, sfk, spec_p, trivial_p, deleted_p,
    2705                 :             :                         constexpr_p, diag, field, dtor_from_ctor);
    2706                 :             :     }
    2707                 :             : 
    2708                 :             :   /* We didn't find a DMI in this union, now check all the members.  */
    2709                 :    37462511 :   if (only_dmi_mem == unknown)
    2710                 :             :     {
    2711                 :       48762 :       only_dmi_mem = no;
    2712                 :       48762 :       goto again;
    2713                 :             :     }
    2714                 :             : }
    2715                 :             : 
    2716                 :             : /* Base walker helper for synthesized_method_walk.  Inspect a direct
    2717                 :             :    or virtual base.  BINFO is the parent type's binfo.  BASE_BINFO is
    2718                 :             :    the base binfo of interests.  All other parms are as for
    2719                 :             :    synthesized_method_walk, or its local vars.  */
    2720                 :             : 
    2721                 :             : static tree
    2722                 :     8944068 : synthesized_method_base_walk (tree binfo, tree base_binfo,
    2723                 :             :                               special_function_kind sfk, tree fnname, int quals,
    2724                 :             :                               tree *inheriting_ctor, tree inherited_parms,
    2725                 :             :                               int flags, bool diag,
    2726                 :             :                               tree *spec_p, bool *trivial_p,
    2727                 :             :                               bool *deleted_p, bool *constexpr_p)
    2728                 :             : {
    2729                 :     8944068 :   bool inherited_binfo = false;
    2730                 :     8944068 :   tree argtype = NULL_TREE;
    2731                 :     8944068 :   deferring_kind defer = dk_no_deferred;
    2732                 :             : 
    2733                 :     8944068 :   if (SFK_COPY_P (sfk) || SFK_MOVE_P (sfk))
    2734                 :     4069767 :     argtype = build_stub_type (BINFO_TYPE (base_binfo), quals, SFK_MOVE_P (sfk));
    2735                 :     4874301 :   else if (inheriting_ctor
    2736                 :     4874301 :            && (inherited_binfo
    2737                 :     4874301 :                = binfo_inherited_from (binfo, base_binfo, *inheriting_ctor)))
    2738                 :             :     {
    2739                 :       39435 :       argtype = inherited_parms;
    2740                 :             :       /* Don't check access on the inherited constructor.  */
    2741                 :       39435 :       if (flag_new_inheriting_ctors)
    2742                 :       39426 :         defer = dk_deferred;
    2743                 :             :     }
    2744                 :     4811806 :   else if (cxx_dialect >= cxx14 && sfk == sfk_virtual_destructor
    2745                 :     1555607 :            && BINFO_VIRTUAL_P (base_binfo)
    2746                 :     5014477 :            && ABSTRACT_CLASS_TYPE_P (BINFO_TYPE (binfo)))
    2747                 :             :     /* Don't check access when looking at vbases of abstract class's
    2748                 :             :        virtual destructor.  */
    2749                 :             :     defer = dk_no_check;
    2750                 :             : 
    2751                 :     8944068 :   if (defer != dk_no_deferred)
    2752                 :       39564 :     push_deferring_access_checks (defer);
    2753                 :    17887942 :   tree rval = locate_fn_flags (base_binfo, fnname, argtype, flags,
    2754                 :             :                                diag ? tf_warning_or_error : tf_none);
    2755                 :     8944068 :   if (defer != dk_no_deferred)
    2756                 :       39564 :     pop_deferring_access_checks ();
    2757                 :             : 
    2758                 :             :   /* Replace an inherited template with the appropriate specialization.  */
    2759                 :     8944068 :   if (inherited_binfo && rval
    2760                 :       39435 :       && DECL_P (*inheriting_ctor) && DECL_P (rval)
    2761                 :     8983470 :       && DECL_CONTEXT (*inheriting_ctor) == DECL_CONTEXT (rval))
    2762                 :       39390 :     *inheriting_ctor = DECL_CLONED_FUNCTION (rval);
    2763                 :             : 
    2764                 :    17888136 :   process_subob_fn (rval, sfk, spec_p, trivial_p, deleted_p,
    2765                 :     8944068 :                     constexpr_p, diag, BINFO_TYPE (base_binfo));
    2766                 :     8944068 :   if (SFK_CTOR_P (sfk)
    2767                 :    13074378 :       && (!BINFO_VIRTUAL_P (base_binfo)
    2768                 :       57354 :           || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (BINFO_TYPE (base_binfo))))
    2769                 :             :     {
    2770                 :             :       /* In a constructor we also need to check the subobject
    2771                 :             :          destructors for cleanup of partially constructed objects.  */
    2772                 :     4121783 :       tree dtor = locate_fn_flags (base_binfo, complete_dtor_identifier,
    2773                 :             :                                    NULL_TREE, flags,
    2774                 :             :                                    diag ? tf_warning_or_error : tf_none);
    2775                 :             :       /* Note that we don't pass down trivial_p; the subobject
    2776                 :             :          destructors don't affect triviality of the constructor.  Nor
    2777                 :             :          do they affect constexpr-ness (a constant expression doesn't
    2778                 :             :          throw) or exception-specification (a throw from one of the
    2779                 :             :          dtors would be a double-fault).  */
    2780                 :     8243566 :       process_subob_fn (dtor, sfk, NULL, NULL, deleted_p, NULL, false,
    2781                 :     4121783 :                         BINFO_TYPE (base_binfo), /*dtor_from_ctor*/true);
    2782                 :             :     }
    2783                 :             : 
    2784                 :     8944068 :   return rval;
    2785                 :             : }
    2786                 :             : 
    2787                 :             : /* The caller wants to generate an implicit declaration of SFK for
    2788                 :             :    CTYPE which is const if relevant and CONST_P is set.  If SPEC_P,
    2789                 :             :    TRIVIAL_P, DELETED_P or CONSTEXPR_P are non-null, set their
    2790                 :             :    referent appropriately.  If DIAG is true, we're either being called
    2791                 :             :    from maybe_explain_implicit_delete to give errors, or if
    2792                 :             :    CONSTEXPR_P is non-null, from explain_invalid_constexpr_fn.  */
    2793                 :             : 
    2794                 :             : static void
    2795                 :    24513737 : synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p,
    2796                 :             :                          tree *spec_p, bool *trivial_p, bool *deleted_p,
    2797                 :             :                          bool *constexpr_p, bool diag,
    2798                 :             :                          tree *inheriting_ctor, tree inherited_parms)
    2799                 :             : {
    2800                 :    24513737 :   tree binfo, base_binfo;
    2801                 :    24513737 :   int i;
    2802                 :             : 
    2803                 :             :   /* SFK must be exactly one category.  */
    2804                 :    24513737 :   gcc_checking_assert (SFK_DTOR_P(sfk) + SFK_CTOR_P(sfk)
    2805                 :             :                        + SFK_ASSIGN_P(sfk) == 1);
    2806                 :             : 
    2807                 :    24513737 :   if (spec_p)
    2808                 :     3436621 :     *spec_p = (cxx_dialect >= cxx11 ? noexcept_true_spec : empty_except_spec);
    2809                 :             : 
    2810                 :    24513737 :   if (deleted_p)
    2811                 :             :     {
    2812                 :             :       /* "The closure type associated with a lambda-expression has a deleted
    2813                 :             :          default constructor and a deleted copy assignment operator."
    2814                 :             :          This is diagnosed in maybe_explain_implicit_delete.
    2815                 :             :          In C++20, only lambda-expressions with lambda-captures have those
    2816                 :             :          deleted.  */
    2817                 :    41660026 :       if (LAMBDA_TYPE_P (ctype)
    2818                 :      640956 :           && (sfk == sfk_constructor || sfk == sfk_copy_assignment)
    2819                 :    21271862 :           && (cxx_dialect < cxx20
    2820                 :      110772 :               || LAMBDA_EXPR_CAPTURE_LIST (CLASSTYPE_LAMBDA_EXPR (ctype))
    2821                 :        8804 :               || LAMBDA_EXPR_DEFAULT_CAPTURE_MODE
    2822                 :        8804 :                                 (CLASSTYPE_LAMBDA_EXPR (ctype)) != CPLD_NONE))
    2823                 :             :         {
    2824                 :      121178 :           *deleted_p = true;
    2825                 :      121178 :           return;
    2826                 :             :         }
    2827                 :             : 
    2828                 :    21020816 :       *deleted_p = false;
    2829                 :             :     }
    2830                 :             : 
    2831                 :    24392559 :   bool check_vdtor = false;
    2832                 :    24392559 :   tree fnname;
    2833                 :             : 
    2834                 :    24392559 :   if (SFK_DTOR_P (sfk))
    2835                 :             :     {
    2836                 :     7963862 :       check_vdtor = true;
    2837                 :             :       /* The synthesized method will call base dtors, but check complete
    2838                 :             :          here to avoid having to deal with VTT.  */
    2839                 :     7963862 :       fnname = complete_dtor_identifier;
    2840                 :             :     }
    2841                 :    16428697 :   else if (SFK_ASSIGN_P (sfk))
    2842                 :     3549144 :     fnname = assign_op_identifier;
    2843                 :             :   else
    2844                 :    12879553 :     fnname = complete_ctor_identifier;
    2845                 :             : 
    2846                 :    48745704 :   gcc_assert ((sfk == sfk_inheriting_constructor)
    2847                 :             :               == (inheriting_ctor && *inheriting_ctor != NULL_TREE));
    2848                 :             : 
    2849                 :             :   /* If that user-written default constructor would satisfy the
    2850                 :             :      requirements of a constexpr constructor (7.1.5), the
    2851                 :             :      implicitly-defined default constructor is constexpr.
    2852                 :             : 
    2853                 :             :      C++20:
    2854                 :             :      The implicitly-defined copy/move assignment operator is constexpr if
    2855                 :             :       - X is a literal type, and
    2856                 :             :       - the assignment operator selected to copy/move each direct base class
    2857                 :             :         subobject is a constexpr function, and
    2858                 :             :       - for each non-static data member of X that is of class type (or array
    2859                 :             :         thereof), the assignment operator selected to copy/move that
    2860                 :             :         member is a constexpr function.
    2861                 :             : 
    2862                 :             :       C++23:
    2863                 :             :       The implicitly-defined copy/move assignment operator is constexpr.  */
    2864                 :    24392559 :   if (constexpr_p)
    2865                 :    21020286 :     *constexpr_p = (SFK_CTOR_P (sfk)
    2866                 :     8829972 :                     || (SFK_ASSIGN_P (sfk) && cxx_dialect >= cxx14)
    2867                 :    26443736 :                     || (SFK_DTOR_P (sfk) && cxx_dialect >= cxx20));
    2868                 :             : 
    2869                 :    24392559 :   bool expected_trivial = type_has_trivial_fn (ctype, sfk);
    2870                 :    24392559 :   if (trivial_p)
    2871                 :    21020268 :     *trivial_p = expected_trivial;
    2872                 :             : 
    2873                 :             :   /* The TYPE_HAS_COMPLEX_* flags tell us about constraints from base
    2874                 :             :      class versions and other properties of the type.  But a subobject
    2875                 :             :      class can be trivially copyable and yet have overload resolution
    2876                 :             :      choose a template constructor for initialization, depending on
    2877                 :             :      rvalueness and cv-quals.  And furthermore, a member in a base might
    2878                 :             :      be trivial but deleted or otherwise not callable.  So we can't exit
    2879                 :             :      early in C++0x.  The same considerations apply in C++98/03, but
    2880                 :             :      there the definition of triviality does not consider overload
    2881                 :             :      resolution, so a constructor can be trivial even if it would otherwise
    2882                 :             :      call a non-trivial constructor.  */
    2883                 :    24392559 :   if (expected_trivial
    2884                 :    17847133 :       && (!(SFK_COPY_P (sfk) || SFK_MOVE_P (sfk)) || cxx_dialect < cxx11))
    2885                 :             :     {
    2886                 :     7750938 :       if (constexpr_p && sfk == sfk_constructor)
    2887                 :             :         {
    2888                 :     2537036 :           bool cx = trivial_default_constructor_is_constexpr (ctype);
    2889                 :     2537036 :           *constexpr_p = cx;
    2890                 :     2537036 :           if (diag && !cx && TREE_CODE (ctype) == UNION_TYPE)
    2891                 :             :             /* A trivial constructor doesn't have any NSDMI.  */
    2892                 :           2 :             inform (input_location, "defaulted default constructor does "
    2893                 :             :                     "not initialize any non-static data member");
    2894                 :             :         }
    2895                 :     7750938 :       if (!diag && cxx_dialect < cxx11)
    2896                 :             :         return;
    2897                 :             :     }
    2898                 :             : 
    2899                 :    24375683 :   bool push_to_top = maybe_push_to_top_level (TYPE_NAME (ctype));
    2900                 :    24375683 :   ++cp_unevaluated_operand;
    2901                 :    24375683 :   ++c_inhibit_evaluation_warnings;
    2902                 :    24375683 :   push_deferring_access_checks (dk_no_deferred);
    2903                 :             : 
    2904                 :    24375683 :   tree scope = push_scope (ctype);
    2905                 :             : 
    2906                 :    24375683 :   int flags = LOOKUP_NORMAL | LOOKUP_SPECULATIVE;
    2907                 :    24375683 :   if (sfk != sfk_inheriting_constructor)
    2908                 :    24336269 :     flags |= LOOKUP_DEFAULTED;
    2909                 :             : 
    2910                 :    24375683 :   tsubst_flags_t complain = diag ? tf_warning_or_error : tf_none;
    2911                 :    24375683 :   if (diag && spec_p)
    2912                 :             :     /* We're in get_defaulted_eh_spec; we don't actually want any walking
    2913                 :             :        diagnostics, we just want complain set.  */
    2914                 :     3104211 :     diag = false;
    2915                 :    24375683 :   int quals = const_p ? TYPE_QUAL_CONST : TYPE_UNQUALIFIED;
    2916                 :             : 
    2917                 :    33111917 :   for (binfo = TYPE_BINFO (ctype), i = 0;
    2918                 :    33111917 :        BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
    2919                 :             :     {
    2920                 :     8736234 :       if (!SFK_ASSIGN_P (sfk) && BINFO_VIRTUAL_P (base_binfo))
    2921                 :             :         /* We'll handle virtual bases below.  */
    2922                 :       56427 :         continue;
    2923                 :             : 
    2924                 :     8679807 :       tree fn = synthesized_method_base_walk (binfo, base_binfo,
    2925                 :             :                                               sfk, fnname, quals,
    2926                 :             :                                               inheriting_ctor, inherited_parms,
    2927                 :             :                                               flags, diag, spec_p, trivial_p,
    2928                 :             :                                               deleted_p, constexpr_p);
    2929                 :             : 
    2930                 :         185 :       if (diag && SFK_ASSIGN_P (sfk) && SFK_MOVE_P (sfk)
    2931                 :          70 :           && BINFO_VIRTUAL_P (base_binfo)
    2932                 :          28 :           && fn && TREE_CODE (fn) == FUNCTION_DECL
    2933                 :          28 :           && move_fn_p (fn) && !trivial_fn_p (fn)
    2934                 :     8679822 :           && vbase_has_user_provided_move_assign (BINFO_TYPE (base_binfo)))
    2935                 :          12 :         warning (OPT_Wvirtual_move_assign,
    2936                 :             :                  "defaulted move assignment for %qT calls a non-trivial "
    2937                 :             :                  "move assignment operator for virtual base %qT",
    2938                 :          12 :                  ctype, BINFO_TYPE (base_binfo));
    2939                 :             : 
    2940                 :     8679807 :       if (check_vdtor && type_has_virtual_destructor (BINFO_TYPE (base_binfo)))
    2941                 :             :         {
    2942                 :             :           /* Unlike for base ctor/op=/dtor, for operator delete it's fine
    2943                 :             :              to have a null fn (no class-specific op delete).  */
    2944                 :     1353056 :           fn = locate_fn_flags (ctype, ovl_op_identifier (false, DELETE_EXPR),
    2945                 :             :                                 ptr_type_node, flags, tf_none);
    2946                 :     1353056 :           if (fn && fn == error_mark_node)
    2947                 :             :             {
    2948                 :          21 :               if (complain & tf_error)
    2949                 :           5 :                 locate_fn_flags (ctype, ovl_op_identifier (false, DELETE_EXPR),
    2950                 :             :                                  ptr_type_node, flags, complain);
    2951                 :          21 :               if (deleted_p)
    2952                 :          16 :                 *deleted_p = true;
    2953                 :             :             }
    2954                 :             :           check_vdtor = false;
    2955                 :             :         }
    2956                 :             :     }
    2957                 :             : 
    2958                 :    24375683 :   vec<tree, va_gc> *vbases = CLASSTYPE_VBASECLASSES (ctype);
    2959                 :    24375683 :   if (SFK_ASSIGN_P (sfk))
    2960                 :             :     /* Already examined vbases above.  */;
    2961                 :    20827904 :   else if (vec_safe_is_empty (vbases))
    2962                 :             :     /* No virtual bases to worry about.  */;
    2963                 :      192559 :   else if (ABSTRACT_CLASS_TYPE_P (ctype) && cxx_dialect >= cxx14
    2964                 :             :            /* DR 1658 specifies that vbases of abstract classes are
    2965                 :             :               ignored for both ctors and dtors.  Except DR 2336
    2966                 :             :               overrides that skipping when determing the eh-spec of a
    2967                 :             :               virtual destructor.  */
    2968                 :      192938 :            && sfk != sfk_virtual_destructor)
    2969                 :             :     /* Vbase cdtors are not relevant.  */;
    2970                 :             :   else
    2971                 :             :     {
    2972                 :      192218 :       if (constexpr_p)
    2973                 :       10714 :         *constexpr_p = false;
    2974                 :             : 
    2975                 :      456479 :       FOR_EACH_VEC_ELT (*vbases, i, base_binfo)
    2976                 :      264261 :         synthesized_method_base_walk (binfo, base_binfo, sfk, fnname, quals,
    2977                 :             :                                       inheriting_ctor, inherited_parms,
    2978                 :             :                                       flags, diag,
    2979                 :             :                                       spec_p, trivial_p, deleted_p, constexpr_p);
    2980                 :             :     }
    2981                 :             : 
    2982                 :             :   /* Now handle the non-static data members.  */
    2983                 :    24375683 :   walk_field_subobs (TYPE_FIELDS (ctype), sfk, fnname, quals,
    2984                 :             :                      spec_p, trivial_p, deleted_p, constexpr_p,
    2985                 :             :                      diag, flags, complain, /*dtor_from_ctor*/false);
    2986                 :    24375683 :   if (SFK_CTOR_P (sfk))
    2987                 :    12865723 :     walk_field_subobs (TYPE_FIELDS (ctype), sfk_destructor,
    2988                 :             :                        complete_dtor_identifier, TYPE_UNQUALIFIED,
    2989                 :             :                        NULL, NULL, deleted_p, NULL,
    2990                 :             :                        false, flags, complain, /*dtor_from_ctor*/true);
    2991                 :             : 
    2992                 :    24375683 :   pop_scope (scope);
    2993                 :             : 
    2994                 :    24375683 :   pop_deferring_access_checks ();
    2995                 :    24375683 :   --cp_unevaluated_operand;
    2996                 :    24375683 :   --c_inhibit_evaluation_warnings;
    2997                 :    24375683 :   maybe_pop_from_top_level (push_to_top);
    2998                 :             : }
    2999                 :             : 
    3000                 :             : /* DECL is a defaulted function whose exception specification is now
    3001                 :             :    needed.  Return what it should be.  */
    3002                 :             : 
    3003                 :             : tree
    3004                 :     3371661 : get_defaulted_eh_spec (tree decl, tsubst_flags_t complain)
    3005                 :             : {
    3006                 :             :   /* For DECL_MAYBE_DELETED this should already have been handled by
    3007                 :             :      synthesize_method.  */
    3008                 :     3371661 :   gcc_assert (!DECL_MAYBE_DELETED (decl));
    3009                 :             : 
    3010                 :     3371661 :   if (DECL_CLONED_FUNCTION_P (decl))
    3011                 :           0 :     decl = DECL_CLONED_FUNCTION (decl);
    3012                 :     3371661 :   special_function_kind sfk = special_function_p (decl);
    3013                 :     3371661 :   tree ctype = DECL_CONTEXT (decl);
    3014                 :     3371661 :   tree parms = FUNCTION_FIRST_USER_PARMTYPE (decl);
    3015                 :     3371661 :   tree parm_type = TREE_VALUE (parms);
    3016                 :     3371661 :   bool const_p = CP_TYPE_CONST_P (non_reference (parm_type));
    3017                 :     3371661 :   tree spec = empty_except_spec;
    3018                 :     3371661 :   bool diag = !DECL_DELETED_FN (decl) && (complain & tf_error);
    3019                 :     6743322 :   tree inh = DECL_INHERITED_CTOR (decl);
    3020                 :     3371661 :   if (SFK_DTOR_P (sfk) && DECL_VIRTUAL_P (decl))
    3021                 :             :     /* We have to examine virtual bases even if abstract.  */
    3022                 :             :     sfk = sfk_virtual_destructor;
    3023                 :     3371661 :   bool pushed = false;
    3024                 :     3371661 :   if (CLASSTYPE_TEMPLATE_INSTANTIATION (ctype))
    3025                 :     2136201 :     pushed = push_tinst_level (decl);
    3026                 :     3371661 :   synthesized_method_walk (ctype, sfk, const_p, &spec, NULL, NULL,
    3027                 :             :                            NULL, diag, &inh, parms);
    3028                 :     3371661 :   if (pushed)
    3029                 :     2135939 :     pop_tinst_level ();
    3030                 :     3371661 :   return spec;
    3031                 :             : }
    3032                 :             : 
    3033                 :             : /* DECL is a deleted function.  If it's implicitly deleted, explain why and
    3034                 :             :    return true; else return false.  */
    3035                 :             : 
    3036                 :             : bool
    3037                 :        2275 : maybe_explain_implicit_delete (tree decl)
    3038                 :             : {
    3039                 :             :   /* If decl is a clone, get the primary variant.  */
    3040                 :        2275 :   decl = DECL_ORIGIN (decl);
    3041                 :        2275 :   gcc_assert (DECL_DELETED_FN (decl));
    3042                 :        2275 :   if (DECL_DEFAULTED_FN (decl))
    3043                 :             :     {
    3044                 :             :       /* Not marked GTY; it doesn't need to be GC'd or written to PCH.  */
    3045                 :        1711 :       static hash_set<tree> *explained;
    3046                 :             : 
    3047                 :        1711 :       special_function_kind sfk;
    3048                 :        1711 :       location_t loc;
    3049                 :        1711 :       bool informed;
    3050                 :        1711 :       tree ctype;
    3051                 :             : 
    3052                 :        1711 :       if (!explained)
    3053                 :         222 :         explained = new hash_set<tree>;
    3054                 :        1711 :       if (explained->add (decl))
    3055                 :             :         return true;
    3056                 :             : 
    3057                 :         445 :       sfk = special_function_p (decl);
    3058                 :         445 :       ctype = DECL_CONTEXT (decl);
    3059                 :         445 :       loc = input_location;
    3060                 :         445 :       input_location = DECL_SOURCE_LOCATION (decl);
    3061                 :             : 
    3062                 :         445 :       informed = false;
    3063                 :         859 :       if (LAMBDA_TYPE_P (ctype))
    3064                 :             :         {
    3065                 :          36 :           informed = true;
    3066                 :          36 :           if (sfk == sfk_constructor)
    3067                 :          19 :             inform (DECL_SOURCE_LOCATION (decl),
    3068                 :             :                     "a lambda closure type has a deleted default constructor");
    3069                 :          17 :           else if (sfk == sfk_copy_assignment)
    3070                 :          17 :             inform (DECL_SOURCE_LOCATION (decl),
    3071                 :             :                     "a lambda closure type has a deleted copy assignment operator");
    3072                 :             :           else
    3073                 :             :             informed = false;
    3074                 :             :         }
    3075                 :         409 :       else if (DECL_ARTIFICIAL (decl)
    3076                 :         326 :                && (sfk == sfk_copy_assignment || sfk == sfk_copy_constructor)
    3077                 :         518 :                && classtype_has_move_assign_or_move_ctor_p (ctype, true))
    3078                 :             :         {
    3079                 :          69 :           inform (DECL_SOURCE_LOCATION (decl),
    3080                 :             :                   "%q#D is implicitly declared as deleted because %qT "
    3081                 :             :                   "declares a move constructor or move assignment operator",
    3082                 :             :                   decl, ctype);
    3083                 :          69 :           informed = true;
    3084                 :             :         }
    3085                 :         340 :       else if (sfk == sfk_inheriting_constructor)
    3086                 :             :         {
    3087                 :          18 :           tree binfo = inherited_ctor_binfo (decl);
    3088                 :          18 :           if (TREE_CODE (binfo) != TREE_BINFO)
    3089                 :             :             {
    3090                 :           3 :               inform (DECL_SOURCE_LOCATION (decl),
    3091                 :             :                       "%q#D inherits from multiple base subobjects",
    3092                 :             :                       decl);
    3093                 :           3 :               informed = true;
    3094                 :             :             }
    3095                 :             :         }
    3096                 :         445 :       if (!informed && sfk == sfk_comparison)
    3097                 :             :         {
    3098                 :          63 :           inform (DECL_SOURCE_LOCATION (decl),
    3099                 :             :                   "%q#D is implicitly deleted because the default "
    3100                 :             :                   "definition would be ill-formed:", decl);
    3101                 :          63 :           build_comparison_op (decl, false, tf_warning_or_error);
    3102                 :             :         }
    3103                 :         382 :       else if (!informed)
    3104                 :             :         {
    3105                 :         274 :           tree parms = FUNCTION_FIRST_USER_PARMTYPE (decl);
    3106                 :         274 :           bool const_p = false;
    3107                 :         274 :           if (parms)
    3108                 :             :             {
    3109                 :         271 :               tree parm_type = TREE_VALUE (parms);
    3110                 :         271 :               const_p = CP_TYPE_CONST_P (non_reference (parm_type));
    3111                 :             :             }
    3112                 :         274 :           tree raises = NULL_TREE;
    3113                 :         274 :           bool deleted_p = false;
    3114                 :         274 :           tree scope = push_scope (ctype);
    3115                 :         548 :           tree inh = DECL_INHERITED_CTOR (decl);
    3116                 :             : 
    3117                 :         274 :           synthesized_method_walk (ctype, sfk, const_p,
    3118                 :             :                                    &raises, NULL, &deleted_p, NULL, false,
    3119                 :             :                                    &inh, parms);
    3120                 :         274 :           if (deleted_p)
    3121                 :             :             {
    3122                 :         274 :               inform (DECL_SOURCE_LOCATION (decl),
    3123                 :             :                       "%q#D is implicitly deleted because the default "
    3124                 :             :                       "definition would be ill-formed:", decl);
    3125                 :         274 :               synthesized_method_walk (ctype, sfk, const_p,
    3126                 :             :                                        NULL, NULL, &deleted_p, NULL, true,
    3127                 :             :                                        &inh, parms);
    3128                 :             :             }
    3129                 :           0 :           else if (!comp_except_specs
    3130                 :           0 :                    (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (decl)),
    3131                 :             :                     raises, ce_normal))
    3132                 :           0 :             inform (DECL_SOURCE_LOCATION (decl), "%q#F is implicitly "
    3133                 :             :                     "deleted because its exception-specification does not "
    3134                 :             :                     "match the implicit exception-specification %qX",
    3135                 :             :                     decl, raises);
    3136                 :           0 :           else if (flag_checking)
    3137                 :           0 :             gcc_unreachable ();
    3138                 :             : 
    3139                 :         274 :           pop_scope (scope);
    3140                 :             :         }
    3141                 :             : 
    3142                 :         445 :       input_location = loc;
    3143                 :         445 :       return true;
    3144                 :             :     }
    3145                 :             :   return false;
    3146                 :             : }
    3147                 :             : 
    3148                 :             : /* DECL is a defaulted function which was declared constexpr.  Explain why
    3149                 :             :    it can't be constexpr.  */
    3150                 :             : 
    3151                 :             : void
    3152                 :          27 : explain_implicit_non_constexpr (tree decl)
    3153                 :             : {
    3154                 :          27 :   tree parms = FUNCTION_FIRST_USER_PARMTYPE (decl);
    3155                 :          27 :   bool const_p = CP_TYPE_CONST_P (non_reference (TREE_VALUE (parms)));
    3156                 :          54 :   tree inh = DECL_INHERITED_CTOR (decl);
    3157                 :          27 :   bool dummy;
    3158                 :          27 :   special_function_kind sfk = special_function_p (decl);
    3159                 :          27 :   if (sfk == sfk_comparison)
    3160                 :             :     {
    3161                 :           9 :       DECL_DECLARED_CONSTEXPR_P (decl) = true;
    3162                 :           9 :       build_comparison_op (decl, false, tf_warning_or_error);
    3163                 :           9 :       DECL_DECLARED_CONSTEXPR_P (decl) = false;
    3164                 :             :     }
    3165                 :             :   else
    3166                 :          18 :     synthesized_method_walk (DECL_CLASS_CONTEXT (decl),
    3167                 :             :                              sfk, const_p,
    3168                 :             :                              NULL, NULL, NULL, &dummy, true,
    3169                 :             :                              &inh, parms);
    3170                 :          27 : }
    3171                 :             : 
    3172                 :             : /* DECL is an instantiation of an inheriting constructor template.  Deduce
    3173                 :             :    the correct exception-specification and deletedness for this particular
    3174                 :             :    specialization.  Return true if the deduction succeeds; false otherwise.  */
    3175                 :             : 
    3176                 :             : bool
    3177                 :       39384 : deduce_inheriting_ctor (tree decl)
    3178                 :             : {
    3179                 :       39384 :   decl = DECL_ORIGIN (decl);
    3180                 :       78768 :   gcc_assert (DECL_INHERITED_CTOR (decl));
    3181                 :       39384 :   tree spec;
    3182                 :       39384 :   bool trivial, constexpr_, deleted;
    3183                 :       39384 :   tree inh = DECL_INHERITED_CTOR (decl);
    3184                 :       39384 :   synthesized_method_walk (DECL_CONTEXT (decl), sfk_inheriting_constructor,
    3185                 :             :                            false, &spec, &trivial, &deleted, &constexpr_,
    3186                 :             :                            /*diag*/false,
    3187                 :             :                            &inh,
    3188                 :       39384 :                            FUNCTION_FIRST_USER_PARMTYPE (decl));
    3189                 :       39384 :   if (spec == error_mark_node)
    3190                 :             :     return false;
    3191                 :       39382 :   if (TREE_CODE (inherited_ctor_binfo (decl)) != TREE_BINFO)
    3192                 :             :     /* Inherited the same constructor from different base subobjects.  */
    3193                 :           3 :     deleted = true;
    3194                 :       39382 :   DECL_DELETED_FN (decl) = deleted;
    3195                 :       39382 :   TREE_TYPE (decl) = build_exception_variant (TREE_TYPE (decl), spec);
    3196                 :       39382 :   SET_DECL_INHERITED_CTOR (decl, inh);
    3197                 :             : 
    3198                 :       39382 :   tree clone;
    3199                 :      118146 :   FOR_EACH_CLONE (clone, decl)
    3200                 :             :     {
    3201                 :       78764 :       DECL_DELETED_FN (clone) = deleted;
    3202                 :       78764 :       TREE_TYPE (clone) = build_exception_variant (TREE_TYPE (clone), spec);
    3203                 :       78764 :       SET_DECL_INHERITED_CTOR (clone, inh);
    3204                 :             :     }
    3205                 :             : 
    3206                 :             :   return true;
    3207                 :             : }
    3208                 :             : 
    3209                 :             : /* Implicitly declare the special function indicated by KIND, as a
    3210                 :             :    member of TYPE.  For copy constructors and assignment operators,
    3211                 :             :    CONST_P indicates whether these functions should take a const
    3212                 :             :    reference argument or a non-const reference.
    3213                 :             :    Returns the FUNCTION_DECL for the implicitly declared function.  */
    3214                 :             : 
    3215                 :             : tree
    3216                 :    21339546 : implicitly_declare_fn (special_function_kind kind, tree type,
    3217                 :             :                        bool const_p, tree pattern_fn,
    3218                 :             :                        tree inherited_parms)
    3219                 :             : {
    3220                 :    21339546 :   tree fn;
    3221                 :    21339546 :   tree parameter_types = void_list_node;
    3222                 :    21339546 :   tree return_type;
    3223                 :    21339546 :   tree fn_type;
    3224                 :    21339546 :   tree raises = empty_except_spec;
    3225                 :    21339546 :   tree rhs_parm_type = NULL_TREE;
    3226                 :    21339546 :   tree this_parm;
    3227                 :    21339546 :   tree name;
    3228                 :    21339546 :   HOST_WIDE_INT saved_processing_template_decl;
    3229                 :    21339546 :   bool deleted_p = false;
    3230                 :    21339546 :   bool constexpr_p = false;
    3231                 :    42679092 :   tree inherited_ctor = (kind == sfk_inheriting_constructor
    3232                 :    21339546 :                          ? pattern_fn : NULL_TREE);
    3233                 :             : 
    3234                 :             :   /* Because we create declarations for implicitly declared functions
    3235                 :             :      lazily, we may be creating the declaration for a member of TYPE
    3236                 :             :      while in some completely different context.  However, TYPE will
    3237                 :             :      never be a dependent class (because we never want to do lookups
    3238                 :             :      for implicitly defined functions in a dependent class).  */
    3239                 :    21339546 :   gcc_assert (!dependent_type_p (type));
    3240                 :             : 
    3241                 :             :   /* If the member-specification does not explicitly declare any member or
    3242                 :             :      friend named operator==, an == operator function is declared
    3243                 :             :      implicitly for each three-way comparison operator function defined as
    3244                 :             :      defaulted in the member-specification, with the same access and
    3245                 :             :      function-definition and in the same class scope as the respective
    3246                 :             :      three-way comparison operator function, except that the return type is
    3247                 :             :      replaced with bool and the declarator-id is replaced with
    3248                 :             :      operator==.
    3249                 :             : 
    3250                 :             :      [Note: Such an implicitly-declared == operator for a class X is
    3251                 :             :      defined as defaulted in the definition of X and has the same
    3252                 :             :      parameter-declaration-clause and trailing requires-clause as the
    3253                 :             :      respective three-way comparison operator. It is declared with friend,
    3254                 :             :      virtual, constexpr, or consteval if the three-way comparison operator
    3255                 :             :      function is so declared. If the three-way comparison operator function
    3256                 :             :      has no noexcept-specifier, the implicitly-declared == operator
    3257                 :             :      function has an implicit exception specification (14.5) that may
    3258                 :             :      differ from the implicit exception specification of the three-way
    3259                 :             :      comparison operator function. --end note]  */
    3260                 :    21339546 :   if (kind == sfk_comparison)
    3261                 :             :     {
    3262                 :         185 :       fn = copy_operator_fn (pattern_fn, EQ_EXPR);
    3263                 :         185 :       DECL_ARTIFICIAL (fn) = 1;
    3264                 :         185 :       apply_deduced_return_type (fn, boolean_type_node);
    3265                 :         185 :       return fn;
    3266                 :             :     }
    3267                 :             : 
    3268                 :             :   /* Furthermore, we must set PROCESSING_TEMPLATE_DECL to zero here
    3269                 :             :      because we only create clones for constructors and destructors
    3270                 :             :      when not in a template.  */
    3271                 :    21339361 :   saved_processing_template_decl = processing_template_decl;
    3272                 :    21339361 :   processing_template_decl = 0;
    3273                 :             : 
    3274                 :    21339361 :   type = TYPE_MAIN_VARIANT (type);
    3275                 :             : 
    3276                 :    21339361 :   if (targetm.cxx.cdtor_returns_this ())
    3277                 :             :     {
    3278                 :           0 :       if (kind == sfk_destructor)
    3279                 :             :         /* See comment in check_special_function_return_type.  */
    3280                 :           0 :         return_type = build_pointer_type (void_type_node);
    3281                 :             :       else
    3282                 :           0 :         return_type = build_pointer_type (type);
    3283                 :             :     }
    3284                 :             :   else
    3285                 :    21339361 :     return_type = void_type_node;
    3286                 :             : 
    3287                 :    21339361 :   int this_quals = TYPE_UNQUALIFIED;
    3288                 :    21339361 :   switch (kind)
    3289                 :             :     {
    3290                 :     5412654 :     case sfk_destructor:
    3291                 :             :       /* Destructor.  */
    3292                 :     5412654 :       name = dtor_identifier;
    3293                 :     5412654 :       break;
    3294                 :             : 
    3295                 :     3589477 :     case sfk_constructor:
    3296                 :             :       /* Default constructor.  */
    3297                 :     3589477 :       name = ctor_identifier;
    3298                 :     3589477 :       break;
    3299                 :             : 
    3300                 :    12337230 :     case sfk_copy_constructor:
    3301                 :    12337230 :     case sfk_copy_assignment:
    3302                 :    12337230 :     case sfk_move_constructor:
    3303                 :    12337230 :     case sfk_move_assignment:
    3304                 :    12337230 :     case sfk_inheriting_constructor:
    3305                 :    12337230 :     {
    3306                 :    12337230 :       if (kind == sfk_copy_assignment
    3307                 :    12337230 :           || kind == sfk_move_assignment)
    3308                 :             :         {
    3309                 :     3417497 :           return_type = build_reference_type (type);
    3310                 :     3417497 :           name = assign_op_identifier;
    3311                 :             :         }
    3312                 :             :       else
    3313                 :     8919733 :         name = ctor_identifier;
    3314                 :             : 
    3315                 :    12337230 :       if (kind == sfk_inheriting_constructor)
    3316                 :             :         parameter_types = inherited_parms;
    3317                 :             :       else
    3318                 :             :         {
    3319                 :    12099931 :           if (const_p)
    3320                 :     7192212 :             rhs_parm_type = cp_build_qualified_type (type, TYPE_QUAL_CONST);
    3321                 :             :           else
    3322                 :             :             rhs_parm_type = type;
    3323                 :    12099931 :           bool move_p = (kind == sfk_move_assignment
    3324                 :    12099931 :                          || kind == sfk_move_constructor);
    3325                 :    12099931 :           rhs_parm_type = cp_build_reference_type (rhs_parm_type, move_p);
    3326                 :             : 
    3327                 :    12099931 :           parameter_types = tree_cons (NULL_TREE, rhs_parm_type, parameter_types);
    3328                 :             :         }
    3329                 :             :       break;
    3330                 :             :     }
    3331                 :             : 
    3332                 :           0 :     default:
    3333                 :           0 :       gcc_unreachable ();
    3334                 :             :     }
    3335                 :             : 
    3336                 :    21339361 :   bool trivial_p = false;
    3337                 :             : 
    3338                 :    21339361 :   if (inherited_ctor)
    3339                 :             :     {
    3340                 :             :       /* For an inheriting constructor, just copy these flags from the
    3341                 :             :          inherited constructor until deduce_inheriting_ctor.  */
    3342                 :      237299 :       raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (inherited_ctor));
    3343                 :      237299 :       deleted_p = DECL_DELETED_FN (inherited_ctor);
    3344                 :      237299 :       constexpr_p = DECL_DECLARED_CONSTEXPR_P (inherited_ctor);
    3345                 :             :     }
    3346                 :    21102062 :   else if (cxx_dialect >= cxx11)
    3347                 :             :     {
    3348                 :    21076763 :       raises = noexcept_deferred_spec;
    3349                 :    21076763 :       synthesized_method_walk (type, kind, const_p, NULL, &trivial_p,
    3350                 :             :                                &deleted_p, &constexpr_p, false,
    3351                 :             :                                &inherited_ctor, inherited_parms);
    3352                 :             :     }
    3353                 :             :   else
    3354                 :       25299 :     synthesized_method_walk (type, kind, const_p, &raises, &trivial_p,
    3355                 :             :                              &deleted_p, &constexpr_p, false,
    3356                 :             :                              &inherited_ctor, inherited_parms);
    3357                 :             :   /* Don't bother marking a deleted constructor as constexpr.  */
    3358                 :    21339361 :   if (deleted_p)
    3359                 :      833048 :     constexpr_p = false;
    3360                 :             :   /* A trivial copy/move constructor is also a constexpr constructor,
    3361                 :             :      unless the class has virtual bases (7.1.5p4).  */
    3362                 :    20506313 :   else if (trivial_p
    3363                 :    16848755 :            && cxx_dialect >= cxx11
    3364                 :    16831879 :            && (kind == sfk_copy_constructor
    3365                 :    16831879 :                || kind == sfk_move_constructor)
    3366                 :    27398649 :            && !CLASSTYPE_VBASECLASSES (type))
    3367                 :     6892336 :     gcc_assert (constexpr_p);
    3368                 :             : 
    3369                 :    21339361 :   if (!trivial_p && type_has_trivial_fn (type, kind))
    3370                 :      208719 :     type_set_nontrivial_flag (type, kind);
    3371                 :             : 
    3372                 :             :   /* Create the function.  */
    3373                 :    21339361 :   tree this_type = cp_build_qualified_type (type, this_quals);
    3374                 :    21339361 :   fn_type = build_method_type_directly (this_type, return_type,
    3375                 :             :                                         parameter_types);
    3376                 :             : 
    3377                 :    21339361 :   if (raises)
    3378                 :             :     {
    3379                 :    21246799 :       if (raises != error_mark_node)
    3380                 :    21246796 :         fn_type = build_exception_variant (fn_type, raises);
    3381                 :             :       else
    3382                 :             :         {
    3383                 :             :           /* Can happen, e.g., in C++98 mode for an ill-formed non-static data
    3384                 :             :              member initializer (c++/89914).  Also, in C++98, we might have
    3385                 :             :              failed to deduce RAISES, so try again but complain this time.  */
    3386                 :           3 :           if (cxx_dialect < cxx11)
    3387                 :           3 :             synthesized_method_walk (type, kind, const_p, &raises, nullptr,
    3388                 :             :                                      nullptr, nullptr, /*diag=*/true,
    3389                 :             :                                      &inherited_ctor, inherited_parms);
    3390                 :             :           /* We should have seen an error at this point.  */
    3391                 :           3 :           gcc_assert (seen_error ());
    3392                 :             :         }
    3393                 :             :     }
    3394                 :    21339361 :   fn = build_lang_decl (FUNCTION_DECL, name, fn_type);
    3395                 :    21339361 :   if (kind != sfk_inheriting_constructor)
    3396                 :    21102062 :     DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (TYPE_NAME (type));
    3397                 :             : 
    3398                 :    21339361 :   if (IDENTIFIER_OVL_OP_P (name))
    3399                 :             :     {
    3400                 :     3417497 :       const ovl_op_info_t *op = IDENTIFIER_OVL_OP_INFO (name);
    3401                 :     3417497 :       DECL_OVERLOADED_OPERATOR_CODE_RAW (fn) = op->ovl_op_code;
    3402                 :     3417497 :     }
    3403                 :    17921864 :   else if (IDENTIFIER_CTOR_P (name))
    3404                 :    12509210 :     DECL_CXX_CONSTRUCTOR_P (fn) = true;
    3405                 :     5412654 :   else if (IDENTIFIER_DTOR_P (name))
    3406                 :     5412654 :     DECL_CXX_DESTRUCTOR_P (fn) = true;
    3407                 :             :   else
    3408                 :           0 :     gcc_unreachable ();
    3409                 :             : 
    3410                 :    21339361 :   SET_DECL_ALIGN (fn, MINIMUM_METHOD_BOUNDARY);
    3411                 :             : 
    3412                 :             :   /* Create the explicit arguments.  */
    3413                 :    21339361 :   if (rhs_parm_type)
    3414                 :             :     {
    3415                 :             :       /* Note that this parameter is *not* marked DECL_ARTIFICIAL; we
    3416                 :             :          want its type to be included in the mangled function
    3417                 :             :          name.  */
    3418                 :    12099931 :       tree decl = cp_build_parm_decl (fn, NULL_TREE, rhs_parm_type);
    3419                 :    12099931 :       TREE_READONLY (decl) = 1;
    3420                 :    12099931 :       retrofit_lang_decl (decl);
    3421                 :    12099931 :       DECL_PARM_INDEX (decl) = DECL_PARM_LEVEL (decl) = 1;
    3422                 :    12099931 :       DECL_ARGUMENTS (fn) = decl;
    3423                 :             :     }
    3424                 :     9239430 :   else if (kind == sfk_inheriting_constructor)
    3425                 :             :     {
    3426                 :      237299 :       tree *p = &DECL_ARGUMENTS (fn);
    3427                 :      237299 :       int index = 1;
    3428                 :      479358 :       for (tree parm = inherited_parms; parm && parm != void_list_node;
    3429                 :      242059 :            parm = TREE_CHAIN (parm))
    3430                 :             :         {
    3431                 :      242059 :           *p = cp_build_parm_decl (fn, NULL_TREE, TREE_VALUE (parm));
    3432                 :      242059 :           retrofit_lang_decl (*p);
    3433                 :      242059 :           DECL_PARM_LEVEL (*p) = 1;
    3434                 :      242059 :           DECL_PARM_INDEX (*p) = index++;
    3435                 :      242059 :           p = &DECL_CHAIN (*p);
    3436                 :             :         }
    3437                 :      237299 :       SET_DECL_INHERITED_CTOR (fn, inherited_ctor);
    3438                 :      237299 :       DECL_NONCONVERTING_P (fn) = DECL_NONCONVERTING_P (inherited_ctor);
    3439                 :             :       /* A constructor so declared has the same access as the corresponding
    3440                 :             :          constructor in X.  */
    3441                 :      237299 :       TREE_PRIVATE (fn) = TREE_PRIVATE (inherited_ctor);
    3442                 :      237299 :       TREE_PROTECTED (fn) = TREE_PROTECTED (inherited_ctor);
    3443                 :             :       /* Copy constexpr from the inherited constructor even if the
    3444                 :             :          inheriting constructor doesn't satisfy the requirements.  */
    3445                 :      237299 :       constexpr_p = DECL_DECLARED_CONSTEXPR_P (inherited_ctor);
    3446                 :      237299 :       tree inherited_ctor_fn = STRIP_TEMPLATE (inherited_ctor);
    3447                 :             :       /* Also copy any attributes.  */
    3448                 :      237299 :       DECL_ATTRIBUTES (fn) = clone_attrs (DECL_ATTRIBUTES (inherited_ctor_fn));
    3449                 :      237299 :       DECL_DISREGARD_INLINE_LIMITS (fn)
    3450                 :      237299 :         = DECL_DISREGARD_INLINE_LIMITS (inherited_ctor_fn);
    3451                 :             :     }
    3452                 :             : 
    3453                 :             :   /* Add the "this" parameter.  */
    3454                 :    21339361 :   this_parm = build_this_parm (fn, fn_type, this_quals);
    3455                 :    21339361 :   DECL_CHAIN (this_parm) = DECL_ARGUMENTS (fn);
    3456                 :    21339361 :   DECL_ARGUMENTS (fn) = this_parm;
    3457                 :             : 
    3458                 :    37266068 :   grokclassfn (type, fn, kind == sfk_destructor ? DTOR_FLAG : NO_SPECIAL);
    3459                 :             : 
    3460                 :    21339361 :   DECL_IN_AGGR_P (fn) = 1;
    3461                 :    21339361 :   DECL_ARTIFICIAL (fn) = 1;
    3462                 :    21339361 :   DECL_DEFAULTED_FN (fn) = 1;
    3463                 :    21339361 :   if (cxx_dialect >= cxx11)
    3464                 :             :     {
    3465                 :    21314058 :       DECL_DELETED_FN (fn) = deleted_p;
    3466                 :    21314058 :       DECL_DECLARED_CONSTEXPR_P (fn) = constexpr_p;
    3467                 :             :     }
    3468                 :    21339361 :   DECL_EXTERNAL (fn) = true;
    3469                 :    21339361 :   DECL_NOT_REALLY_EXTERN (fn) = 1;
    3470                 :    21339361 :   DECL_DECLARED_INLINE_P (fn) = 1;
    3471                 :    21339361 :   set_linkage_according_to_type (type, fn);
    3472                 :    21339361 :   if (TREE_PUBLIC (fn))
    3473                 :    21289028 :     DECL_COMDAT (fn) = 1;
    3474                 :    21339361 :   rest_of_decl_compilation (fn, namespace_bindings_p (), at_eof);
    3475                 :    21339361 :   gcc_assert (!TREE_USED (fn));
    3476                 :             : 
    3477                 :             :   /* Propagate constraints from the inherited constructor. */
    3478                 :    21339361 :   if (flag_concepts && inherited_ctor)
    3479                 :       71151 :     if (tree orig_ci = get_constraints (inherited_ctor))
    3480                 :             :       {
    3481                 :          88 :         tree new_ci = copy_node (orig_ci);
    3482                 :          88 :         set_constraints (fn, new_ci);
    3483                 :             :       }
    3484                 :             : 
    3485                 :             :   /* Restore PROCESSING_TEMPLATE_DECL.  */
    3486                 :    21339361 :   processing_template_decl = saved_processing_template_decl;
    3487                 :             : 
    3488                 :    21339361 :   if (inherited_ctor && TREE_CODE (inherited_ctor) == TEMPLATE_DECL)
    3489                 :       42772 :     fn = add_inherited_template_parms (fn, inherited_ctor);
    3490                 :             : 
    3491                 :             :   /* Warn about calling a non-trivial move assignment in a virtual base.  */
    3492                 :     1146402 :   if (kind == sfk_move_assignment && !deleted_p && !trivial_p
    3493                 :    21611453 :       && CLASSTYPE_VBASECLASSES (type))
    3494                 :             :     {
    3495                 :          61 :       location_t loc = input_location;
    3496                 :          61 :       input_location = DECL_SOURCE_LOCATION (fn);
    3497                 :          61 :       synthesized_method_walk (type, kind, const_p,
    3498                 :             :                                NULL, NULL, NULL, NULL, true,
    3499                 :             :                                NULL, NULL_TREE);
    3500                 :          61 :       input_location = loc;
    3501                 :             :     }
    3502                 :             : 
    3503                 :             :   return fn;
    3504                 :             : }
    3505                 :             : 
    3506                 :             : /* Gives any errors about defaulted functions which need to be deferred
    3507                 :             :    until the containing class is complete.  */
    3508                 :             : 
    3509                 :             : void
    3510                 :     5157328 : defaulted_late_check (tree fn)
    3511                 :             : {
    3512                 :             :   /* Complain about invalid signature for defaulted fn.  */
    3513                 :     5157328 :   tree ctx = DECL_CONTEXT (fn);
    3514                 :     5157328 :   special_function_kind kind = special_function_p (fn);
    3515                 :             : 
    3516                 :     5157328 :   if (kind == sfk_comparison)
    3517                 :             :     {
    3518                 :             :       /* If the function was declared constexpr, check that the definition
    3519                 :             :          qualifies.  Otherwise we can define the function lazily.  */
    3520                 :        9582 :       if (DECL_DECLARED_CONSTEXPR_P (fn) && !DECL_INITIAL (fn))
    3521                 :             :         {
    3522                 :             :           /* Prevent GC.  */
    3523                 :        7358 :           function_depth++;
    3524                 :        7358 :           synthesize_method (fn);
    3525                 :        7358 :           function_depth--;
    3526                 :             :         }
    3527                 :       13471 :       return;
    3528                 :             :     }
    3529                 :             : 
    3530                 :     5147746 :   bool fn_const_p = (copy_fn_p (fn) == 2);
    3531                 :     5147746 :   tree implicit_fn = implicitly_declare_fn (kind, ctx, fn_const_p,
    3532                 :             :                                             NULL, NULL);
    3533                 :     5147746 :   tree eh_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (implicit_fn));
    3534                 :             : 
    3535                 :             :   /* Includes special handling for a default xobj operator.  */
    3536                 :    10295486 :   auto compare_fn_params = [](tree fn, tree implicit_fn){
    3537                 :     5147740 :     tree fn_parms = TYPE_ARG_TYPES (TREE_TYPE (fn));
    3538                 :     5147740 :     tree implicit_fn_parms = TYPE_ARG_TYPES (TREE_TYPE (implicit_fn));
    3539                 :             : 
    3540                 :     5147740 :     if (DECL_XOBJ_MEMBER_FUNCTION_P (fn))
    3541                 :             :       {
    3542                 :           4 :         tree fn_obj_ref_type = TREE_VALUE (fn_parms);
    3543                 :             :         /* We can't default xobj operators with an xobj parameter that is not
    3544                 :             :            an lvalue reference, even if it would correspond.  */
    3545                 :           4 :         if (!TYPE_REF_P (fn_obj_ref_type)
    3546                 :           4 :             || TYPE_REF_IS_RVALUE (fn_obj_ref_type)
    3547                 :           8 :             || !object_parms_correspond (fn, implicit_fn,
    3548                 :           4 :                                          DECL_CONTEXT (implicit_fn)))
    3549                 :           0 :           return false;
    3550                 :             :         /* We just compared the object parameters, skip over them before
    3551                 :             :            passing to compparms.  */
    3552                 :           4 :         fn_parms = TREE_CHAIN (fn_parms);
    3553                 :           4 :         implicit_fn_parms = TREE_CHAIN (implicit_fn_parms);
    3554                 :             :       }
    3555                 :     5147740 :     return compparms (fn_parms, implicit_fn_parms);
    3556                 :             :   };
    3557                 :             : 
    3558                 :     5147746 :   if (!same_type_p (TREE_TYPE (TREE_TYPE (fn)),
    3559                 :             :                     TREE_TYPE (TREE_TYPE (implicit_fn)))
    3560                 :     5147746 :       || !compare_fn_params (fn, implicit_fn))
    3561                 :             :     {
    3562                 :          26 :       auto_diagnostic_group d;
    3563                 :          26 :       error ("defaulted declaration %q+D does not match the "
    3564                 :             :              "expected signature", fn);
    3565                 :          26 :       inform (DECL_SOURCE_LOCATION (fn),
    3566                 :             :               "expected signature: %qD", implicit_fn);
    3567                 :          26 :     }
    3568                 :             : 
    3569                 :     5147746 :   if (DECL_DELETED_FN (implicit_fn))
    3570                 :             :     {
    3571                 :        3889 :       DECL_DELETED_FN (fn) = 1;
    3572                 :        3889 :       return;
    3573                 :             :     }
    3574                 :             : 
    3575                 :             :   /* If a function is explicitly defaulted on its first declaration without an
    3576                 :             :      exception-specification, it is implicitly considered to have the same
    3577                 :             :      exception-specification as if it had been implicitly declared.  */
    3578                 :     5143857 :   if (!TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn))
    3579                 :     5143857 :       && DECL_DEFAULTED_IN_CLASS_P (fn))
    3580                 :     3457154 :     TREE_TYPE (fn) = build_exception_variant (TREE_TYPE (fn), eh_spec);
    3581                 :             : 
    3582                 :    10287193 :   if (DECL_DEFAULTED_IN_CLASS_P (fn)
    3583                 :    10287193 :       && DECL_DECLARED_CONSTEXPR_P (implicit_fn))
    3584                 :             :     {
    3585                 :             :       /* Hmm...should we do this for out-of-class too? Should it be OK to
    3586                 :             :          add constexpr later like inline, rather than requiring
    3587                 :             :          declarations to match?  */
    3588                 :     2658639 :       DECL_DECLARED_CONSTEXPR_P (fn) = true;
    3589                 :     2658639 :       if (kind == sfk_constructor)
    3590                 :      730284 :         TYPE_HAS_CONSTEXPR_CTOR (ctx) = true;
    3591                 :             :     }
    3592                 :             : 
    3593                 :     5143857 :   if (!DECL_DECLARED_CONSTEXPR_P (implicit_fn)
    3594                 :     5143857 :       && DECL_DECLARED_CONSTEXPR_P (fn))
    3595                 :             :     {
    3596                 :       95197 :       if (!CLASSTYPE_TEMPLATE_INSTANTIATION (ctx))
    3597                 :             :         {
    3598                 :          17 :           auto_diagnostic_group d;
    3599                 :          17 :           error ("explicitly defaulted function %q+D cannot be declared "
    3600                 :             :                  "%qs because the implicit declaration is not %qs:", fn,
    3601                 :          34 :                  DECL_IMMEDIATE_FUNCTION_P (fn) ? "consteval" : "constexpr",
    3602                 :             :                  "constexpr");
    3603                 :          17 :           explain_implicit_non_constexpr (fn);
    3604                 :          17 :         }
    3605                 :       95197 :       DECL_DECLARED_CONSTEXPR_P (fn) = false;
    3606                 :             :     }
    3607                 :             : }
    3608                 :             : 
    3609                 :             : /* Returns true iff FN can be explicitly defaulted, and gives any
    3610                 :             :    errors if defaulting FN is ill-formed.  */
    3611                 :             : 
    3612                 :             : bool
    3613                 :     5366795 : defaultable_fn_check (tree fn)
    3614                 :             : {
    3615                 :     5366795 :   special_function_kind kind = sfk_none;
    3616                 :             : 
    3617                 :     5366795 :   if (template_parm_scope_p ())
    3618                 :             :     {
    3619                 :           3 :       error ("a template cannot be defaulted");
    3620                 :           3 :       return false;
    3621                 :             :     }
    3622                 :             : 
    3623                 :    10733584 :   if (DECL_CONSTRUCTOR_P (fn))
    3624                 :             :     {
    3625                 :     3271442 :       if (FUNCTION_FIRST_USER_PARMTYPE (fn) == void_list_node)
    3626                 :             :         kind = sfk_constructor;
    3627                 :     1812799 :       else if (copy_fn_p (fn) > 0
    3628                 :     1812799 :                && (TREE_CHAIN (FUNCTION_FIRST_USER_PARMTYPE (fn))
    3629                 :      980896 :                    == void_list_node))
    3630                 :             :         kind = sfk_copy_constructor;
    3631                 :      831906 :       else if (move_fn_p (fn))
    3632                 :             :         kind = sfk_move_constructor;
    3633                 :             :     }
    3634                 :     2095350 :   else if (DECL_DESTRUCTOR_P (fn))
    3635                 :             :     kind = sfk_destructor;
    3636                 :     1456717 :   else if (DECL_ASSIGNMENT_OPERATOR_P (fn)
    3637                 :     1456717 :            && DECL_OVERLOADED_OPERATOR_IS (fn, NOP_EXPR))
    3638                 :             :     {
    3639                 :     1408423 :       if (copy_fn_p (fn))
    3640                 :             :         kind = sfk_copy_assignment;
    3641                 :      563978 :       else if (move_fn_p (fn))
    3642                 :             :         kind = sfk_move_assignment;
    3643                 :             :     }
    3644                 :       48294 :   else if (DECL_OVERLOADED_OPERATOR_CODE_RAW (fn) >= OVL_OP_EQ_EXPR
    3645                 :       48294 :            && DECL_OVERLOADED_OPERATOR_CODE_RAW (fn) <= OVL_OP_SPACESHIP_EXPR)
    3646                 :             :     {
    3647                 :       48279 :       kind = sfk_comparison;
    3648                 :       48279 :       if (!early_check_defaulted_comparison (fn))
    3649                 :             :         return false;
    3650                 :             :     }
    3651                 :             : 
    3652                 :             :   /* FIXME: We need to check for xobj member functions here to give better
    3653                 :             :      diagnostics for weird cases where unrelated xobj parameters are given.
    3654                 :             :      We just want to do better than 'cannot be defaulted'.  */
    3655                 :             : 
    3656                 :             :   if (kind == sfk_none)
    3657                 :             :     {
    3658                 :          21 :       error ("%qD cannot be defaulted", fn);
    3659                 :          21 :       return false;
    3660                 :             :     }
    3661                 :             :   else
    3662                 :             :     {
    3663                 :     5366692 :       for (tree t = FUNCTION_FIRST_USER_PARMTYPE (fn);
    3664                 :     8677843 :            t && t != void_list_node; t = TREE_CHAIN (t))
    3665                 :     3311154 :         if (TREE_PURPOSE (t))
    3666                 :             :           {
    3667                 :           3 :             error ("defaulted function %q+D with default argument", fn);
    3668                 :           3 :             break;
    3669                 :             :           }
    3670                 :             : 
    3671                 :             :       /* Avoid do_warn_unused_parameter warnings.  */
    3672                 :     8677846 :       for (tree p = FUNCTION_FIRST_USER_PARM (fn); p; p = DECL_CHAIN (p))
    3673                 :     3311154 :         if (DECL_NAME (p))
    3674                 :      190660 :           suppress_warning (p, OPT_Wunused_parameter);
    3675                 :             : 
    3676                 :     5366692 :       if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
    3677                 :             :         /* Defer checking.  */;
    3678                 :       22451 :       else if (!processing_template_decl)
    3679                 :         533 :         defaulted_late_check (fn);
    3680                 :             : 
    3681                 :     5366692 :       return true;
    3682                 :             :     }
    3683                 :             : }
    3684                 :             : 
    3685                 :             : /* Add an implicit declaration to TYPE for the kind of function
    3686                 :             :    indicated by SFK.  Return the FUNCTION_DECL for the new implicit
    3687                 :             :    declaration.  */
    3688                 :             : 
    3689                 :             : tree
    3690                 :    15954316 : lazily_declare_fn (special_function_kind sfk, tree type)
    3691                 :             : {
    3692                 :    15954316 :   tree fn;
    3693                 :             :   /* Whether or not the argument has a const reference type.  */
    3694                 :    15954316 :   bool const_p = false;
    3695                 :             : 
    3696                 :    15954316 :   type = TYPE_MAIN_VARIANT (type);
    3697                 :             : 
    3698                 :    15954316 :   switch (sfk)
    3699                 :             :     {
    3700                 :     2205408 :     case sfk_constructor:
    3701                 :     2205408 :       CLASSTYPE_LAZY_DEFAULT_CTOR (type) = 0;
    3702                 :     2205408 :       break;
    3703                 :     3930186 :     case sfk_copy_constructor:
    3704                 :     3930186 :       const_p = TYPE_HAS_CONST_COPY_CTOR (type);
    3705                 :     3930186 :       CLASSTYPE_LAZY_COPY_CTOR (type) = 0;
    3706                 :     3930186 :       break;
    3707                 :     3048204 :     case sfk_move_constructor:
    3708                 :     3048204 :       CLASSTYPE_LAZY_MOVE_CTOR (type) = 0;
    3709                 :     3048204 :       break;
    3710                 :     1246826 :     case sfk_copy_assignment:
    3711                 :     1246826 :       const_p = TYPE_HAS_CONST_COPY_ASSIGN (type);
    3712                 :     1246826 :       CLASSTYPE_LAZY_COPY_ASSIGN (type) = 0;
    3713                 :     1246826 :       break;
    3714                 :      849902 :     case sfk_move_assignment:
    3715                 :      849902 :       CLASSTYPE_LAZY_MOVE_ASSIGN (type) = 0;
    3716                 :      849902 :       break;
    3717                 :     4673790 :     case sfk_destructor:
    3718                 :     4673790 :       CLASSTYPE_LAZY_DESTRUCTOR (type) = 0;
    3719                 :     4673790 :       break;
    3720                 :           0 :     default:
    3721                 :           0 :       gcc_unreachable ();
    3722                 :             :     }
    3723                 :             : 
    3724                 :             :   /* Declare the function.  */
    3725                 :    15954316 :   fn = implicitly_declare_fn (sfk, type, const_p, NULL, NULL);
    3726                 :             : 
    3727                 :             :   /* [class.copy]/8 If the class definition declares a move constructor or
    3728                 :             :      move assignment operator, the implicitly declared copy constructor is
    3729                 :             :      defined as deleted.... */
    3730                 :    15954316 :   if ((sfk == sfk_copy_assignment || sfk == sfk_copy_constructor)
    3731                 :     5177012 :       && cxx_dialect >= cxx11)
    3732                 :             :     {
    3733                 :     5161513 :       if (classtype_has_move_assign_or_move_ctor_p (type, true))
    3734                 :      684170 :         DECL_DELETED_FN (fn) = true;
    3735                 :     4477343 :       else if (classtype_has_depr_implicit_copy (type))
    3736                 :             :         /* The implicit definition of a copy constructor as defaulted is
    3737                 :             :            deprecated if the class has a user-declared copy assignment operator
    3738                 :             :            or a user-declared destructor. The implicit definition of a copy
    3739                 :             :            assignment operator as defaulted is deprecated if the class has a
    3740                 :             :            user-declared copy constructor or a user-declared destructor (15.4,
    3741                 :             :            15.8).  */
    3742                 :      566246 :         TREE_DEPRECATED (fn) = true;
    3743                 :             :     }
    3744                 :             : 
    3745                 :             :   /* Destructors and assignment operators may be virtual.  */
    3746                 :    15954316 :   if (sfk == sfk_destructor
    3747                 :    15954316 :       || sfk == sfk_move_assignment
    3748                 :    10430624 :       || sfk == sfk_copy_assignment)
    3749                 :     6770518 :     check_for_override (fn, type);
    3750                 :             : 
    3751                 :             :   /* Add it to the class  */
    3752                 :    15954316 :   bool added = add_method (type, fn, false);
    3753                 :    15954316 :   gcc_assert (added || errorcount);
    3754                 :             : 
    3755                 :             :   /* Add it to TYPE_FIELDS.  */
    3756                 :    15954316 :   if (sfk == sfk_destructor
    3757                 :    15954316 :       && DECL_VIRTUAL_P (fn))
    3758                 :             :     /* The ABI requires that a virtual destructor go at the end of the
    3759                 :             :        vtable.  */
    3760                 :      165677 :     TYPE_FIELDS (type) = chainon (TYPE_FIELDS (type), fn);
    3761                 :             :   else
    3762                 :             :     {
    3763                 :    15788639 :       DECL_CHAIN (fn) = TYPE_FIELDS (type);
    3764                 :    15788639 :       TYPE_FIELDS (type) = fn;
    3765                 :             :     }
    3766                 :             :   /* Propagate TYPE_FIELDS.  */
    3767                 :    15954316 :   fixup_type_variants (type);
    3768                 :             : 
    3769                 :    15954316 :   maybe_add_class_template_decl_list (type, fn, /*friend_p=*/0);
    3770                 :    15954316 :   if (DECL_MAYBE_IN_CHARGE_CDTOR_P (fn))
    3771                 :             :     /* Create appropriate clones.  */
    3772                 :    13857588 :     clone_cdtor (fn, /*update_methods=*/true);
    3773                 :             : 
    3774                 :             :   /* Classes, structs or unions TYPE marked with hotness attributes propagate
    3775                 :             :      the attribute to all methods.  This is typically done in
    3776                 :             :      check_bases_and_members, but we must also inject them here for deferred
    3777                 :             :      lazily-declared functions.  */
    3778                 :    15954316 :   maybe_propagate_warmth_attributes (fn, type);
    3779                 :             : 
    3780                 :    15954316 :   return fn;
    3781                 :             : }
    3782                 :             : 
    3783                 :             : /* Given a FUNCTION_DECL FN and a chain LIST, skip as many elements of LIST
    3784                 :             :    as there are artificial parms in FN.  */
    3785                 :             : 
    3786                 :             : tree
    3787                 :  2061346326 : skip_artificial_parms_for (const_tree fn, tree list)
    3788                 :             : {
    3789                 :  2061346326 :   if (DECL_IOBJ_MEMBER_FUNCTION_P (fn))
    3790                 :  1283506680 :     list = TREE_CHAIN (list);
    3791                 :             :   else
    3792                 :             :     return list;
    3793                 :             : 
    3794                 :  1283506680 :   if (DECL_HAS_IN_CHARGE_PARM_P (fn))
    3795                 :     9771981 :     list = TREE_CHAIN (list);
    3796                 :  1283506680 :   if (DECL_HAS_VTT_PARM_P (fn))
    3797                 :    12553388 :     list = TREE_CHAIN (list);
    3798                 :             :   return list;
    3799                 :             : }
    3800                 :             : 
    3801                 :             : /* Given a FUNCTION_DECL FN and a chain LIST, return the number of
    3802                 :             :    artificial parms in FN.  */
    3803                 :             : 
    3804                 :             : int
    3805                 :   278064400 : num_artificial_parms_for (const_tree fn)
    3806                 :             : {
    3807                 :   278064400 :   int count = 0;
    3808                 :             : 
    3809                 :   278064400 :   if (DECL_IOBJ_MEMBER_FUNCTION_P (fn))
    3810                 :   249359814 :     count++;
    3811                 :             :   else
    3812                 :             :     return 0;
    3813                 :             : 
    3814                 :   249359814 :   if (DECL_HAS_IN_CHARGE_PARM_P (fn))
    3815                 :        1822 :     count++;
    3816                 :   249359814 :   if (DECL_HAS_VTT_PARM_P (fn))
    3817                 :      108655 :     count++;
    3818                 :             :   return count;
    3819                 :             : }
    3820                 :             : 
    3821                 :             : 
    3822                 :             : #include "gt-cp-method.h"
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.