LCOV - code coverage report
Current view: top level - gcc/cp - typeck2.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 93.1 % 1214 1130
Test Date: 2024-04-20 14:03:02 Functions: 100.0 % 39 39
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Report error messages, build initializers, and perform
       2                 :             :    some front-end optimizations for C++ compiler.
       3                 :             :    Copyright (C) 1987-2024 Free Software Foundation, Inc.
       4                 :             :    Hacked 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                 :             : /* This file is part of the C++ front end.
      24                 :             :    It contains routines to build C++ expressions given their operands,
      25                 :             :    including computing the types of the result, C and C++ specific error
      26                 :             :    checks, and some optimization.  */
      27                 :             : 
      28                 :             : #include "config.h"
      29                 :             : #include "system.h"
      30                 :             : #include "coretypes.h"
      31                 :             : #include "cp-tree.h"
      32                 :             : #include "stor-layout.h"
      33                 :             : #include "varasm.h"
      34                 :             : #include "intl.h"
      35                 :             : #include "gcc-rich-location.h"
      36                 :             : #include "target.h"
      37                 :             : 
      38                 :             : static tree
      39                 :             : process_init_constructor (tree type, tree init, int nested, int flags,
      40                 :             :                           tsubst_flags_t complain);
      41                 :             : 
      42                 :             : 
      43                 :             : /* Print an error message stemming from an attempt to use
      44                 :             :    BASETYPE as a base class for TYPE.  */
      45                 :             : 
      46                 :             : tree
      47                 :          31 : error_not_base_type (tree basetype, tree type)
      48                 :             : {
      49                 :          31 :   if (TREE_CODE (basetype) == FUNCTION_DECL)
      50                 :           0 :     basetype = DECL_CONTEXT (basetype);
      51                 :          31 :   error ("type %qT is not a base type for type %qT", basetype, type);
      52                 :          31 :   return error_mark_node;
      53                 :             : }
      54                 :             : 
      55                 :             : tree
      56                 :        1213 : binfo_or_else (tree base, tree type)
      57                 :             : {
      58                 :        1213 :   tree binfo = lookup_base (type, base, ba_unique,
      59                 :             :                             NULL, tf_warning_or_error);
      60                 :             : 
      61                 :        1213 :   if (binfo == error_mark_node)
      62                 :             :     return NULL_TREE;
      63                 :        1213 :   else if (!binfo)
      64                 :           0 :     error_not_base_type (base, type);
      65                 :             :   return binfo;
      66                 :             : }
      67                 :             : 
      68                 :             : /* According to ARM $7.1.6, "A `const' object may be initialized, but its
      69                 :             :    value may not be changed thereafter.  */
      70                 :             : 
      71                 :             : void
      72                 :         139 : cxx_readonly_error (location_t loc, tree arg, enum lvalue_use errstring)
      73                 :             : {
      74                 :             :  
      75                 :             : /* This macro is used to emit diagnostics to ensure that all format
      76                 :             :    strings are complete sentences, visible to gettext and checked at
      77                 :             :    compile time.  */
      78                 :             :  
      79                 :             : #define ERROR_FOR_ASSIGNMENT(LOC, AS, ASM, IN, DE, ARG)                 \
      80                 :             :   do {                                                                  \
      81                 :             :     switch (errstring)                                                  \
      82                 :             :       {                                                                 \
      83                 :             :       case lv_assign:                                                   \
      84                 :             :         error_at (LOC, AS, ARG);                                        \
      85                 :             :         break;                                                          \
      86                 :             :       case lv_asm:                                                      \
      87                 :             :         error_at (LOC, ASM, ARG);                                       \
      88                 :             :         break;                                                          \
      89                 :             :       case lv_increment:                                                \
      90                 :             :         error_at (LOC, IN, ARG);                                        \
      91                 :             :         break;                                                          \
      92                 :             :       case lv_decrement:                                                \
      93                 :             :         error_at (LOC, DE, ARG);                                        \
      94                 :             :         break;                                                          \
      95                 :             :       default:                                                          \
      96                 :             :         gcc_unreachable ();                                             \
      97                 :             :       }                                                                 \
      98                 :             :   } while (0)
      99                 :             : 
     100                 :             :   /* Handle C++-specific things first.  */
     101                 :             : 
     102                 :         139 :   if (VAR_P (arg)
     103                 :          17 :       && DECL_LANG_SPECIFIC (arg)
     104                 :           0 :       && DECL_IN_AGGR_P (arg)
     105                 :         139 :       && !TREE_STATIC (arg))
     106                 :           0 :     ERROR_FOR_ASSIGNMENT (loc,
     107                 :             :                           G_("assignment of constant field %qD"),
     108                 :             :                           G_("constant field %qD used as %<asm%> output"),
     109                 :             :                           G_("increment of constant field %qD"),
     110                 :             :                           G_("decrement of constant field %qD"),
     111                 :             :                           arg);
     112                 :         139 :   else if (INDIRECT_REF_P (arg)
     113                 :          28 :            && TYPE_REF_P (TREE_TYPE (TREE_OPERAND (arg, 0)))
     114                 :         159 :            && (VAR_P (TREE_OPERAND (arg, 0))
     115                 :           5 :                || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
     116                 :          15 :     ERROR_FOR_ASSIGNMENT (loc,
     117                 :             :                           G_("assignment of read-only reference %qD"),
     118                 :             :                           G_("read-only reference %qD used as %<asm%> output"),
     119                 :             :                           G_("increment of read-only reference %qD"),
     120                 :             :                           G_("decrement of read-only reference %qD"),
     121                 :             :                           TREE_OPERAND (arg, 0));
     122                 :             :   else
     123                 :         124 :     readonly_error (loc, arg, errstring);
     124                 :         139 : }
     125                 :             : 
     126                 :             : /* If TYPE has abstract virtual functions, issue an error about trying
     127                 :             :    to create an object of that type.  DECL is the object declared, or
     128                 :             :    NULL_TREE if the declaration is unavailable, in which case USE specifies
     129                 :             :    the kind of invalid use.  Returns 1 if an error occurred; zero if
     130                 :             :    all was well.  */
     131                 :             : 
     132                 :             : static int
     133                 :   300631829 : abstract_virtuals_error (tree decl, tree type, abstract_class_use use,
     134                 :             :                          tsubst_flags_t complain)
     135                 :             : {
     136                 :   300631829 :   vec<tree, va_gc> *pure;
     137                 :             : 
     138                 :   300631829 :   if (TREE_CODE (type) == ARRAY_TYPE)
     139                 :             :     {
     140                 :      722541 :       decl = NULL_TREE;
     141                 :      722541 :       use = ACU_ARRAY;
     142                 :      722541 :       type = strip_array_types (type);
     143                 :             :     }
     144                 :             : 
     145                 :             :   /* This function applies only to classes. Any other entity can never
     146                 :             :      be abstract.  */
     147                 :   300631829 :   if (!CLASS_TYPE_P (type))
     148                 :             :     return 0;
     149                 :    43808208 :   type = TYPE_MAIN_VARIANT (type);
     150                 :             : 
     151                 :             : #if 0
     152                 :             :   /* Instantiation here seems to be required by the standard,
     153                 :             :      but breaks e.g. boost::bind.  FIXME!  */
     154                 :             :   /* In SFINAE, non-N3276 context, force instantiation.  */
     155                 :             :   if (!(complain & (tf_error|tf_decltype)))
     156                 :             :     complete_type (type);
     157                 :             : #endif
     158                 :             : 
     159                 :    43808208 :   if (!TYPE_SIZE (type))
     160                 :             :     /* TYPE is being defined, and during that time
     161                 :             :        CLASSTYPE_PURE_VIRTUALS holds the inline friends.  */
     162                 :             :     return 0;
     163                 :             : 
     164                 :    43808141 :   pure = CLASSTYPE_PURE_VIRTUALS (type);
     165                 :    43808141 :   if (!pure)
     166                 :             :     return 0;
     167                 :             : 
     168                 :         141 :   if (!(complain & tf_error))
     169                 :             :     return 1;
     170                 :             : 
     171                 :         117 :   auto_diagnostic_group d;
     172                 :         117 :   if (decl)
     173                 :             :     {
     174                 :          62 :       if (VAR_P (decl))
     175                 :          10 :         error ("cannot declare variable %q+D to be of abstract "
     176                 :             :                "type %qT", decl, type);
     177                 :          52 :       else if (TREE_CODE (decl) == PARM_DECL)
     178                 :             :         {
     179                 :          35 :           if (DECL_NAME (decl))
     180                 :          32 :             error ("cannot declare parameter %q+D to be of abstract type %qT",
     181                 :             :                    decl, type);
     182                 :             :           else
     183                 :           3 :             error ("cannot declare parameter to be of abstract type %qT",
     184                 :             :                    type);
     185                 :             :         }
     186                 :          17 :       else if (TREE_CODE (decl) == FIELD_DECL)
     187                 :          14 :         error ("cannot declare field %q+D to be of abstract type %qT",
     188                 :             :                decl, type);
     189                 :           3 :       else if (TREE_CODE (decl) == FUNCTION_DECL
     190                 :           3 :                && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
     191                 :           0 :         error ("invalid abstract return type for member function %q+#D", decl);
     192                 :           3 :       else if (TREE_CODE (decl) == FUNCTION_DECL)
     193                 :           3 :         error ("invalid abstract return type for function %q+#D", decl);
     194                 :           0 :       else if (identifier_p (decl))
     195                 :             :         /* Here we do not have location information.  */
     196                 :           0 :         error ("invalid abstract type %qT for %qE", type, decl);
     197                 :             :       else
     198                 :           0 :         error ("invalid abstract type for %q+D", decl);
     199                 :             :     }
     200                 :          55 :   else switch (use)
     201                 :             :     {
     202                 :          11 :     case ACU_ARRAY:
     203                 :          11 :       error ("creating array of %qT, which is an abstract class type", type);
     204                 :          11 :       break;
     205                 :           9 :     case ACU_CAST:
     206                 :           9 :       error ("invalid cast to abstract class type %qT", type);
     207                 :           9 :       break;
     208                 :           0 :     case ACU_NEW:
     209                 :           0 :       error ("invalid new-expression of abstract class type %qT", type);
     210                 :           0 :       break;
     211                 :           0 :     case ACU_RETURN:
     212                 :           0 :       error ("invalid abstract return type %qT", type);
     213                 :           0 :       break;
     214                 :           0 :     case ACU_PARM:
     215                 :           0 :       error ("invalid abstract parameter type %qT", type);
     216                 :           0 :       break;
     217                 :           7 :     case ACU_THROW:
     218                 :           7 :       error ("expression of abstract class type %qT cannot "
     219                 :             :              "be used in throw-expression", type);
     220                 :           7 :       break;
     221                 :           3 :     case ACU_CATCH:
     222                 :           3 :       error ("cannot declare %<catch%> parameter to be of abstract "
     223                 :             :              "class type %qT", type);
     224                 :           3 :       break;
     225                 :          25 :     default:
     226                 :          25 :       error ("cannot allocate an object of abstract type %qT", type);
     227                 :             :     }
     228                 :             : 
     229                 :             :   /* Only go through this once.  */
     230                 :         117 :   if (pure->length ())
     231                 :             :     {
     232                 :          52 :       unsigned ix;
     233                 :          52 :       tree fn;
     234                 :             : 
     235                 :          52 :       inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)),
     236                 :             :               "  because the following virtual functions are pure within %qT:",
     237                 :             :               type);
     238                 :             : 
     239                 :         156 :       FOR_EACH_VEC_ELT (*pure, ix, fn)
     240                 :         104 :         if (! DECL_CLONED_FUNCTION_P (fn)
     241                 :          52 :             || DECL_COMPLETE_DESTRUCTOR_P (fn))
     242                 :          52 :           inform (DECL_SOURCE_LOCATION (fn), "    %#qD", fn);
     243                 :             : 
     244                 :             :       /* Now truncate the vector.  This leaves it non-null, so we know
     245                 :             :          there are pure virtuals, but empty so we don't list them out
     246                 :             :          again.  */
     247                 :          52 :       pure->truncate (0);
     248                 :             :     }
     249                 :             : 
     250                 :         117 :   return 1;
     251                 :         117 : }
     252                 :             : 
     253                 :             : int
     254                 :   260176766 : abstract_virtuals_error (tree decl, tree type,
     255                 :             :                          tsubst_flags_t complain /* = tf_warning_or_error */)
     256                 :             : {
     257                 :   260176766 :   return abstract_virtuals_error (decl, type, ACU_UNKNOWN, complain);
     258                 :             : }
     259                 :             : 
     260                 :             : int
     261                 :    40455063 : abstract_virtuals_error (abstract_class_use use, tree type,
     262                 :             :                          tsubst_flags_t complain /* = tf_warning_or_error */)
     263                 :             : {
     264                 :    40455063 :   return abstract_virtuals_error (NULL_TREE, type, use, complain);
     265                 :             : }
     266                 :             : 
     267                 :             : 
     268                 :             : /* Print an inform about the declaration of the incomplete type TYPE.  */
     269                 :             : 
     270                 :             : void
     271                 :         960 : cxx_incomplete_type_inform (const_tree type)
     272                 :             : {
     273                 :         960 :   if (!TYPE_MAIN_DECL (type))
     274                 :             :     return;
     275                 :             : 
     276                 :         852 :   location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type));
     277                 :         852 :   tree ptype = strip_top_quals (CONST_CAST_TREE (type));
     278                 :             : 
     279                 :         852 :   if (current_class_type
     280                 :         312 :       && TYPE_BEING_DEFINED (current_class_type)
     281                 :        1099 :       && same_type_p (ptype, current_class_type))
     282                 :         107 :     inform (loc, "definition of %q#T is not complete until "
     283                 :             :             "the closing brace", ptype);
     284                 :         745 :   else if (!TYPE_TEMPLATE_INFO (ptype))
     285                 :         590 :     inform (loc, "forward declaration of %q#T", ptype);
     286                 :             :   else
     287                 :         155 :     inform (loc, "declaration of %q#T", ptype);
     288                 :             : }
     289                 :             : 
     290                 :             : /* Print an error message for invalid use of an incomplete type.
     291                 :             :    VALUE is the expression that was used (or 0 if that isn't known)
     292                 :             :    and TYPE is the type that was invalid.  DIAG_KIND indicates the
     293                 :             :    type of diagnostic (see diagnostic.def).  */
     294                 :             : 
     295                 :             : bool
     296                 :        1040 : cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
     297                 :             :                                 const_tree type, diagnostic_t diag_kind)
     298                 :             : {
     299                 :        1040 :   bool is_decl = false, complained = false;
     300                 :             : 
     301                 :             :   /* Avoid duplicate error message.  */
     302                 :        1040 :   if (TREE_CODE (type) == ERROR_MARK)
     303                 :             :     return false;
     304                 :             : 
     305                 :        1040 :   if (value)
     306                 :             :     {
     307                 :         484 :       STRIP_ANY_LOCATION_WRAPPER (value);
     308                 :             : 
     309                 :         484 :       if (VAR_P (value)
     310                 :         422 :           || TREE_CODE (value) == PARM_DECL
     311                 :         372 :           || TREE_CODE (value) == FIELD_DECL)
     312                 :             :         {
     313                 :         148 :           complained = emit_diagnostic (diag_kind, DECL_SOURCE_LOCATION (value), 0,
     314                 :             :                                         "%qD has incomplete type", value);
     315                 :         148 :           is_decl = true;
     316                 :             :         }
     317                 :             :     }
     318                 :        1040 :  retry:
     319                 :             :   /* We must print an error message.  Be clever about what it says.  */
     320                 :             : 
     321                 :        1046 :   switch (TREE_CODE (type))
     322                 :             :     {
     323                 :         704 :     case RECORD_TYPE:
     324                 :         704 :     case UNION_TYPE:
     325                 :         704 :     case ENUMERAL_TYPE:
     326                 :         704 :       if (!is_decl)
     327                 :         580 :         complained = emit_diagnostic (diag_kind, loc, 0,
     328                 :             :                                       "invalid use of incomplete type %q#T",
     329                 :             :                                       type);
     330                 :         704 :       if (complained)
     331                 :         698 :         cxx_incomplete_type_inform (type);
     332                 :             :       break;
     333                 :             : 
     334                 :          15 :     case VOID_TYPE:
     335                 :          15 :       complained = emit_diagnostic (diag_kind, loc, 0,
     336                 :             :                        "invalid use of %qT", type);
     337                 :          15 :       break;
     338                 :             : 
     339                 :          76 :     case ARRAY_TYPE:
     340                 :          76 :       if (TYPE_DOMAIN (type))
     341                 :             :         {
     342                 :           6 :           type = TREE_TYPE (type);
     343                 :           6 :           goto retry;
     344                 :             :         }
     345                 :          70 :       complained = emit_diagnostic (diag_kind, loc, 0,
     346                 :             :                        "invalid use of array with unspecified bounds");
     347                 :          70 :       break;
     348                 :             : 
     349                 :          92 :     case OFFSET_TYPE:
     350                 :          92 :     bad_member:
     351                 :          92 :       {
     352                 :          92 :         tree member = TREE_OPERAND (value, 1);
     353                 :          92 :         if (is_overloaded_fn (member) && !flag_ms_extensions)
     354                 :             :           {
     355                 :          88 :             gcc_rich_location richloc (loc);
     356                 :             :             /* If "member" has no arguments (other than "this"), then
     357                 :             :                add a fix-it hint.  */
     358                 :          88 :             member = MAYBE_BASELINK_FUNCTIONS (member);
     359                 :          88 :             if (TREE_CODE (member) == FUNCTION_DECL
     360                 :          76 :                 && DECL_OBJECT_MEMBER_FUNCTION_P (member)
     361                 :         164 :                 && type_num_arguments (TREE_TYPE (member)) == 1)
     362                 :          72 :               richloc.add_fixit_insert_after ("()");
     363                 :          88 :             complained = emit_diagnostic (diag_kind, &richloc, 0,
     364                 :             :                              "invalid use of member function %qD "
     365                 :             :                              "(did you forget the %<()%> ?)", member);
     366                 :          88 :           }
     367                 :             :         else
     368                 :           4 :           complained = emit_diagnostic (diag_kind, loc, 0,
     369                 :             :                            "invalid use of member %qD "
     370                 :             :                            "(did you forget the %<&%> ?)", member);
     371                 :             :       }
     372                 :             :       break;
     373                 :             : 
     374                 :          33 :     case TEMPLATE_TYPE_PARM:
     375                 :          33 :       if (is_auto (type))
     376                 :             :         {
     377                 :          21 :           if (CLASS_PLACEHOLDER_TEMPLATE (type))
     378                 :           2 :             complained = emit_diagnostic (diag_kind, loc, 0,
     379                 :             :                              "invalid use of placeholder %qT", type);
     380                 :             :           else
     381                 :          19 :             complained = emit_diagnostic (diag_kind, loc, 0,
     382                 :             :                              "invalid use of %qT", type);
     383                 :             :         }
     384                 :             :       else
     385                 :          12 :         complained = emit_diagnostic (diag_kind, loc, 0,
     386                 :             :                          "invalid use of template type parameter %qT", type);
     387                 :             :       break;
     388                 :             : 
     389                 :           4 :     case BOUND_TEMPLATE_TEMPLATE_PARM:
     390                 :           8 :       complained = emit_diagnostic (diag_kind, loc, 0,
     391                 :             :                        "invalid use of template template parameter %qT",
     392                 :           4 :                        TYPE_NAME (type));
     393                 :           4 :       break;
     394                 :             : 
     395                 :           3 :     case TYPE_PACK_EXPANSION:
     396                 :           3 :       complained = emit_diagnostic (diag_kind, loc, 0,
     397                 :             :                        "invalid use of pack expansion %qT", type);
     398                 :           3 :       break;
     399                 :             : 
     400                 :          24 :     case TYPENAME_TYPE:
     401                 :          24 :     case DECLTYPE_TYPE:
     402                 :          24 :       complained = emit_diagnostic (diag_kind, loc, 0,
     403                 :             :                        "invalid use of dependent type %qT", type);
     404                 :          24 :       break;
     405                 :             : 
     406                 :         187 :     case LANG_TYPE:
     407                 :         187 :       if (type == init_list_type_node)
     408                 :             :         {
     409                 :           3 :           complained = emit_diagnostic (diag_kind, loc, 0,
     410                 :             :                            "invalid use of brace-enclosed initializer list");
     411                 :           3 :           break;
     412                 :             :         }
     413                 :         184 :       gcc_assert (type == unknown_type_node);
     414                 :         184 :       if (value && TREE_CODE (value) == COMPONENT_REF)
     415                 :          92 :         goto bad_member;
     416                 :          92 :       else if (value && TREE_CODE (value) == ADDR_EXPR)
     417                 :          36 :         complained = emit_diagnostic (diag_kind, loc, 0,
     418                 :             :                          "address of overloaded function with no contextual "
     419                 :             :                          "type information");
     420                 :          56 :       else if (value && TREE_CODE (value) == OVERLOAD)
     421                 :          56 :         complained = emit_diagnostic (diag_kind, loc, 0,
     422                 :             :                          "overloaded function with no contextual type information");
     423                 :             :       else
     424                 :           0 :         complained = emit_diagnostic (diag_kind, loc, 0,
     425                 :             :                          "insufficient contextual information to determine type");
     426                 :             :       break;
     427                 :             : 
     428                 :           0 :     default:
     429                 :           0 :       gcc_unreachable ();
     430                 :             :     }
     431                 :             : 
     432                 :             :   return complained;
     433                 :             : }
     434                 :             : 
     435                 :             : /* Print an error message for invalid use of an incomplete type.
     436                 :             :    VALUE is the expression that was used (or 0 if that isn't known)
     437                 :             :    and TYPE is the type that was invalid.  */
     438                 :             : 
     439                 :             : void
     440                 :          74 : cxx_incomplete_type_error (location_t loc, const_tree value, const_tree type)
     441                 :             : {
     442                 :          74 :   cxx_incomplete_type_diagnostic (loc, value, type, DK_ERROR);
     443                 :          74 : }
     444                 :             : 
     445                 :             : 
     446                 :             : /* We've just initialized subobject SUB; also insert a TARGET_EXPR with an
     447                 :             :    EH-only cleanup for SUB.  Because of EH region nesting issues, we need to
     448                 :             :    make the cleanup conditional on a flag that we will clear once the object is
     449                 :             :    fully initialized, so push a new flag onto FLAGS.  */
     450                 :             : 
     451                 :             : static void
     452                 :      292472 : maybe_push_temp_cleanup (tree sub, vec<tree,va_gc> **flags)
     453                 :             : {
     454                 :      292472 :   if (!flag_exceptions)
     455                 :             :     return;
     456                 :      582014 :   if (tree cleanup
     457                 :      291007 :       = cxx_maybe_build_cleanup (sub, tf_warning_or_error))
     458                 :             :     {
     459                 :          72 :       tree tx = get_target_expr (boolean_true_node);
     460                 :          72 :       tree flag = TARGET_EXPR_SLOT (tx);
     461                 :          72 :       CLEANUP_EH_ONLY (tx) = true;
     462                 :          72 :       TARGET_EXPR_CLEANUP (tx) = build3 (COND_EXPR, void_type_node,
     463                 :             :                                          flag, cleanup, void_node);
     464                 :          72 :       add_stmt (tx);
     465                 :          72 :       vec_safe_push (*flags, flag);
     466                 :             :     }
     467                 :             : }
     468                 :             : 
     469                 :             : /* The recursive part of split_nonconstant_init.  DEST is an lvalue
     470                 :             :    expression to which INIT should be assigned.  INIT is a CONSTRUCTOR.
     471                 :             :    Return true if the whole of the value was initialized by the
     472                 :             :    generated statements.  */
     473                 :             : 
     474                 :             : static bool
     475                 :      226511 : split_nonconstant_init_1 (tree dest, tree init, bool last,
     476                 :             :                           vec<tree,va_gc> **flags)
     477                 :             : {
     478                 :      226511 :   unsigned HOST_WIDE_INT idx, tidx = HOST_WIDE_INT_M1U;
     479                 :      226511 :   tree field_index, value;
     480                 :      226511 :   tree type = TREE_TYPE (dest);
     481                 :      226511 :   tree inner_type = NULL;
     482                 :      226511 :   bool array_type_p = false;
     483                 :      226511 :   bool complete_p = true;
     484                 :      226511 :   HOST_WIDE_INT num_split_elts = 0;
     485                 :      226511 :   tree last_split_elt = NULL_TREE;
     486                 :             : 
     487                 :      226511 :   switch (TREE_CODE (type))
     488                 :             :     {
     489                 :        3108 :     case ARRAY_TYPE:
     490                 :        3108 :       inner_type = TREE_TYPE (type);
     491                 :        3108 :       array_type_p = true;
     492                 :        3108 :       if ((TREE_SIDE_EFFECTS (init)
     493                 :         522 :            && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
     494                 :        3440 :           || vla_type_p (type))
     495                 :             :         {
     496                 :         269 :           if (!TYPE_DOMAIN (type)
     497                 :           3 :               && TREE_CODE (init) == CONSTRUCTOR
     498                 :         272 :               && CONSTRUCTOR_NELTS (init))
     499                 :             :             {
     500                 :             :               /* Flexible array.  */
     501                 :           3 :               cp_complete_array_type (&type, init, /*default*/true);
     502                 :           3 :               dest = build1 (VIEW_CONVERT_EXPR, type, dest);
     503                 :             :             }
     504                 :             : 
     505                 :             :           /* For an array, we only need/want a single cleanup region rather
     506                 :             :              than one per element.  build_vec_init will handle it.  */
     507                 :         269 :           tree code = build_vec_init (dest, NULL_TREE, init, false, 1,
     508                 :             :                                       tf_warning_or_error, flags);
     509                 :         269 :           add_stmt (code);
     510                 :         269 :           return true;
     511                 :             :         }
     512                 :             :       /* FALLTHRU */
     513                 :             : 
     514                 :      225095 :     case RECORD_TYPE:
     515                 :      225095 :     case UNION_TYPE:
     516                 :      225095 :     case QUAL_UNION_TYPE:
     517                 :      737946 :       FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), idx,
     518                 :             :                                 field_index, value)
     519                 :             :         {
     520                 :             :           /* The current implementation of this algorithm assumes that
     521                 :             :              the field was set for all the elements. This is usually done
     522                 :             :              by process_init_constructor.  */
     523                 :      512851 :           gcc_assert (field_index);
     524                 :             : 
     525                 :      512851 :           if (!array_type_p)
     526                 :      507458 :             inner_type = TREE_TYPE (field_index);
     527                 :             : 
     528                 :      512851 :           tree sub;
     529                 :      512851 :           if (array_type_p)
     530                 :        5393 :             sub = build4 (ARRAY_REF, inner_type, dest, field_index,
     531                 :             :                           NULL_TREE, NULL_TREE);
     532                 :             :           else
     533                 :      507458 :             sub = build3 (COMPONENT_REF, inner_type, dest, field_index,
     534                 :             :                           NULL_TREE);
     535                 :             : 
     536                 :     1536413 :           bool elt_last = last && idx == CONSTRUCTOR_NELTS (init) - 1;
     537                 :             : 
     538                 :             :           /* We need to see sub-array TARGET_EXPR before cp_fold_r so we can
     539                 :             :              handle cleanup flags properly.  */
     540                 :      512851 :           gcc_checking_assert (!target_expr_needs_replace (value));
     541                 :             : 
     542                 :      512851 :           if (TREE_CODE (value) == CONSTRUCTOR)
     543                 :             :             {
     544                 :         581 :               if (!split_nonconstant_init_1 (sub, value, elt_last, flags)
     545                 :             :                       /* For flexible array member with initializer we
     546                 :             :                          can't remove the initializer, because only the
     547                 :             :                          initializer determines how many elements the
     548                 :             :                          flexible array member has.  */
     549                 :         581 :                   || (!array_type_p
     550                 :         176 :                       && TREE_CODE (inner_type) == ARRAY_TYPE
     551                 :         100 :                       && TYPE_DOMAIN (inner_type) == NULL
     552                 :          61 :                       && TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
     553                 :          61 :                       && COMPLETE_TYPE_P (TREE_TYPE (value))
     554                 :          61 :                       && !integer_zerop (TYPE_SIZE (TREE_TYPE (value)))
     555                 :          61 :                       && elt_last
     556                 :          61 :                       && TYPE_HAS_TRIVIAL_DESTRUCTOR
     557                 :             :                                 (strip_array_types (inner_type))))
     558                 :             :                 complete_p = false;
     559                 :             :               else
     560                 :             :                 {
     561                 :             :                   /* Mark element for removal.  */
     562                 :         156 :                   last_split_elt = field_index;
     563                 :         156 :                   CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE;
     564                 :         156 :                   if (idx < tidx)
     565                 :             :                     tidx = idx;
     566                 :         156 :                   num_split_elts++;
     567                 :             :                 }
     568                 :             :             }
     569                 :      512270 :           else if (tree vi = get_vec_init_expr (value))
     570                 :             :             {
     571                 :          32 :               add_stmt (expand_vec_init_expr (sub, vi, tf_warning_or_error,
     572                 :             :                                               flags));
     573                 :             : 
     574                 :             :               /* Mark element for removal.  */
     575                 :          32 :               last_split_elt = field_index;
     576                 :          32 :               CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE;
     577                 :          32 :               if (idx < tidx)
     578                 :             :                 tidx = idx;
     579                 :          32 :               num_split_elts++;
     580                 :             :             }
     581                 :      512238 :           else if (!initializer_constant_valid_p (value, inner_type))
     582                 :             :             {
     583                 :      414203 :               tree code;
     584                 :             : 
     585                 :             :               /* Push cleanups for any preceding members with constant
     586                 :             :                  initialization.  */
     587                 :      414203 :               if (CLASS_TYPE_P (type))
     588                 :      819352 :                 for (tree prev = (last_split_elt ?
     589                 :      194187 :                                   DECL_CHAIN (last_split_elt)
     590                 :      215489 :                                   : TYPE_FIELDS (type));
     591                 :        1292 :                      ; prev = DECL_CHAIN (prev))
     592                 :             :                   {
     593                 :      410968 :                     prev = next_aggregate_field (prev);
     594                 :      410968 :                     if (prev == field_index)
     595                 :             :                       break;
     596                 :        1292 :                     tree ptype = TREE_TYPE (prev);
     597                 :        1292 :                     if (TYPE_P (ptype) && type_build_dtor_call (ptype))
     598                 :             :                       {
     599                 :          22 :                         tree pcref = build3 (COMPONENT_REF, ptype, dest, prev,
     600                 :             :                                              NULL_TREE);
     601                 :          22 :                         maybe_push_temp_cleanup (pcref, flags);
     602                 :             :                       }
     603                 :        1292 :                   }
     604                 :             : 
     605                 :             :               /* Mark element for removal.  */
     606                 :      414203 :               CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE;
     607                 :      414203 :               if (idx < tidx)
     608                 :             :                 tidx = idx;
     609                 :             : 
     610                 :      414203 :               if (TREE_CODE (field_index) == RANGE_EXPR)
     611                 :             :                 {
     612                 :             :                   /* Use build_vec_init to initialize a range.  */
     613                 :           0 :                   tree low = TREE_OPERAND (field_index, 0);
     614                 :           0 :                   tree hi = TREE_OPERAND (field_index, 1);
     615                 :           0 :                   sub = build4 (ARRAY_REF, inner_type, dest, low,
     616                 :             :                                 NULL_TREE, NULL_TREE);
     617                 :           0 :                   sub = cp_build_addr_expr (sub, tf_warning_or_error);
     618                 :           0 :                   tree max = size_binop (MINUS_EXPR, hi, low);
     619                 :           0 :                   code = build_vec_init (sub, max, value, false, 0,
     620                 :             :                                          tf_warning_or_error);
     621                 :           0 :                   add_stmt (code);
     622                 :           0 :                   if (tree_fits_shwi_p (max))
     623                 :           0 :                     num_split_elts += tree_to_shwi (max);
     624                 :             :                 }
     625                 :             :               else
     626                 :             :                 {
     627                 :             :                   /* We may need to add a copy constructor call if
     628                 :             :                      the field has [[no_unique_address]].  */
     629                 :      414203 :                   if (unsafe_return_slot_p (sub))
     630                 :             :                     {
     631                 :             :                       /* But not if the initializer is an implicit ctor call
     632                 :             :                          we just built in digest_init.  */
     633                 :         147 :                       if (TREE_CODE (value) == TARGET_EXPR
     634                 :         147 :                           && TARGET_EXPR_LIST_INIT_P (value)
     635                 :         159 :                           && make_safe_copy_elision (sub, value))
     636                 :          12 :                         goto build_init;
     637                 :             : 
     638                 :         135 :                       tree name = (DECL_FIELD_IS_BASE (field_index)
     639                 :         135 :                                    ? base_ctor_identifier
     640                 :         135 :                                    : complete_ctor_identifier);
     641                 :         135 :                       releasing_vec args = make_tree_vector_single (value);
     642                 :         135 :                       code = build_special_member_call
     643                 :         135 :                         (sub, name, &args, inner_type,
     644                 :             :                          LOOKUP_NORMAL, tf_warning_or_error);
     645                 :         135 :                     }
     646                 :             :                   else
     647                 :             :                     {
     648                 :      414056 :                     build_init:
     649                 :      414068 :                       code = cp_build_init_expr (sub, value);
     650                 :             :                     }
     651                 :      414203 :                   code = build_stmt (input_location, EXPR_STMT, code);
     652                 :      414203 :                   add_stmt (code);
     653                 :      414203 :                   if (!elt_last)
     654                 :      292450 :                     maybe_push_temp_cleanup (sub, flags);
     655                 :             :                 }
     656                 :             : 
     657                 :      414203 :               last_split_elt = field_index;
     658                 :      414203 :               num_split_elts++;
     659                 :             :             }
     660                 :             :         }
     661                 :      225095 :       if (num_split_elts == 1)
     662                 :      111816 :         CONSTRUCTOR_ELTS (init)->ordered_remove (tidx);
     663                 :      113279 :       else if (num_split_elts > 1)
     664                 :             :         {
     665                 :             :           /* Perform the delayed ordered removal of non-constant elements
     666                 :             :              we split out.  */
     667                 :      818910 :           for (idx = tidx; idx < CONSTRUCTOR_NELTS (init); ++idx)
     668                 :      302836 :             if (CONSTRUCTOR_ELT (init, idx)->index == NULL_TREE)
     669                 :             :               ;
     670                 :             :             else
     671                 :             :               {
     672                 :         261 :                 *CONSTRUCTOR_ELT (init, tidx) = *CONSTRUCTOR_ELT (init, idx);
     673                 :         261 :                 ++tidx;
     674                 :             :               }
     675                 :      106619 :           vec_safe_truncate (CONSTRUCTOR_ELTS (init), tidx);
     676                 :             :         }
     677                 :             :       break;
     678                 :             : 
     679                 :        1147 :     case VECTOR_TYPE:
     680                 :        1147 :       if (!initializer_constant_valid_p (init, type))
     681                 :             :         {
     682                 :        1142 :           tree code;
     683                 :        1142 :           tree cons = copy_node (init);
     684                 :        1142 :           CONSTRUCTOR_ELTS (init) = NULL;
     685                 :        1142 :           code = build2 (MODIFY_EXPR, type, dest, cons);
     686                 :        1142 :           code = build_stmt (input_location, EXPR_STMT, code);
     687                 :        1142 :           add_stmt (code);
     688                 :        1142 :           num_split_elts += CONSTRUCTOR_NELTS (init);
     689                 :             :         }
     690                 :             :       break;
     691                 :             : 
     692                 :           0 :     default:
     693                 :           0 :       gcc_unreachable ();
     694                 :             :     }
     695                 :             : 
     696                 :             :   /* The rest of the initializer is now a constant. */
     697                 :      226242 :   TREE_CONSTANT (init) = 1;
     698                 :      226242 :   TREE_SIDE_EFFECTS (init) = 0;
     699                 :             : 
     700                 :             :   /* We didn't split out anything.  */
     701                 :      226242 :   if (num_split_elts == 0)
     702                 :             :     return false;
     703                 :             : 
     704                 :      218435 :   return complete_p && complete_ctor_at_level_p (TREE_TYPE (init),
     705                 :             :                                                  num_split_elts, inner_type);
     706                 :             : }
     707                 :             : 
     708                 :             : /* A subroutine of store_init_value.  Splits non-constant static
     709                 :             :    initializer INIT into a constant part and generates code to
     710                 :             :    perform the non-constant part of the initialization to DEST.
     711                 :             :    Returns the code for the runtime init.  */
     712                 :             : 
     713                 :             : tree
     714                 :    12025993 : split_nonconstant_init (tree dest, tree init)
     715                 :             : {
     716                 :    12025993 :   tree code;
     717                 :             : 
     718                 :    12025993 :   if (TREE_CODE (init) == TARGET_EXPR)
     719                 :      196678 :     init = TARGET_EXPR_INITIAL (init);
     720                 :    12025993 :   if (TREE_CODE (init) == CONSTRUCTOR)
     721                 :             :     {
     722                 :             :       /* Subobject initializers are not full-expressions.  */
     723                 :      225930 :       auto fe = (make_temp_override
     724                 :      225930 :                  (current_stmt_tree ()->stmts_are_full_exprs_p, 0));
     725                 :             : 
     726                 :      225930 :       init = cp_fully_fold_init (init);
     727                 :      225930 :       code = push_stmt_list ();
     728                 :             : 
     729                 :             :       /* If the complete object is an array, build_vec_init's cleanup is
     730                 :             :          enough.  Otherwise, collect flags for disabling subobject
     731                 :             :          cleanups once the complete object is fully constructed.  */
     732                 :      225930 :       vec<tree, va_gc> *flags = nullptr;
     733                 :      225930 :       if (TREE_CODE (TREE_TYPE (dest)) != ARRAY_TYPE)
     734                 :      223020 :         flags = make_tree_vector ();
     735                 :             : 
     736                 :      225930 :       if (split_nonconstant_init_1 (dest, init, true, &flags))
     737                 :      121486 :         init = NULL_TREE;
     738                 :             : 
     739                 :      672589 :       for (tree f : flags)
     740                 :             :         {
     741                 :             :           /* See maybe_push_temp_cleanup.  */
     742                 :         277 :           tree d = f;
     743                 :         277 :           tree i = boolean_false_node;
     744                 :         277 :           if (TREE_CODE (f) == TREE_LIST)
     745                 :             :             {
     746                 :             :               /* To disable a build_vec_init cleanup, set
     747                 :             :                  iterator = maxindex.  */
     748                 :         205 :               d = TREE_PURPOSE (f);
     749                 :         205 :               i = TREE_VALUE (f);
     750                 :         205 :               ggc_free (f);
     751                 :             :             }
     752                 :         277 :           add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (d), d, i));
     753                 :             :         }
     754                 :      225930 :       release_tree_vector (flags);
     755                 :             : 
     756                 :      225930 :       code = pop_stmt_list (code);
     757                 :      225930 :       if (VAR_P (dest) && !is_local_temp (dest))
     758                 :             :         {
     759                 :      225308 :           DECL_INITIAL (dest) = init;
     760                 :      225308 :           TREE_READONLY (dest) = 0;
     761                 :             :         }
     762                 :         622 :       else if (init)
     763                 :             :         {
     764                 :         254 :           tree ie = cp_build_init_expr (dest, init);
     765                 :         254 :           code = add_stmt_to_compound (ie, code);
     766                 :             :         }
     767                 :      225930 :     }
     768                 :    11800063 :   else if (TREE_CODE (init) == STRING_CST
     769                 :    11800063 :            && array_of_runtime_bound_p (TREE_TYPE (dest)))
     770                 :          30 :     code = build_vec_init (dest, NULL_TREE, init, /*value-init*/false,
     771                 :             :                            /*from array*/1, tf_warning_or_error);
     772                 :             :   else
     773                 :    11800033 :     code = cp_build_init_expr (dest, init);
     774                 :             : 
     775                 :    12025993 :   return code;
     776                 :             : }
     777                 :             : 
     778                 :             : /* T is the initializer of a constexpr variable.  Set CONSTRUCTOR_MUTABLE_POISON
     779                 :             :    for any CONSTRUCTOR within T that contains (directly or indirectly) a mutable
     780                 :             :    member, thereby poisoning it so it can't be copied to another a constexpr
     781                 :             :    variable or read during constexpr evaluation.  */
     782                 :             : 
     783                 :             : static void
     784                 :    17687632 : poison_mutable_constructors (tree t)
     785                 :             : {
     786                 :    17687632 :   if (TREE_CODE (t) != CONSTRUCTOR)
     787                 :             :     return;
     788                 :             : 
     789                 :      965097 :   if (cp_has_mutable_p (TREE_TYPE (t)))
     790                 :             :     {
     791                 :         179 :       CONSTRUCTOR_MUTABLE_POISON (t) = true;
     792                 :             : 
     793                 :         179 :       if (vec<constructor_elt, va_gc> *elts = CONSTRUCTOR_ELTS (t))
     794                 :         385 :         for (const constructor_elt &ce : *elts)
     795                 :         212 :           poison_mutable_constructors (ce.value);
     796                 :             :     }
     797                 :             : }
     798                 :             : 
     799                 :             : /* Perform appropriate conversions on the initial value of a variable,
     800                 :             :    store it in the declaration DECL,
     801                 :             :    and print any error messages that are appropriate.
     802                 :             :    If the init is invalid, store an ERROR_MARK.
     803                 :             : 
     804                 :             :    C++: Note that INIT might be a TREE_LIST, which would mean that it is
     805                 :             :    a base class initializer for some aggregate type, hopefully compatible
     806                 :             :    with DECL.  If INIT is a single element, and DECL is an aggregate
     807                 :             :    type, we silently convert INIT into a TREE_LIST, allowing a constructor
     808                 :             :    to be called.
     809                 :             : 
     810                 :             :    If INIT is a TREE_LIST and there is no constructor, turn INIT
     811                 :             :    into a CONSTRUCTOR and use standard initialization techniques.
     812                 :             :    Perhaps a warning should be generated?
     813                 :             : 
     814                 :             :    Returns code to be executed if initialization could not be performed
     815                 :             :    for static variable.  In that case, caller must emit the code.  */
     816                 :             : 
     817                 :             : tree
     818                 :    32244846 : store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
     819                 :             : {
     820                 :    32244846 :   tree value, type;
     821                 :             : 
     822                 :             :   /* If variable's type was invalidly declared, just ignore it.  */
     823                 :             : 
     824                 :    32244846 :   type = TREE_TYPE (decl);
     825                 :    32244846 :   if (TREE_CODE (type) == ERROR_MARK)
     826                 :             :     return NULL_TREE;
     827                 :             : 
     828                 :     2024614 :   if (MAYBE_CLASS_TYPE_P (type))
     829                 :             :     {
     830                 :     1994121 :       if (TREE_CODE (init) == TREE_LIST)
     831                 :             :         {
     832                 :           0 :           error ("constructor syntax used, but no constructor declared "
     833                 :             :                  "for type %qT", type);
     834                 :           0 :           init = build_constructor_from_list (init_list_type_node, nreverse (init));
     835                 :             :         }
     836                 :             :     }
     837                 :             : 
     838                 :             :   /* End of special C++ code.  */
     839                 :             : 
     840                 :    32244846 :   if (flags & LOOKUP_ALREADY_DIGESTED)
     841                 :             :     value = init;
     842                 :             :   else
     843                 :             :     {
     844                 :    30889841 :       if (TREE_STATIC (decl))
     845                 :    14136480 :         flags |= LOOKUP_ALLOW_FLEXARRAY_INIT;
     846                 :             :       /* Digest the specified initializer into an expression.  */
     847                 :    30889841 :       value = digest_init_flags (type, init, flags, tf_warning_or_error);
     848                 :             :     }
     849                 :             : 
     850                 :             :   /* Look for braced array initializers for character arrays and
     851                 :             :      recursively convert them into STRING_CSTs.  */
     852                 :    32244846 :   value = braced_lists_to_strings (type, value);
     853                 :             : 
     854                 :    32244846 :   current_ref_temp_count = 0;
     855                 :    32244846 :   value = extend_ref_init_temps (decl, value, cleanups);
     856                 :             : 
     857                 :             :   /* In C++11 constant expression is a semantic, not syntactic, property.
     858                 :             :      In C++98, make sure that what we thought was a constant expression at
     859                 :             :      template definition time is still constant and otherwise perform this
     860                 :             :      as optimization, e.g. to fold SIZEOF_EXPRs in the initializer.  */
     861                 :    32244846 :   if (decl_maybe_constant_var_p (decl) || TREE_STATIC (decl))
     862                 :             :     {
     863                 :    17698204 :       bool const_init;
     864                 :    17698204 :       tree oldval = value;
     865                 :    17698204 :       if (DECL_DECLARED_CONSTEXPR_P (decl)
     866                 :     5043861 :           || DECL_DECLARED_CONSTINIT_P (decl)
     867                 :    22741930 :           || (DECL_IN_AGGR_P (decl)
     868                 :     1116260 :               && DECL_INITIALIZED_IN_CLASS_P (decl)))
     869                 :             :         {
     870                 :    13770611 :           value = fold_non_dependent_expr (value, tf_warning_or_error,
     871                 :             :                                            /*manifestly_const_eval=*/true,
     872                 :             :                                            decl);
     873                 :    13759827 :           if (value == error_mark_node)
     874                 :             :             ;
     875                 :             :           /* Diagnose a non-constant initializer for constexpr variable or
     876                 :             :              non-inline in-class-initialized static data member.  */
     877                 :    13759622 :           else if (!is_constant_expression (value))
     878                 :             :             {
     879                 :             :               /* Maybe we want to give this message for constexpr variables as
     880                 :             :                  well, but that will mean a lot of testsuite adjustment.  */
     881                 :         103 :               if (DECL_DECLARED_CONSTINIT_P (decl))
     882                 :          20 :               error_at (location_of (decl),
     883                 :             :                         "%<constinit%> variable %qD does not have a "
     884                 :             :                         "constant initializer", decl);
     885                 :         103 :               require_constant_expression (value);
     886                 :         103 :               value = error_mark_node;
     887                 :             :             }
     888                 :             :           else
     889                 :             :             {
     890                 :    13759519 :               value = maybe_constant_init (value, decl, true);
     891                 :             : 
     892                 :             :               /* In a template we might not have done the necessary
     893                 :             :                  transformations to make value actually constant,
     894                 :             :                  e.g. extend_ref_init_temps.  */
     895                 :    13759519 :               if (!processing_template_decl
     896                 :    13759519 :                   && !TREE_CONSTANT (value))
     897                 :             :                 {
     898                 :        1101 :                   if (DECL_DECLARED_CONSTINIT_P (decl))
     899                 :          18 :                   error_at (location_of (decl),
     900                 :             :                             "%<constinit%> variable %qD does not have a "
     901                 :             :                             "constant initializer", decl);
     902                 :        1101 :                   value = cxx_constant_init (value, decl);
     903                 :             :                 }
     904                 :             :             }
     905                 :             :         }
     906                 :             :       else
     907                 :     3927593 :         value = fold_non_dependent_init (value, tf_warning_or_error,
     908                 :             :                                          /*manifestly_const_eval=*/true, decl);
     909                 :    17687420 :       poison_mutable_constructors (value);
     910                 :    17687420 :       const_init = (reduced_constant_expression_p (value)
     911                 :    17687420 :                     || error_operand_p (value));
     912                 :    17687420 :       DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = const_init;
     913                 :             :       /* FIXME setting TREE_CONSTANT on refs breaks the back end.  */
     914                 :    17687420 :       if (!TYPE_REF_P (type))
     915                 :    19885117 :         TREE_CONSTANT (decl) = const_init && decl_maybe_constant_var_p (decl);
     916                 :    17687420 :       if (!const_init)
     917                 :    16414945 :         value = oldval;
     918                 :             :     }
     919                 :             :   /* Don't fold initializers of automatic variables in constexpr functions,
     920                 :             :      that might fold away something that needs to be diagnosed at constexpr
     921                 :             :      evaluation time.  */
     922                 :    32234062 :   if (!current_function_decl
     923                 :    18044020 :       || !DECL_DECLARED_CONSTEXPR_P (current_function_decl)
     924                 :    34935354 :       || TREE_STATIC (decl))
     925                 :    29532832 :     value = cp_fully_fold_init (value);
     926                 :             : 
     927                 :             :   /* Handle aggregate NSDMI in non-constant initializers, too.  */
     928                 :    32234062 :   value = replace_placeholders (value, decl);
     929                 :             : 
     930                 :             :   /* A COMPOUND_LITERAL_P CONSTRUCTOR is the syntactic form; by the time we get
     931                 :             :      here it should have been digested into an actual value for the type.  */
     932                 :    32234062 :   gcc_checking_assert (TREE_CODE (value) != CONSTRUCTOR
     933                 :             :                        || processing_template_decl
     934                 :             :                        || VECTOR_TYPE_P (type)
     935                 :             :                        || !TREE_HAS_CONSTRUCTOR (value));
     936                 :             : 
     937                 :             :   /* If the initializer is not a constant, fill in DECL_INITIAL with
     938                 :             :      the bits that are constant, and then return an expression that
     939                 :             :      will perform the dynamic initialization.  */
     940                 :    32234062 :   if (value != error_mark_node
     941                 :    32229947 :       && !processing_template_decl
     942                 :    62815816 :       && (TREE_SIDE_EFFECTS (value)
     943                 :    25335799 :           || vla_type_p (type)
     944                 :    25335690 :           || ! reduced_constant_expression_p (value)))
     945                 :    12018455 :     return split_nonconstant_init (decl, value);
     946                 :             : 
     947                 :             :   /* DECL may change value; purge caches.  */
     948                 :    20215607 :   clear_cv_and_fold_caches ();
     949                 :             : 
     950                 :             :   /* If the value is a constant, just put it in DECL_INITIAL.  If DECL
     951                 :             :      is an automatic variable, the middle end will turn this into a
     952                 :             :      dynamic initialization later.  */
     953                 :    20215607 :   DECL_INITIAL (decl) = value;
     954                 :    20215607 :   return NULL_TREE;
     955                 :             : }
     956                 :             : 
     957                 :             : 
     958                 :             : /* Give diagnostic about narrowing conversions within { }, or as part of
     959                 :             :    a converted constant expression.  If CONST_ONLY, only check
     960                 :             :    constants.  */
     961                 :             : 
     962                 :             : bool
     963                 :    13059063 : check_narrowing (tree type, tree init, tsubst_flags_t complain,
     964                 :             :                  bool const_only/*= false*/)
     965                 :             : {
     966                 :    13059063 :   tree ftype = unlowered_expr_type (init);
     967                 :    13059063 :   bool ok = true;
     968                 :    13059063 :   REAL_VALUE_TYPE d;
     969                 :             : 
     970                 :    13015870 :   if (((!warn_narrowing || !(complain & tf_warning))
     971                 :     2318042 :        && cxx_dialect == cxx98)
     972                 :    13017167 :       || !ARITHMETIC_TYPE_P (type)
     973                 :             :       /* Don't emit bogus warnings with e.g. value-dependent trees.  */
     974                 :    25961818 :       || instantiation_dependent_expression_p (init))
     975                 :      224058 :     return ok;
     976                 :             : 
     977                 :          12 :   if (BRACE_ENCLOSED_INITIALIZER_P (init)
     978                 :    12835005 :       && TREE_CODE (type) == COMPLEX_TYPE)
     979                 :             :     {
     980                 :           0 :       tree elttype = TREE_TYPE (type);
     981                 :           0 :       if (CONSTRUCTOR_NELTS (init) > 0)
     982                 :           0 :         ok &= check_narrowing (elttype, CONSTRUCTOR_ELT (init, 0)->value,
     983                 :             :                                complain);
     984                 :           0 :       if (CONSTRUCTOR_NELTS (init) > 1)
     985                 :           0 :         ok &= check_narrowing (elttype, CONSTRUCTOR_ELT (init, 1)->value,
     986                 :             :                                complain);
     987                 :           0 :       return ok;
     988                 :             :     }
     989                 :             : 
     990                 :             :   /* Even non-dependent expressions can still have template
     991                 :             :      codes like CAST_EXPR, so use *_non_dependent_expr to cope.  */
     992                 :    12835005 :   init = fold_non_dependent_expr (init, complain, /*manifest*/true);
     993                 :    12835005 :   if (init == error_mark_node)
     994                 :             :     return ok;
     995                 :             : 
     996                 :             :   /* If we were asked to only check constants, return early.  */
     997                 :    12835002 :   if (const_only && !TREE_CONSTANT (init))
     998                 :             :     return ok;
     999                 :             : 
    1000                 :    12833390 :   if (CP_INTEGRAL_TYPE_P (type)
    1001                 :    12824559 :       && SCALAR_FLOAT_TYPE_P (ftype))
    1002                 :             :     ok = false;
    1003                 :    12833153 :   else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
    1004                 :    12782098 :            && CP_INTEGRAL_TYPE_P (type))
    1005                 :             :     {
    1006                 :    12779974 :       if (TREE_CODE (ftype) == ENUMERAL_TYPE)
    1007                 :             :         /* Check for narrowing based on the values of the enumeration. */
    1008                 :      824882 :         ftype = ENUM_UNDERLYING_TYPE (ftype);
    1009                 :    12779974 :       if ((tree_int_cst_lt (TYPE_MAX_VALUE (type),
    1010                 :    12779974 :                             TYPE_MAX_VALUE (ftype))
    1011                 :    12535450 :            || tree_int_cst_lt (TYPE_MIN_VALUE (ftype),
    1012                 :    12535450 :                                TYPE_MIN_VALUE (type)))
    1013                 :    23586778 :           && (TREE_CODE (init) != INTEGER_CST
    1014                 :    11051192 :               || !int_fits_type_p (init, type)))
    1015                 :             :         ok = false;
    1016                 :             :     }
    1017                 :             :   /* [dcl.init.list]#7.2: "from long double to double or float, or from
    1018                 :             :       double to float".  */
    1019                 :       53179 :   else if (SCALAR_FLOAT_TYPE_P (ftype)
    1020                 :        6707 :            && SCALAR_FLOAT_TYPE_P (type))
    1021                 :             :     {
    1022                 :       13390 :       if ((extended_float_type_p (ftype) || extended_float_type_p (type))
    1023                 :        6695 :           ? /* "from a floating-point type T to another floating-point type
    1024                 :             :                whose floating-point conversion rank is neither greater than
    1025                 :             :                nor equal to that of T".
    1026                 :             :                So, it is ok if
    1027                 :             :                cp_compare_floating_point_conversion_ranks (ftype, type)
    1028                 :             :                returns -2 (type has greater conversion rank than ftype)
    1029                 :             :                or [-1..1] (type has equal conversion rank as ftype, possibly
    1030                 :             :                different subrank.  Only do this if at least one of the
    1031                 :             :                types is extended floating-point type, otherwise keep doing
    1032                 :             :                what we did before (for the sake of non-standard
    1033                 :             :                backend types).  */
    1034                 :          52 :             cp_compare_floating_point_conversion_ranks (ftype, type) >= 2
    1035                 :        6643 :           : ((same_type_p (ftype, long_double_type_node)
    1036                 :         140 :               && (same_type_p (type, double_type_node)
    1037                 :         131 :                   || same_type_p (type, float_type_node)))
    1038                 :        6634 :              || (same_type_p (ftype, double_type_node)
    1039                 :        6016 :                  && same_type_p (type, float_type_node))
    1040                 :        8022 :              || (TYPE_PRECISION (type) < TYPE_PRECISION (ftype))))
    1041                 :             :         {
    1042                 :        5272 :           if (TREE_CODE (init) == REAL_CST)
    1043                 :             :             {
    1044                 :             :               /* Issue 703: Loss of precision is OK as long as the value is
    1045                 :             :                  within the representable range of the new type.  */
    1046                 :        5250 :               REAL_VALUE_TYPE r;
    1047                 :        5250 :               d = TREE_REAL_CST (init);
    1048                 :        5250 :               real_convert (&r, TYPE_MODE (type), &d);
    1049                 :        5250 :               if (real_isinf (&r))
    1050                 :           0 :                 ok = false;
    1051                 :             :             }
    1052                 :             :           else
    1053                 :             :             ok = false;
    1054                 :             :         }
    1055                 :             :     }
    1056                 :       46484 :   else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
    1057                 :        2124 :            && SCALAR_FLOAT_TYPE_P (type))
    1058                 :             :     {
    1059                 :        2089 :       ok = false;
    1060                 :        2089 :       if (TREE_CODE (init) == INTEGER_CST)
    1061                 :             :         {
    1062                 :        2049 :           d = real_value_from_int_cst (0, init);
    1063                 :        2049 :           if (exact_real_truncate (TYPE_MODE (type), &d))
    1064                 :        3392 :             ok = true;
    1065                 :             :         }
    1066                 :             :     }
    1067                 :       44395 :   else if (TREE_CODE (type) == BOOLEAN_TYPE
    1068                 :       44395 :            && (TYPE_PTR_P (ftype) || TYPE_PTRMEM_P (ftype)))
    1069                 :             :     /* C++20 P1957R2: converting from a pointer type or a pointer-to-member
    1070                 :             :        type to bool should be considered narrowing.  This is a DR so is not
    1071                 :             :        limited to C++20 only.  */
    1072                 :             :     ok = false;
    1073                 :             : 
    1074                 :    12833390 :   bool almost_ok = ok;
    1075                 :    12833390 :   if (!ok && !CONSTANT_CLASS_P (init) && (complain & tf_warning_or_error))
    1076                 :             :     {
    1077                 :         179 :       tree folded = cp_fully_fold (init);
    1078                 :         179 :       if (TREE_CONSTANT (folded) && check_narrowing (type, folded, tf_none))
    1079                 :             :         almost_ok = true;
    1080                 :             :     }
    1081                 :             : 
    1082                 :    12833390 :   if (!ok)
    1083                 :             :     {
    1084                 :         869 :       location_t loc = cp_expr_loc_or_input_loc (init);
    1085                 :         869 :       if (cxx_dialect == cxx98)
    1086                 :             :         {
    1087                 :           1 :           if (complain & tf_warning)
    1088                 :           1 :             warning_at (loc, OPT_Wnarrowing, "narrowing conversion of %qE "
    1089                 :             :                         "from %qH to %qI is ill-formed in C++11",
    1090                 :             :                         init, ftype, type);
    1091                 :             :           ok = true;
    1092                 :             :         }
    1093                 :         868 :       else if (!CONSTANT_CLASS_P (init))
    1094                 :             :         {
    1095                 :         256 :           if (complain & tf_warning_or_error)
    1096                 :             :             {
    1097                 :         179 :               auto_diagnostic_group d;
    1098                 :           6 :               if ((!almost_ok || pedantic)
    1099                 :         179 :                   && pedwarn (loc, OPT_Wnarrowing,
    1100                 :             :                               "narrowing conversion of %qE from %qH to %qI",
    1101                 :             :                               init, ftype, type)
    1102                 :         341 :                   && almost_ok)
    1103                 :           3 :                 inform (loc, " the expression has a constant value but is not "
    1104                 :             :                         "a C++ constant-expression");
    1105                 :         179 :               ok = true;
    1106                 :         179 :             }
    1107                 :             :         }
    1108                 :         612 :       else if (complain & tf_error)
    1109                 :             :         {
    1110                 :         604 :           int savederrorcount = errorcount;
    1111                 :         604 :           permerror_opt (loc, OPT_Wnarrowing,
    1112                 :             :                          "narrowing conversion of %qE from %qH to %qI",
    1113                 :             :                          init, ftype, type);
    1114                 :         604 :           if (errorcount == savederrorcount)
    1115                 :    13058462 :             ok = true;
    1116                 :             :         }
    1117                 :             :     }
    1118                 :             : 
    1119                 :             :   return ok;
    1120                 :             : }
    1121                 :             : 
    1122                 :             : /* True iff TYPE is a C++20 "ordinary" character type.  */
    1123                 :             : 
    1124                 :             : bool
    1125                 :       37847 : ordinary_char_type_p (tree type)
    1126                 :             : {
    1127                 :       37847 :   type = TYPE_MAIN_VARIANT (type);
    1128                 :       37847 :   return (type == char_type_node
    1129                 :       18973 :           || type == signed_char_type_node
    1130                 :       56800 :           || type == unsigned_char_type_node);
    1131                 :             : }
    1132                 :             : 
    1133                 :             : /* True iff the string literal INIT has a type suitable for initializing array
    1134                 :             :    TYPE.  */
    1135                 :             : 
    1136                 :             : bool
    1137                 :      531772 : array_string_literal_compatible_p (tree type, tree init)
    1138                 :             : {
    1139                 :      531772 :   tree to_char_type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
    1140                 :      531772 :   tree from_char_type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (init)));
    1141                 :             : 
    1142                 :      531772 :   if (to_char_type == from_char_type)
    1143                 :             :     return true;
    1144                 :             :   /* The array element type does not match the initializing string
    1145                 :             :      literal element type; this is only allowed when both types are
    1146                 :             :      ordinary character type.  There are no string literals of
    1147                 :             :      signed or unsigned char type in the language, but we can get
    1148                 :             :      them internally from converting braced-init-lists to
    1149                 :             :      STRING_CST.  */
    1150                 :       18967 :   if (ordinary_char_type_p (to_char_type)
    1151                 :       18967 :       && ordinary_char_type_p (from_char_type))
    1152                 :             :     return true;
    1153                 :             : 
    1154                 :             :   /* P2513 (C++20/C++23): "an array of char or unsigned char may
    1155                 :             :      be initialized by a UTF-8 string literal, or by such a string
    1156                 :             :      literal enclosed in braces."  */
    1157                 :         119 :   if (from_char_type == char8_type_node
    1158                 :          20 :       && (to_char_type == char_type_node
    1159                 :          15 :           || to_char_type == unsigned_char_type_node))
    1160                 :             :     return true;
    1161                 :             : 
    1162                 :             :   return false;
    1163                 :             : }
    1164                 :             : 
    1165                 :             : /* Process the initializer INIT for a variable of type TYPE, emitting
    1166                 :             :    diagnostics for invalid initializers and converting the initializer as
    1167                 :             :    appropriate.
    1168                 :             : 
    1169                 :             :    For aggregate types, it assumes that reshape_init has already run, thus the
    1170                 :             :    initializer will have the right shape (brace elision has been undone).
    1171                 :             : 
    1172                 :             :    NESTED is non-zero iff we are being called for an element of a CONSTRUCTOR,
    1173                 :             :    2 iff the element of a CONSTRUCTOR is inside another CONSTRUCTOR.  */
    1174                 :             : 
    1175                 :             : static tree
    1176                 :    50048693 : digest_init_r (tree type, tree init, int nested, int flags,
    1177                 :             :                tsubst_flags_t complain)
    1178                 :             : {
    1179                 :    50048693 :   enum tree_code code = TREE_CODE (type);
    1180                 :             : 
    1181                 :    50048693 :   if (error_operand_p (init))
    1182                 :        1832 :     return error_mark_node;
    1183                 :             : 
    1184                 :    50046861 :   gcc_assert (init);
    1185                 :             : 
    1186                 :             :   /* We must strip the outermost array type when completing the type,
    1187                 :             :      because the its bounds might be incomplete at the moment.  */
    1188                 :    50857178 :   if (!complete_type_or_maybe_complain (code == ARRAY_TYPE
    1189                 :      810317 :                                         ? TREE_TYPE (type) : type, NULL_TREE,
    1190                 :             :                                         complain))
    1191                 :          23 :     return error_mark_node;
    1192                 :             : 
    1193                 :    50046838 :   location_t loc = cp_expr_loc_or_input_loc (init);
    1194                 :             : 
    1195                 :    50046838 :   tree stripped_init = init;
    1196                 :             : 
    1197                 :     7387753 :   if (BRACE_ENCLOSED_INITIALIZER_P (init)
    1198                 :    57431095 :       && CONSTRUCTOR_IS_PAREN_INIT (init))
    1199                 :         820 :     flags |= LOOKUP_AGGREGATE_PAREN_INIT;
    1200                 :             : 
    1201                 :             :   /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue
    1202                 :             :      (g++.old-deja/g++.law/casts2.C).  */
    1203                 :    50046838 :   if (TREE_CODE (init) == NON_LVALUE_EXPR)
    1204                 :    11096633 :     stripped_init = TREE_OPERAND (init, 0);
    1205                 :             : 
    1206                 :    50046838 :   stripped_init = tree_strip_any_location_wrapper (stripped_init);
    1207                 :             : 
    1208                 :             :   /* Initialization of an array of chars from a string constant. The initializer
    1209                 :             :      can be optionally enclosed in braces, but reshape_init has already removed
    1210                 :             :      them if they were present.  */
    1211                 :    50046838 :   if (code == ARRAY_TYPE)
    1212                 :             :     {
    1213                 :      934513 :       if (nested && !TYPE_DOMAIN (type))
    1214                 :             :         /* C++ flexible array members have a null domain.  */
    1215                 :             :         {
    1216                 :         540 :           if (flags & LOOKUP_ALLOW_FLEXARRAY_INIT)
    1217                 :         479 :             pedwarn (loc, OPT_Wpedantic,
    1218                 :             :                      "initialization of a flexible array member");
    1219                 :             :           else
    1220                 :             :             {
    1221                 :          61 :               if (complain & tf_error)
    1222                 :          61 :                 error_at (loc, "non-static initialization of"
    1223                 :             :                                " a flexible array member");
    1224                 :          61 :               return error_mark_node;
    1225                 :             :             }
    1226                 :             :         }
    1227                 :             : 
    1228                 :      810256 :       tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
    1229                 :      810256 :       if (char_type_p (typ1)
    1230                 :      810256 :           && TREE_CODE (stripped_init) == STRING_CST)
    1231                 :             :         {
    1232                 :      531733 :           if (!array_string_literal_compatible_p (type, init))
    1233                 :             :             {
    1234                 :         105 :               if (complain & tf_error)
    1235                 :         105 :                 error_at (loc, "cannot initialize array of %qT from "
    1236                 :             :                           "a string literal with type array of %qT",
    1237                 :             :                           typ1,
    1238                 :         105 :                           TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (init))));
    1239                 :         105 :               return error_mark_node;
    1240                 :             :             }
    1241                 :             : 
    1242                 :      531826 :           if (nested == 2 && !TYPE_DOMAIN (type))
    1243                 :             :             {
    1244                 :          33 :               if (complain & tf_error)
    1245                 :          33 :                 error_at (loc, "initialization of flexible array member "
    1246                 :             :                                "in a nested context");
    1247                 :          33 :               return error_mark_node;
    1248                 :             :             }
    1249                 :             : 
    1250                 :      531595 :           if (type != TREE_TYPE (init)
    1251                 :      531595 :               && !variably_modified_type_p (type, NULL_TREE))
    1252                 :             :             {
    1253                 :       20702 :               init = copy_node (init);
    1254                 :       20702 :               TREE_TYPE (init) = type;
    1255                 :             :               /* If we have a location wrapper, then also copy the wrapped
    1256                 :             :                  node, and update the copy's type.  */
    1257                 :       20702 :               if (location_wrapper_p (init))
    1258                 :             :                 {
    1259                 :       20369 :                   stripped_init = copy_node (stripped_init);
    1260                 :       20369 :                   TREE_OPERAND (init, 0) = stripped_init;
    1261                 :       20369 :                   TREE_TYPE (stripped_init) = type;
    1262                 :             :                 }
    1263                 :             :             }
    1264                 :      531595 :           if (TYPE_DOMAIN (type) && TREE_CONSTANT (TYPE_SIZE (type)))
    1265                 :             :             {
    1266                 :             :               /* Not a flexible array member.  */
    1267                 :      531506 :               int size = TREE_INT_CST_LOW (TYPE_SIZE (type));
    1268                 :      531506 :               size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
    1269                 :             :               /* In C it is ok to subtract 1 from the length of the string
    1270                 :             :                  because it's ok to ignore the terminating null char that is
    1271                 :             :                  counted in the length of the constant, but in C++ this would
    1272                 :             :                  be invalid.  */
    1273                 :      531506 :               if (size < TREE_STRING_LENGTH (stripped_init))
    1274                 :             :                 {
    1275                 :         176 :                   permerror (loc, "initializer-string for %qT is too long",
    1276                 :             :                              type);
    1277                 :             : 
    1278                 :         176 :                   init = build_string (size,
    1279                 :         176 :                                        TREE_STRING_POINTER (stripped_init));
    1280                 :         176 :                   TREE_TYPE (init) = type;
    1281                 :             :                 }
    1282                 :             :             }
    1283                 :      531595 :           return init;
    1284                 :             :         }
    1285                 :             :     }
    1286                 :             : 
    1287                 :             :   /* Handle scalar types (including conversions) and references.  */
    1288                 :        1080 :   if ((code != COMPLEX_TYPE || BRACE_ENCLOSED_INITIALIZER_P (stripped_init))
    1289                 :    49515091 :       && (SCALAR_TYPE_P (type) || code == REFERENCE_TYPE))
    1290                 :             :     {
    1291                 :             :       /* Narrowing is OK when initializing an aggregate from
    1292                 :             :          a parenthesized list.  */
    1293                 :    42261034 :       if (nested && !(flags & LOOKUP_AGGREGATE_PAREN_INIT))
    1294                 :    12411030 :         flags |= LOOKUP_NO_NARROWING;
    1295                 :    42261034 :       init = convert_for_initialization (0, type, init, flags,
    1296                 :             :                                          ICR_INIT, NULL_TREE, 0,
    1297                 :             :                                          complain);
    1298                 :             : 
    1299                 :    42261034 :       return init;
    1300                 :             :     }
    1301                 :             : 
    1302                 :             :   /* Come here only for aggregates: records, arrays, unions, complex numbers
    1303                 :             :      and vectors.  */
    1304                 :     7254010 :   gcc_assert (code == ARRAY_TYPE
    1305                 :             :               || VECTOR_TYPE_P (type)
    1306                 :             :               || code == RECORD_TYPE
    1307                 :             :               || code == UNION_TYPE
    1308                 :             :               || code == OPAQUE_TYPE
    1309                 :             :               || code == COMPLEX_TYPE);
    1310                 :             : 
    1311                 :             :   /* "If T is a class type and the initializer list has a single
    1312                 :             :      element of type cv U, where U is T or a class derived from T,
    1313                 :             :      the object is initialized from that element."  */
    1314                 :     7254010 :   if (cxx_dialect >= cxx11
    1315                 :     7227508 :       && BRACE_ENCLOSED_INITIALIZER_P (stripped_init)
    1316                 :     7019709 :       && !CONSTRUCTOR_IS_DESIGNATED_INIT (stripped_init)
    1317                 :     6789759 :       && CONSTRUCTOR_NELTS (stripped_init) == 1
    1318                 :     7614434 :       && ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type))
    1319                 :       36054 :           || VECTOR_TYPE_P (type)))
    1320                 :             :     {
    1321                 :      324603 :       tree elt = CONSTRUCTOR_ELT (stripped_init, 0)->value;
    1322                 :      324603 :       if (reference_related_p (type, TREE_TYPE (elt)))
    1323                 :             :         {
    1324                 :             :           /* In C++17, aggregates can have bases, thus participate in
    1325                 :             :              aggregate initialization.  In the following case:
    1326                 :             : 
    1327                 :             :                struct B { int c; };
    1328                 :             :                struct D : B { };
    1329                 :             :                D d{{D{{42}}}};
    1330                 :             : 
    1331                 :             :             there's an extra set of braces, so the D temporary initializes
    1332                 :             :             the first element of d, which is the B base subobject.  The base
    1333                 :             :             of type B is copy-initialized from the D temporary, causing
    1334                 :             :             object slicing.  */
    1335                 :          20 :           tree field = next_aggregate_field (TYPE_FIELDS (type));
    1336                 :          40 :           if (field && DECL_FIELD_IS_BASE (field))
    1337                 :             :             {
    1338                 :          20 :               if (warning_at (loc, 0, "initializing a base class of type %qT "
    1339                 :          20 :                               "results in object slicing", TREE_TYPE (field)))
    1340                 :          20 :                 inform (loc, "remove %<{ }%> around initializer");
    1341                 :             :             }
    1342                 :           0 :           else if (flag_checking)
    1343                 :             :             /* We should have fixed this in reshape_init.  */
    1344                 :           0 :             gcc_unreachable ();
    1345                 :             :         }
    1346                 :             :     }
    1347                 :             : 
    1348                 :     7254010 :   if (SIMPLE_TARGET_EXPR_P (stripped_init))
    1349                 :        7749 :     stripped_init = TARGET_EXPR_INITIAL (stripped_init);
    1350                 :             : 
    1351                 :     7039142 :   if (BRACE_ENCLOSED_INITIALIZER_P (stripped_init)
    1352                 :    14288869 :       && !TYPE_NON_AGGREGATE_CLASS (type))
    1353                 :     6754549 :     return process_init_constructor (type, stripped_init, nested, flags,
    1354                 :     6754549 :                                      complain);
    1355                 :             :   else
    1356                 :             :     {
    1357                 :      499461 :       if (COMPOUND_LITERAL_P (stripped_init) && code == ARRAY_TYPE)
    1358                 :             :         {
    1359                 :           0 :           if (complain & tf_error)
    1360                 :           0 :             error_at (loc, "cannot initialize aggregate of type %qT with "
    1361                 :             :                       "a compound literal", type);
    1362                 :             : 
    1363                 :           0 :           return error_mark_node;
    1364                 :             :         }
    1365                 :             : 
    1366                 :      499461 :       if (code == ARRAY_TYPE
    1367                 :      499461 :           && !BRACE_ENCLOSED_INITIALIZER_P (stripped_init))
    1368                 :             :         {
    1369                 :             :           /* Allow the result of build_array_copy and of
    1370                 :             :              build_value_init_noctor.  */
    1371                 :          87 :           if ((TREE_CODE (stripped_init) == VEC_INIT_EXPR
    1372                 :          68 :                || TREE_CODE (stripped_init) == CONSTRUCTOR)
    1373                 :         134 :               && (same_type_ignoring_top_level_qualifiers_p
    1374                 :          47 :                   (type, TREE_TYPE (init))))
    1375                 :             :             return init;
    1376                 :             : 
    1377                 :          52 :           if (complain & tf_error)
    1378                 :          52 :             error_at (loc, "array must be initialized with a brace-enclosed"
    1379                 :             :                       " initializer");
    1380                 :          52 :           return error_mark_node;
    1381                 :             :         }
    1382                 :             : 
    1383                 :      499374 :       return convert_for_initialization (NULL_TREE, type, init,
    1384                 :             :                                          flags,
    1385                 :             :                                          ICR_INIT, NULL_TREE, 0,
    1386                 :      499374 :                                          complain);
    1387                 :             :     }
    1388                 :             : }
    1389                 :             : 
    1390                 :             : tree
    1391                 :     1025401 : digest_init (tree type, tree init, tsubst_flags_t complain)
    1392                 :             : {
    1393                 :     1025401 :   return digest_init_r (type, init, 0, LOOKUP_IMPLICIT, complain);
    1394                 :             : }
    1395                 :             : 
    1396                 :             : tree
    1397                 :    34661567 : digest_init_flags (tree type, tree init, int flags, tsubst_flags_t complain)
    1398                 :             : {
    1399                 :    34661567 :   return digest_init_r (type, init, 0, flags, complain);
    1400                 :             : }
    1401                 :             : 
    1402                 :             : /* Callback to replace PLACEHOLDER_EXPRs in a TARGET_EXPR (which isn't used
    1403                 :             :    in the context of guaranteed copy elision).  */
    1404                 :             : 
    1405                 :             : static tree
    1406                 :     2799166 : replace_placeholders_for_class_temp_r (tree *tp, int *, void *data)
    1407                 :             : {
    1408                 :     2799166 :   tree t = *tp;
    1409                 :     2799166 :   auto pset = static_cast<hash_set<tree> *>(data);
    1410                 :             : 
    1411                 :             :   /* We're looking for a TARGET_EXPR nested in the whole expression.  */
    1412                 :     2799166 :   if (TREE_CODE (t) == TARGET_EXPR
    1413                 :             :       /* That serves as temporary materialization, not an initializer.  */
    1414                 :       22425 :       && !TARGET_EXPR_ELIDING_P (t)
    1415                 :     2799569 :       && !pset->add (t))
    1416                 :             :     {
    1417                 :         348 :       tree init = TARGET_EXPR_INITIAL (t);
    1418                 :         351 :       while (TREE_CODE (init) == COMPOUND_EXPR)
    1419                 :           3 :         init = TREE_OPERAND (init, 1);
    1420                 :         348 :       if (TREE_CODE (init) == CONSTRUCTOR
    1421                 :         348 :           && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init))
    1422                 :             :         {
    1423                 :          99 :           tree obj = TARGET_EXPR_SLOT (t);
    1424                 :          99 :           replace_placeholders (init, obj);
    1425                 :             :           /* We should have dealt with all PLACEHOLDER_EXPRs.  */
    1426                 :          99 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = false;
    1427                 :          99 :           gcc_checking_assert (!find_placeholders (init));
    1428                 :             :         }
    1429                 :             :     }
    1430                 :             :   /* TARGET_EXPRs initializing function arguments are not marked as eliding,
    1431                 :             :      even though gimplify_arg drops them on the floor.  Don't go replacing
    1432                 :             :      placeholders in them.  */
    1433                 :     2798818 :   else if (TREE_CODE (t) == CALL_EXPR || TREE_CODE (t) == AGGR_INIT_EXPR)
    1434                 :       63463 :     for (int i = 0; i < call_expr_nargs (t); ++i)
    1435                 :             :       {
    1436                 :       41796 :         tree arg = get_nth_callarg (t, i);
    1437                 :       41796 :         if (TREE_CODE (arg) == TARGET_EXPR && !TARGET_EXPR_ELIDING_P (arg))
    1438                 :          55 :           pset->add (arg);
    1439                 :             :       }
    1440                 :             : 
    1441                 :     2799166 :   return NULL_TREE;
    1442                 :             : }
    1443                 :             : 
    1444                 :             : /* Process the initializer INIT for an NSDMI DECL (a FIELD_DECL).  */
    1445                 :             : tree
    1446                 :      418482 : digest_nsdmi_init (tree decl, tree init, tsubst_flags_t complain)
    1447                 :             : {
    1448                 :      418482 :   gcc_assert (TREE_CODE (decl) == FIELD_DECL);
    1449                 :             : 
    1450                 :      418482 :   tree type = TREE_TYPE (decl);
    1451                 :      418482 :   if (DECL_BIT_FIELD_TYPE (decl))
    1452                 :        2718 :     type = DECL_BIT_FIELD_TYPE (decl);
    1453                 :      418482 :   int flags = LOOKUP_IMPLICIT;
    1454                 :      418482 :   if (DIRECT_LIST_INIT_P (init))
    1455                 :             :     {
    1456                 :       42279 :       flags = LOOKUP_NORMAL;
    1457                 :       42279 :       complain |= tf_no_cleanup;
    1458                 :             :     }
    1459                 :      154744 :   if (BRACE_ENCLOSED_INITIALIZER_P (init)
    1460                 :      573226 :       && CP_AGGREGATE_TYPE_P (type))
    1461                 :      124436 :     init = reshape_init (type, init, complain);
    1462                 :      418482 :   init = digest_init_flags (type, init, flags, complain);
    1463                 :      418482 :   set_target_expr_eliding (init);
    1464                 :             : 
    1465                 :             :   /* We may have temporary materialization in a NSDMI, if the initializer
    1466                 :             :      has something like A{} in it.  Digesting the {} could have introduced
    1467                 :             :      a PLACEHOLDER_EXPR referring to A.  Now that we've got a TARGET_EXPR,
    1468                 :             :      we have an object we can refer to.  The reason we bother doing this
    1469                 :             :      here is for code like
    1470                 :             : 
    1471                 :             :        struct A {
    1472                 :             :          int x;
    1473                 :             :          int y = x;
    1474                 :             :        };
    1475                 :             : 
    1476                 :             :        struct B {
    1477                 :             :          int x = 0;
    1478                 :             :          int y = A{x}.y; // #1
    1479                 :             :        };
    1480                 :             : 
    1481                 :             :      where in #1 we don't want to end up with two PLACEHOLDER_EXPRs for
    1482                 :             :      different types on the same level in a {} when lookup_placeholder
    1483                 :             :      wouldn't find a named object for the PLACEHOLDER_EXPR for A.  Note,
    1484                 :             :      temporary materialization does not occur when initializing an object
    1485                 :             :      from a prvalue of the same type, therefore we must not replace the
    1486                 :             :      placeholder with a temporary object so that it can be elided.  */
    1487                 :      418482 :   hash_set<tree> pset;
    1488                 :      418482 :   cp_walk_tree (&init, replace_placeholders_for_class_temp_r, &pset, nullptr);
    1489                 :             : 
    1490                 :      418482 :   return init;
    1491                 :      418482 : }
    1492                 :             : 
    1493                 :             : /* Set of flags used within process_init_constructor to describe the
    1494                 :             :    initializers.  */
    1495                 :             : #define PICFLAG_ERRONEOUS 1
    1496                 :             : #define PICFLAG_NOT_ALL_CONSTANT 2
    1497                 :             : #define PICFLAG_NOT_ALL_SIMPLE 4
    1498                 :             : #define PICFLAG_SIDE_EFFECTS 8
    1499                 :             : #define PICFLAG_VEC_INIT 16
    1500                 :             : 
    1501                 :             : /* Given an initializer INIT, return the flag (PICFLAG_*) which better
    1502                 :             :    describe it.  */
    1503                 :             : 
    1504                 :             : static int
    1505                 :    14797491 : picflag_from_initializer (tree init)
    1506                 :             : {
    1507                 :    14797491 :   if (init == error_mark_node)
    1508                 :             :     return PICFLAG_ERRONEOUS;
    1509                 :    14797075 :   else if (!TREE_CONSTANT (init))
    1510                 :             :     {
    1511                 :     1122228 :       if (TREE_SIDE_EFFECTS (init))
    1512                 :             :         return PICFLAG_SIDE_EFFECTS;
    1513                 :             :       else
    1514                 :     1054829 :         return PICFLAG_NOT_ALL_CONSTANT;
    1515                 :             :     }
    1516                 :    13674847 :   else if (!initializer_constant_valid_p (init, TREE_TYPE (init)))
    1517                 :       12083 :     return PICFLAG_NOT_ALL_SIMPLE;
    1518                 :             :   return 0;
    1519                 :             : }
    1520                 :             : 
    1521                 :             : /* Adjust INIT for going into a CONSTRUCTOR.  */
    1522                 :             : 
    1523                 :             : static tree
    1524                 :    14361725 : massage_init_elt (tree type, tree init, int nested, int flags,
    1525                 :             :                   tsubst_flags_t complain)
    1526                 :             : {
    1527                 :    14361725 :   int new_flags = LOOKUP_IMPLICIT;
    1528                 :    14361725 :   if (flags & LOOKUP_ALLOW_FLEXARRAY_INIT)
    1529                 :    10962035 :     new_flags |= LOOKUP_ALLOW_FLEXARRAY_INIT;
    1530                 :    14361725 :   if (flags & LOOKUP_AGGREGATE_PAREN_INIT)
    1531                 :        1214 :     new_flags |= LOOKUP_AGGREGATE_PAREN_INIT;
    1532                 :    24865439 :   init = digest_init_r (type, init, nested ? 2 : 1, new_flags, complain);
    1533                 :             :   /* When we defer constant folding within a statement, we may want to
    1534                 :             :      defer this folding as well.  Don't call this on CONSTRUCTORs because
    1535                 :             :      their elements have already been folded, and we must avoid folding
    1536                 :             :      the result of get_nsdmi.  */
    1537                 :    14361725 :   if (TREE_CODE (init) != CONSTRUCTOR)
    1538                 :             :     {
    1539                 :    12710082 :       tree t = fold_non_dependent_init (init, complain);
    1540                 :    12710082 :       if (TREE_CONSTANT (t))
    1541                 :    11577624 :         init = t;
    1542                 :    12710082 :       set_target_expr_eliding (init);
    1543                 :             :     }
    1544                 :    14361725 :   return init;
    1545                 :             : }
    1546                 :             : 
    1547                 :             : /* Subroutine of process_init_constructor, which will process an initializer
    1548                 :             :    INIT for an array or vector of type TYPE. Returns the flags (PICFLAG_*)
    1549                 :             :    which describe the initializers.  */
    1550                 :             : 
    1551                 :             : static int
    1552                 :      319941 : process_init_constructor_array (tree type, tree init, int nested, int flags,
    1553                 :             :                                 tsubst_flags_t complain)
    1554                 :             : {
    1555                 :      319941 :   unsigned HOST_WIDE_INT i, len = 0;
    1556                 :      319941 :   int picflags = 0;
    1557                 :      319941 :   bool unbounded = false;
    1558                 :      319941 :   constructor_elt *ce;
    1559                 :      319941 :   vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (init);
    1560                 :             : 
    1561                 :      319941 :   gcc_assert (TREE_CODE (type) == ARRAY_TYPE
    1562                 :             :               || VECTOR_TYPE_P (type));
    1563                 :             : 
    1564                 :      319941 :   if (TREE_CODE (type) == ARRAY_TYPE)
    1565                 :             :     {
    1566                 :             :       /* C++ flexible array members have a null domain.  */
    1567                 :      278436 :       tree domain = TYPE_DOMAIN (type);
    1568                 :      278436 :       if (domain && TREE_CONSTANT (TYPE_MAX_VALUE (domain)))
    1569                 :      555912 :         len = wi::ext (wi::to_offset (TYPE_MAX_VALUE (domain))
    1570                 :      555912 :                        - wi::to_offset (TYPE_MIN_VALUE (domain)) + 1,
    1571                 :      277956 :                        TYPE_PRECISION (TREE_TYPE (domain)),
    1572                 :      555912 :                        TYPE_SIGN (TREE_TYPE (domain))).to_uhwi ();
    1573                 :             :       else
    1574                 :             :         unbounded = true;  /* Take as many as there are.  */
    1575                 :             : 
    1576                 :      278436 :       if (nested == 2 && !domain && !vec_safe_is_empty (v))
    1577                 :             :         {
    1578                 :          95 :           if (complain & tf_error)
    1579                 :         190 :             error_at (cp_expr_loc_or_input_loc (init),
    1580                 :             :                       "initialization of flexible array member "
    1581                 :             :                       "in a nested context");
    1582                 :          95 :           return PICFLAG_ERRONEOUS;
    1583                 :             :         }
    1584                 :             :     }
    1585                 :             :   else
    1586                 :             :     /* Vectors are like simple fixed-size arrays.  */
    1587                 :       41505 :     unbounded = !TYPE_VECTOR_SUBPARTS (type).is_constant (&len);
    1588                 :             : 
    1589                 :             :   /* There must not be more initializers than needed.  */
    1590                 :      319846 :   if (!unbounded && vec_safe_length (v) > len)
    1591                 :             :     {
    1592                 :           5 :       if (complain & tf_error)
    1593                 :           5 :         error ("too many initializers for %qT", type);
    1594                 :             :       else
    1595                 :             :         return PICFLAG_ERRONEOUS;
    1596                 :             :     }
    1597                 :             : 
    1598                 :     9007036 :   FOR_EACH_VEC_SAFE_ELT (v, i, ce)
    1599                 :             :     {
    1600                 :     8687190 :       if (!ce->index)
    1601                 :         224 :         ce->index = size_int (i);
    1602                 :     8686966 :       else if (!check_array_designated_initializer (ce, i))
    1603                 :           0 :         ce->index = error_mark_node;
    1604                 :     8687190 :       gcc_assert (ce->value);
    1605                 :     8687190 :       ce->value
    1606                 :     8687190 :         = massage_init_elt (TREE_TYPE (type), ce->value, nested, flags,
    1607                 :             :                             complain);
    1608                 :             : 
    1609                 :     8687190 :       gcc_checking_assert
    1610                 :             :         (ce->value == error_mark_node
    1611                 :             :          || (same_type_ignoring_top_level_qualifiers_p
    1612                 :             :              (strip_array_types (TREE_TYPE (type)),
    1613                 :             :               strip_array_types (TREE_TYPE (ce->value)))));
    1614                 :             : 
    1615                 :     8687190 :       picflags |= picflag_from_initializer (ce->value);
    1616                 :             :       /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer
    1617                 :             :          CONSTRUCTOR.  */
    1618                 :     8687190 :       if (TREE_CODE (ce->value) == CONSTRUCTOR
    1619                 :     8687190 :           && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value))
    1620                 :             :         {
    1621                 :          21 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    1622                 :          21 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value) = 0;
    1623                 :             :         }
    1624                 :             :     }
    1625                 :             : 
    1626                 :             :   /* No more initializers. If the array is unbounded, we are done. Otherwise,
    1627                 :             :      we must add initializers ourselves.  */
    1628                 :      319846 :   if (!unbounded)
    1629                 :      319509 :     for (; i < len; ++i)
    1630                 :             :       {
    1631                 :       19996 :         tree next;
    1632                 :             : 
    1633                 :       19996 :         if (type_build_ctor_call (TREE_TYPE (type)))
    1634                 :             :           {
    1635                 :             :             /* If this type needs constructors run for default-initialization,
    1636                 :             :                we can't rely on the back end to do it for us, so make the
    1637                 :             :                initialization explicit by list-initializing from T{}.  */
    1638                 :         291 :             next = build_constructor (init_list_type_node, NULL);
    1639                 :         291 :             next = massage_init_elt (TREE_TYPE (type), next, nested, flags,
    1640                 :             :                                      complain);
    1641                 :         291 :             if (initializer_zerop (next))
    1642                 :             :               /* The default zero-initialization is fine for us; don't
    1643                 :             :                  add anything to the CONSTRUCTOR.  */
    1644                 :             :               next = NULL_TREE;
    1645                 :             :           }
    1646                 :       19705 :         else if (!zero_init_p (TREE_TYPE (type)))
    1647                 :          68 :           next = build_zero_init (TREE_TYPE (type),
    1648                 :             :                                   /*nelts=*/NULL_TREE,
    1649                 :             :                                   /*static_storage_p=*/false);
    1650                 :             :         else
    1651                 :             :           /* The default zero-initialization is fine for us; don't
    1652                 :             :              add anything to the CONSTRUCTOR.  */
    1653                 :             :           next = NULL_TREE;
    1654                 :             : 
    1655                 :         220 :         if (next)
    1656                 :             :           {
    1657                 :         220 :             if (next != error_mark_node
    1658                 :         220 :                 && (initializer_constant_valid_p (next, TREE_TYPE (next))
    1659                 :         208 :                     != null_pointer_node))
    1660                 :             :               {
    1661                 :             :                 /* Use VEC_INIT_EXPR for non-constant initialization of
    1662                 :             :                    trailing elements with no explicit initializers.  */
    1663                 :         130 :                 picflags |= PICFLAG_VEC_INIT;
    1664                 :         130 :                 break;
    1665                 :             :               }
    1666                 :             : 
    1667                 :          90 :             picflags |= picflag_from_initializer (next);
    1668                 :             :             /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer
    1669                 :             :                CONSTRUCTOR.  */
    1670                 :          90 :             if (TREE_CODE (next) == CONSTRUCTOR
    1671                 :          90 :                 && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next))
    1672                 :             :               {
    1673                 :           0 :                 CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    1674                 :           0 :                 CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next) = 0;
    1675                 :             :               }
    1676                 :          90 :             if (len > i+1)
    1677                 :             :               {
    1678                 :          42 :                 tree range = build2 (RANGE_EXPR, size_type_node,
    1679                 :             :                                      build_int_cst (size_type_node, i),
    1680                 :          42 :                                      build_int_cst (size_type_node, len - 1));
    1681                 :          42 :                 CONSTRUCTOR_APPEND_ELT (v, range, next);
    1682                 :          42 :                 break;
    1683                 :             :               }
    1684                 :             :             else
    1685                 :          48 :               CONSTRUCTOR_APPEND_ELT (v, size_int (i), next);
    1686                 :             :           }
    1687                 :             :         else
    1688                 :             :           /* Don't bother checking all the other elements.  */
    1689                 :             :           break;
    1690                 :             :       }
    1691                 :             : 
    1692                 :      319846 :   CONSTRUCTOR_ELTS (init) = v;
    1693                 :      319846 :   return picflags;
    1694                 :             : }
    1695                 :             : 
    1696                 :             : /* Subroutine of process_init_constructor, which will process an initializer
    1697                 :             :    INIT for a class of type TYPE. Returns the flags (PICFLAG_*) which describe
    1698                 :             :    the initializers.  */
    1699                 :             : 
    1700                 :             : static int
    1701                 :     6318514 : process_init_constructor_record (tree type, tree init, int nested, int flags,
    1702                 :             :                                  tsubst_flags_t complain)
    1703                 :             : {
    1704                 :     6318514 :   vec<constructor_elt, va_gc> *v = NULL;
    1705                 :     6318514 :   tree field;
    1706                 :     6318514 :   int skipped = 0;
    1707                 :             : 
    1708                 :     6318514 :   gcc_assert (TREE_CODE (type) == RECORD_TYPE);
    1709                 :     6318514 :   gcc_assert (!CLASSTYPE_VBASECLASSES (type));
    1710                 :     6318514 :   gcc_assert (!TYPE_BINFO (type)
    1711                 :             :               || cxx_dialect >= cxx17
    1712                 :             :               || !BINFO_N_BASE_BINFOS (TYPE_BINFO (type)));
    1713                 :     6318514 :   gcc_assert (!TYPE_POLYMORPHIC_P (type));
    1714                 :             : 
    1715                 :     6318514 :  restart:
    1716                 :     6351667 :   int picflags = 0;
    1717                 :     6351667 :   unsigned HOST_WIDE_INT idx = 0;
    1718                 :     6351667 :   int designator_skip = -1;
    1719                 :             :   /* Generally, we will always have an index for each initializer (which is
    1720                 :             :      a FIELD_DECL, put by reshape_init), but compound literals don't go trough
    1721                 :             :      reshape_init. So we need to handle both cases.  */
    1722                 :    58812136 :   for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    1723                 :             :     {
    1724                 :    52494152 :       tree next;
    1725                 :             : 
    1726                 :    97988226 :       if (TREE_CODE (field) != FIELD_DECL
    1727                 :    52494152 :           || (DECL_ARTIFICIAL (field)
    1728                 :      377476 :               && !(cxx_dialect >= cxx17 && DECL_FIELD_IS_BASE (field))))
    1729                 :    45494074 :         continue;
    1730                 :             : 
    1731                 :     7000078 :       if (DECL_UNNAMED_BIT_FIELD (field))
    1732                 :          95 :         continue;
    1733                 :             : 
    1734                 :             :       /* If this is a bitfield, first convert to the declared type.  */
    1735                 :     6999983 :       tree fldtype = TREE_TYPE (field);
    1736                 :     6999983 :       if (DECL_BIT_FIELD_TYPE (field))
    1737                 :      662396 :         fldtype = DECL_BIT_FIELD_TYPE (field);
    1738                 :     6999983 :       if (fldtype == error_mark_node)
    1739                 :             :         return PICFLAG_ERRONEOUS;
    1740                 :             : 
    1741                 :     6999967 :       next = NULL_TREE;
    1742                 :    12566730 :       if (idx < CONSTRUCTOR_NELTS (init))
    1743                 :             :         {
    1744                 :     5564981 :           constructor_elt *ce = &(*CONSTRUCTOR_ELTS (init))[idx];
    1745                 :     5564981 :           if (ce->index)
    1746                 :             :             {
    1747                 :             :               /* We can have either a FIELD_DECL or an IDENTIFIER_NODE. The
    1748                 :             :                  latter case can happen in templates where lookup has to be
    1749                 :             :                  deferred.  */
    1750                 :     5564002 :               gcc_assert (TREE_CODE (ce->index) == FIELD_DECL
    1751                 :             :                           || identifier_p (ce->index));
    1752                 :     5564002 :               if (ce->index == field || ce->index == DECL_NAME (field))
    1753                 :     5563895 :                 next = ce->value;
    1754                 :             :               else
    1755                 :             :                 {
    1756                 :         107 :                   ce = NULL;
    1757                 :         107 :                   if (designator_skip == -1)
    1758                 :          88 :                     designator_skip = 1;
    1759                 :             :                 }
    1760                 :             :             }
    1761                 :             :           else
    1762                 :             :             {
    1763                 :         979 :               designator_skip = 0;
    1764                 :         979 :               next = ce->value;
    1765                 :             :             }
    1766                 :             : 
    1767                 :     5564981 :           if (ce)
    1768                 :             :             {
    1769                 :     5564874 :               gcc_assert (ce->value);
    1770                 :     5564874 :               next = massage_init_elt (fldtype, next, nested, flags, complain);
    1771                 :             :               /* We can't actually elide the temporary when initializing a
    1772                 :             :                  potentially-overlapping field from a function that returns by
    1773                 :             :                  value.  */
    1774                 :     5564874 :               if (ce->index
    1775                 :     5563895 :                   && TREE_CODE (next) == TARGET_EXPR
    1776                 :     5593224 :                   && unsafe_copy_elision_p (ce->index, next))
    1777                 :          10 :                 TARGET_EXPR_ELIDING_P (next) = false;
    1778                 :     5564874 :               ++idx;
    1779                 :             :             }
    1780                 :             :         }
    1781                 :     6999967 :       if (next == error_mark_node)
    1782                 :             :         /* We skip initializers for empty bases/fields, so skipping an invalid
    1783                 :             :            one could make us accept invalid code.  */
    1784                 :             :         return PICFLAG_ERRONEOUS;
    1785                 :     6999453 :       else if (next)
    1786                 :             :         /* Already handled above.  */;
    1787                 :     1435093 :       else if (DECL_INITIAL (field))
    1788                 :             :         {
    1789                 :       72845 :           if (skipped > 0)
    1790                 :             :             {
    1791                 :             :               /* We're using an NSDMI past a field with implicit
    1792                 :             :                  zero-init.  Go back and make it explicit.  */
    1793                 :       33153 :               skipped = -1;
    1794                 :       33153 :               vec_safe_truncate (v, 0);
    1795                 :       33153 :               goto restart;
    1796                 :             :             }
    1797                 :             :           /* C++14 aggregate NSDMI.  */
    1798                 :       39692 :           next = get_nsdmi (field, /*ctor*/false, complain);
    1799                 :       39692 :           if (!CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init)
    1800                 :       39692 :               && find_placeholders (next))
    1801                 :         837 :             CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    1802                 :             :         }
    1803                 :     1362248 :       else if (type_build_ctor_call (fldtype))
    1804                 :             :         {
    1805                 :             :           /* If this type needs constructors run for
    1806                 :             :              default-initialization, we can't rely on the back end to do it
    1807                 :             :              for us, so build up TARGET_EXPRs.  If the type in question is
    1808                 :             :              a class, just build one up; if it's an array, recurse.  */
    1809                 :        2751 :           next = build_constructor (init_list_type_node, NULL);
    1810                 :        2751 :           next = massage_init_elt (fldtype, next, nested, flags, complain);
    1811                 :        2751 :           if (TREE_CODE (next) == TARGET_EXPR
    1812                 :        2751 :               && unsafe_copy_elision_p (field, next))
    1813                 :           0 :             TARGET_EXPR_ELIDING_P (next) = false;
    1814                 :             : 
    1815                 :             :           /* Warn when some struct elements are implicitly initialized.  */
    1816                 :        2751 :           if ((complain & tf_warning)
    1817                 :        2641 :               && !cp_unevaluated_operand
    1818                 :        5368 :               && !EMPTY_CONSTRUCTOR_P (init))
    1819                 :          26 :             warning (OPT_Wmissing_field_initializers,
    1820                 :             :                      "missing initializer for member %qD", field);
    1821                 :             :         }
    1822                 :             :       else
    1823                 :             :         {
    1824                 :     1359497 :           if (TYPE_REF_P (fldtype))
    1825                 :             :             {
    1826                 :          23 :               if (complain & tf_error)
    1827                 :          23 :                 error ("member %qD is uninitialized reference", field);
    1828                 :             :               else
    1829                 :             :                 return PICFLAG_ERRONEOUS;
    1830                 :             :             }
    1831                 :     1359474 :           else if (CLASSTYPE_REF_FIELDS_NEED_INIT (fldtype))
    1832                 :             :             {
    1833                 :           1 :               if (complain & tf_error)
    1834                 :           1 :                 error ("member %qD with uninitialized reference fields", field);
    1835                 :             :               else
    1836                 :             :                 return PICFLAG_ERRONEOUS;
    1837                 :             :             }
    1838                 :             :           /* Do nothing for flexible array members since they need not have any
    1839                 :             :              elements.  Don't worry about 'skipped' because a flexarray has to
    1840                 :             :              be the last field.  */
    1841                 :     1359473 :           else if (TREE_CODE (fldtype) == ARRAY_TYPE && !TYPE_DOMAIN (fldtype))
    1842                 :         137 :             continue;
    1843                 :             : 
    1844                 :             :           /* Warn when some struct elements are implicitly initialized
    1845                 :             :              to zero.  */
    1846                 :     1359360 :           if ((complain & tf_warning)
    1847                 :     1242995 :               && !cp_unevaluated_operand
    1848                 :     1242402 :               && !EMPTY_CONSTRUCTOR_P (init)
    1849                 :     1360407 :               && !is_really_empty_class (fldtype, /*ignore_vptr*/false))
    1850                 :         975 :             warning (OPT_Wmissing_field_initializers,
    1851                 :             :                      "missing initializer for member %qD", field);
    1852                 :             : 
    1853                 :     1359360 :           if (!zero_init_p (fldtype) || skipped < 0)
    1854                 :             :             {
    1855                 :      396929 :               if (TYPE_REF_P (fldtype))
    1856                 :           3 :                 next = build_zero_cst (fldtype);
    1857                 :             :               else
    1858                 :      396926 :                 next = build_zero_init (fldtype, /*nelts=*/NULL_TREE,
    1859                 :             :                                         /*static_storage_p=*/false);
    1860                 :             :             }
    1861                 :             :           else
    1862                 :             :             {
    1863                 :             :               /* The default zero-initialization is fine for us; don't
    1864                 :             :                  add anything to the CONSTRUCTOR.  */
    1865                 :      962431 :               skipped = 1;
    1866                 :      962431 :               continue;
    1867                 :             :             }
    1868                 :             :         }
    1869                 :             : 
    1870                 :     6003732 :       if (is_empty_field (field)
    1871                 :     6003732 :           && !TREE_SIDE_EFFECTS (next))
    1872                 :             :         /* Don't add trivial initialization of an empty base/field to the
    1873                 :             :            constructor, as they might not be ordered the way the back-end
    1874                 :             :            expects.  */
    1875                 :         141 :         continue;
    1876                 :             : 
    1877                 :             :       /* If this is a bitfield, now convert to the lowered type.  */
    1878                 :     6003591 :       if (fldtype != TREE_TYPE (field))
    1879                 :      331549 :         next = cp_convert_and_check (TREE_TYPE (field), next, complain);
    1880                 :     6003591 :       picflags |= picflag_from_initializer (next);
    1881                 :             :       /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer CONSTRUCTOR.  */
    1882                 :     6003591 :       if (TREE_CODE (next) == CONSTRUCTOR
    1883                 :     6003591 :           && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next))
    1884                 :             :         {
    1885                 :          69 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    1886                 :          69 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next) = 0;
    1887                 :             :         }
    1888                 :    58464060 :       CONSTRUCTOR_APPEND_ELT (v, field, next);
    1889                 :             :     }
    1890                 :             : 
    1891                 :     8874803 :   if (idx < CONSTRUCTOR_NELTS (init))
    1892                 :             :     {
    1893                 :          64 :       if (complain & tf_error)
    1894                 :             :         {
    1895                 :          23 :           constructor_elt *ce = &(*CONSTRUCTOR_ELTS (init))[idx];
    1896                 :             :           /* For better diagnostics, try to find out if it is really
    1897                 :             :              the case of too many initializers or if designators are
    1898                 :             :              in incorrect order.  */
    1899                 :          23 :           if (designator_skip == 1 && ce->index)
    1900                 :             :             {
    1901                 :          18 :               gcc_assert (TREE_CODE (ce->index) == FIELD_DECL
    1902                 :             :                           || identifier_p (ce->index));
    1903                 :          18 :               for (field = TYPE_FIELDS (type);
    1904                 :          75 :                    field; field = DECL_CHAIN (field))
    1905                 :             :                 {
    1906                 :         129 :                   if (TREE_CODE (field) != FIELD_DECL
    1907                 :          75 :                       || (DECL_ARTIFICIAL (field)
    1908                 :           0 :                           && !(cxx_dialect >= cxx17
    1909                 :           0 :                                && DECL_FIELD_IS_BASE (field))))
    1910                 :          54 :                     continue;
    1911                 :             : 
    1912                 :          21 :                   if (DECL_UNNAMED_BIT_FIELD (field))
    1913                 :           0 :                     continue;
    1914                 :             : 
    1915                 :          21 :                   if (ce->index == field || ce->index == DECL_NAME (field))
    1916                 :             :                     break;
    1917                 :             :                 }
    1918                 :             :             }
    1919                 :          23 :           if (field)
    1920                 :          18 :             error ("designator order for field %qD does not match declaration "
    1921                 :             :                    "order in %qT", field, type);
    1922                 :             :           else
    1923                 :           5 :             error ("too many initializers for %qT", type);
    1924                 :             :         }
    1925                 :             :       else
    1926                 :             :         return PICFLAG_ERRONEOUS;
    1927                 :             :     }
    1928                 :             : 
    1929                 :     6317943 :   CONSTRUCTOR_ELTS (init) = v;
    1930                 :     6317943 :   return picflags;
    1931                 :             : }
    1932                 :             : 
    1933                 :             : /* Subroutine of process_init_constructor, which will process a single
    1934                 :             :    initializer INIT for a union of type TYPE. Returns the flags (PICFLAG_*)
    1935                 :             :    which describe the initializer.  */
    1936                 :             : 
    1937                 :             : static int
    1938                 :      116094 : process_init_constructor_union (tree type, tree init, int nested, int flags,
    1939                 :             :                                 tsubst_flags_t complain)
    1940                 :             : {
    1941                 :      116094 :   constructor_elt *ce;
    1942                 :      116094 :   int len;
    1943                 :             : 
    1944                 :             :   /* If the initializer was empty, use the union's NSDMI if it has one.
    1945                 :             :      Otherwise use default zero initialization.  */
    1946                 :      116094 :   if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    1947                 :             :     {
    1948                 :      104347 :       for (tree field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    1949                 :             :         {
    1950                 :       94873 :           if (TREE_CODE (field) == FIELD_DECL
    1951                 :       94873 :               && DECL_INITIAL (field) != NULL_TREE)
    1952                 :             :             {
    1953                 :          26 :               tree val = get_nsdmi (field, /*in_ctor=*/false, complain);
    1954                 :          26 :               if (!CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init)
    1955                 :          26 :                   && find_placeholders (val))
    1956                 :          20 :                 CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    1957                 :          26 :               CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (init), field, val);
    1958                 :          26 :               break;
    1959                 :             :             }
    1960                 :             :         }
    1961                 :             : 
    1962                 :        9500 :       if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    1963                 :             :         return 0;
    1964                 :             :     }
    1965                 :             : 
    1966                 :      106620 :   len = CONSTRUCTOR_ELTS (init)->length ();
    1967                 :      106620 :   if (len > 1)
    1968                 :             :     {
    1969                 :           1 :       if (!(complain & tf_error))
    1970                 :             :         return PICFLAG_ERRONEOUS;
    1971                 :           1 :       error ("too many initializers for %qT", type);
    1972                 :           1 :       CONSTRUCTOR_ELTS (init)->block_remove (1, len-1);
    1973                 :             :     }
    1974                 :             : 
    1975                 :      106620 :   ce = &(*CONSTRUCTOR_ELTS (init))[0];
    1976                 :             : 
    1977                 :             :   /* If this element specifies a field, initialize via that field.  */
    1978                 :      106620 :   if (ce->index)
    1979                 :             :     {
    1980                 :      106616 :       if (TREE_CODE (ce->index) == FIELD_DECL)
    1981                 :             :         ;
    1982                 :           0 :       else if (identifier_p (ce->index))
    1983                 :             :         {
    1984                 :             :           /* This can happen within a cast, see g++.dg/opt/cse2.C.  */
    1985                 :           0 :           tree name = ce->index;
    1986                 :           0 :           tree field;
    1987                 :           0 :           for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    1988                 :           0 :             if (DECL_NAME (field) == name)
    1989                 :             :               break;
    1990                 :           0 :           if (!field)
    1991                 :             :             {
    1992                 :           0 :               if (complain & tf_error)
    1993                 :           0 :                 error ("no field %qD found in union being initialized",
    1994                 :             :                        field);
    1995                 :           0 :               ce->value = error_mark_node;
    1996                 :             :             }
    1997                 :           0 :           ce->index = field;
    1998                 :             :         }
    1999                 :             :       else
    2000                 :             :         {
    2001                 :           0 :           gcc_assert (TREE_CODE (ce->index) == INTEGER_CST
    2002                 :             :                       || TREE_CODE (ce->index) == RANGE_EXPR);
    2003                 :           0 :           if (complain & tf_error)
    2004                 :           0 :             error ("index value instead of field name in union initializer");
    2005                 :           0 :           ce->value = error_mark_node;
    2006                 :             :         }
    2007                 :             :     }
    2008                 :             :   else
    2009                 :             :     {
    2010                 :             :       /* Find the first named field.  ANSI decided in September 1990
    2011                 :             :          that only named fields count here.  */
    2012                 :           4 :       tree field = TYPE_FIELDS (type);
    2013                 :          44 :       while (field && (!DECL_NAME (field) || TREE_CODE (field) != FIELD_DECL))
    2014                 :          40 :         field = TREE_CHAIN (field);
    2015                 :           4 :       if (field == NULL_TREE)
    2016                 :             :         {
    2017                 :           1 :           if (complain & tf_error)
    2018                 :           1 :             error ("too many initializers for %qT", type);
    2019                 :           1 :           ce->value = error_mark_node;
    2020                 :             :         }
    2021                 :           4 :       ce->index = field;
    2022                 :             :     }
    2023                 :             : 
    2024                 :      106620 :   if (ce->value && ce->value != error_mark_node)
    2025                 :      106619 :     ce->value = massage_init_elt (TREE_TYPE (ce->index), ce->value, nested,
    2026                 :             :                                   flags, complain);
    2027                 :             : 
    2028                 :             :   /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer CONSTRUCTOR.  */
    2029                 :      106620 :   if (ce->value
    2030                 :      106620 :       && TREE_CODE (ce->value) == CONSTRUCTOR
    2031                 :      173645 :       && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value))
    2032                 :             :     {
    2033                 :           0 :       CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    2034                 :           0 :       CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value) = 0;
    2035                 :             :     }
    2036                 :      106620 :   return picflag_from_initializer (ce->value);
    2037                 :             : }
    2038                 :             : 
    2039                 :             : /* Process INIT, a constructor for a variable of aggregate type TYPE. The
    2040                 :             :    constructor is a brace-enclosed initializer, and will be modified in-place.
    2041                 :             : 
    2042                 :             :    Each element is converted to the right type through digest_init, and
    2043                 :             :    missing initializers are added following the language rules (zero-padding,
    2044                 :             :    etc.).
    2045                 :             : 
    2046                 :             :    After the execution, the initializer will have TREE_CONSTANT if all elts are
    2047                 :             :    constant, and TREE_STATIC set if, in addition, all elts are simple enough
    2048                 :             :    constants that the assembler and linker can compute them.
    2049                 :             : 
    2050                 :             :    The function returns the initializer itself, or error_mark_node in case
    2051                 :             :    of error.  */
    2052                 :             : 
    2053                 :             : static tree
    2054                 :     6754549 : process_init_constructor (tree type, tree init, int nested, int flags,
    2055                 :             :                           tsubst_flags_t complain)
    2056                 :             : {
    2057                 :     6754549 :   int picflags;
    2058                 :             : 
    2059                 :     6754549 :   gcc_assert (BRACE_ENCLOSED_INITIALIZER_P (init));
    2060                 :             : 
    2061                 :     6754549 :   if (TREE_CODE (type) == ARRAY_TYPE || VECTOR_TYPE_P (type))
    2062                 :      319941 :     picflags = process_init_constructor_array (type, init, nested, flags,
    2063                 :             :                                                complain);
    2064                 :     6434608 :   else if (TREE_CODE (type) == RECORD_TYPE)
    2065                 :     6318514 :     picflags = process_init_constructor_record (type, init, nested, flags,
    2066                 :             :                                                 complain);
    2067                 :      116094 :   else if (TREE_CODE (type) == UNION_TYPE)
    2068                 :      116094 :     picflags = process_init_constructor_union (type, init, nested, flags,
    2069                 :             :                                                complain);
    2070                 :             :   else
    2071                 :           0 :     gcc_unreachable ();
    2072                 :             : 
    2073                 :     6754549 :   if (picflags & PICFLAG_ERRONEOUS)
    2074                 :        1021 :     return error_mark_node;
    2075                 :             : 
    2076                 :     6753528 :   TREE_TYPE (init) = type;
    2077                 :     6753528 :   if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == NULL_TREE)
    2078                 :         314 :     cp_complete_array_type (&TREE_TYPE (init), init, /*do_default=*/0);
    2079                 :     6753528 :   if (picflags & PICFLAG_SIDE_EFFECTS)
    2080                 :             :     {
    2081                 :       48567 :       TREE_CONSTANT (init) = false;
    2082                 :       48567 :       TREE_SIDE_EFFECTS (init) = true;
    2083                 :             :     }
    2084                 :     6704961 :   else if (picflags & PICFLAG_NOT_ALL_CONSTANT)
    2085                 :             :     {
    2086                 :             :       /* Make sure TREE_CONSTANT isn't set from build_constructor.  */
    2087                 :      663583 :       TREE_CONSTANT (init) = false;
    2088                 :      663583 :       TREE_SIDE_EFFECTS (init) = false;
    2089                 :             :     }
    2090                 :             :   else
    2091                 :             :     {
    2092                 :     6041378 :       TREE_CONSTANT (init) = 1;
    2093                 :     6041378 :       TREE_SIDE_EFFECTS (init) = false;
    2094                 :     6041378 :       if (!(picflags & PICFLAG_NOT_ALL_SIMPLE))
    2095                 :     6029360 :         TREE_STATIC (init) = 1;
    2096                 :             :     }
    2097                 :     6753528 :   if (picflags & PICFLAG_VEC_INIT)
    2098                 :             :     {
    2099                 :             :       /* Defer default-initialization of array elements with no corresponding
    2100                 :             :          initializer-clause until later so we can use a loop.  */
    2101                 :         130 :       TREE_TYPE (init) = init_list_type_node;
    2102                 :         130 :       init = build_vec_init_expr (type, init, complain);
    2103                 :         130 :       init = get_target_expr (init);
    2104                 :             :     }
    2105                 :             :   return init;
    2106                 :             : }
    2107                 :             : 
    2108                 :             : /* Given a structure or union value DATUM, construct and return
    2109                 :             :    the structure or union component which results from narrowing
    2110                 :             :    that value to the base specified in BASETYPE.  For example, given the
    2111                 :             :    hierarchy
    2112                 :             : 
    2113                 :             :    class L { int ii; };
    2114                 :             :    class A : L { ... };
    2115                 :             :    class B : L { ... };
    2116                 :             :    class C : A, B { ... };
    2117                 :             : 
    2118                 :             :    and the declaration
    2119                 :             : 
    2120                 :             :    C x;
    2121                 :             : 
    2122                 :             :    then the expression
    2123                 :             : 
    2124                 :             :    x.A::ii refers to the ii member of the L part of
    2125                 :             :    the A part of the C object named by X.  In this case,
    2126                 :             :    DATUM would be x, and BASETYPE would be A.
    2127                 :             : 
    2128                 :             :    I used to think that this was nonconformant, that the standard specified
    2129                 :             :    that first we look up ii in A, then convert x to an L& and pull out the
    2130                 :             :    ii part.  But in fact, it does say that we convert x to an A&; A here
    2131                 :             :    is known as the "naming class".  (jason 2000-12-19)
    2132                 :             : 
    2133                 :             :    BINFO_P points to a variable initialized either to NULL_TREE or to the
    2134                 :             :    binfo for the specific base subobject we want to convert to.  */
    2135                 :             : 
    2136                 :             : tree
    2137                 :       23802 : build_scoped_ref (tree datum, tree basetype, tree* binfo_p)
    2138                 :             : {
    2139                 :       23802 :   tree binfo;
    2140                 :             : 
    2141                 :       23802 :   if (datum == error_mark_node)
    2142                 :             :     return error_mark_node;
    2143                 :       23802 :   if (*binfo_p)
    2144                 :             :     binfo = *binfo_p;
    2145                 :             :   else
    2146                 :       23802 :     binfo = lookup_base (TREE_TYPE (datum), basetype, ba_check,
    2147                 :             :                          NULL, tf_warning_or_error);
    2148                 :             : 
    2149                 :       23802 :   if (!binfo || binfo == error_mark_node)
    2150                 :             :     {
    2151                 :           8 :       *binfo_p = NULL_TREE;
    2152                 :           8 :       if (!binfo)
    2153                 :           0 :         error_not_base_type (basetype, TREE_TYPE (datum));
    2154                 :           8 :       return error_mark_node;
    2155                 :             :     }
    2156                 :             : 
    2157                 :       23794 :   *binfo_p = binfo;
    2158                 :       23794 :   return build_base_path (PLUS_EXPR, datum, binfo, 1,
    2159                 :       23794 :                           tf_warning_or_error);
    2160                 :             : }
    2161                 :             : 
    2162                 :             : /* Build a reference to an object specified by the C++ `->' operator.
    2163                 :             :    Usually this just involves dereferencing the object, but if the
    2164                 :             :    `->' operator is overloaded, then such overloads must be
    2165                 :             :    performed until an object which does not have the `->' operator
    2166                 :             :    overloaded is found.  An error is reported when circular pointer
    2167                 :             :    delegation is detected.  */
    2168                 :             : 
    2169                 :             : tree
    2170                 :    32020925 : build_x_arrow (location_t loc, tree expr, tsubst_flags_t complain)
    2171                 :             : {
    2172                 :    32020925 :   tree orig_expr = expr;
    2173                 :    32020925 :   tree type = TREE_TYPE (expr);
    2174                 :    32020925 :   tree last_rval = NULL_TREE;
    2175                 :    32020925 :   vec<tree, va_gc> *types_memoized = NULL;
    2176                 :             : 
    2177                 :    32020925 :   if (type == error_mark_node)
    2178                 :             :     return error_mark_node;
    2179                 :             : 
    2180                 :    32020866 :   if (processing_template_decl)
    2181                 :             :     {
    2182                 :    28237898 :       tree ttype = NULL_TREE;
    2183                 :    28237898 :       if (type && TYPE_PTR_P (type))
    2184                 :    25518385 :         ttype = TREE_TYPE (type);
    2185                 :    25518385 :       if (ttype && !dependent_scope_p (ttype))
    2186                 :             :         /* Pointer to current instantiation, don't treat as dependent.  */;
    2187                 :     7060214 :       else if (type_dependent_expression_p (expr))
    2188                 :             :         {
    2189                 :     6988715 :           expr = build_min_nt_loc (loc, ARROW_EXPR, expr);
    2190                 :     6988715 :           TREE_TYPE (expr) = ttype;
    2191                 :     6988715 :           return expr;
    2192                 :             :         }
    2193                 :             :     }
    2194                 :             : 
    2195                 :    25032151 :   if (MAYBE_CLASS_TYPE_P (type))
    2196                 :             :     {
    2197                 :      177937 :       struct tinst_level *actual_inst = current_instantiation ();
    2198                 :      177937 :       tree fn = NULL;
    2199                 :             : 
    2200                 :      359453 :       while ((expr = build_new_op (loc, COMPONENT_REF,
    2201                 :             :                                    LOOKUP_NORMAL, expr, NULL_TREE, NULL_TREE,
    2202                 :             :                                    NULL_TREE, &fn, complain)))
    2203                 :             :         {
    2204                 :      181532 :           if (expr == error_mark_node)
    2205                 :          24 :             return error_mark_node;
    2206                 :             : 
    2207                 :             :           /* This provides a better instantiation backtrace in case of
    2208                 :             :              error.  */
    2209                 :      181516 :           if (fn && DECL_USE_TEMPLATE (fn))
    2210                 :      152316 :             push_tinst_level_loc (fn, 
    2211                 :      148714 :                                   (current_instantiation () != actual_inst)
    2212                 :        3602 :                                   ? DECL_SOURCE_LOCATION (fn)
    2213                 :             :                                   : input_location);
    2214                 :      181516 :           fn = NULL;
    2215                 :             : 
    2216                 :      181516 :           if (vec_member (TREE_TYPE (expr), types_memoized))
    2217                 :             :             {
    2218                 :           0 :               if (complain & tf_error)
    2219                 :           0 :                 error ("circular pointer delegation detected");
    2220                 :           0 :               return error_mark_node;
    2221                 :             :             }
    2222                 :             : 
    2223                 :      181516 :           vec_safe_push (types_memoized, TREE_TYPE (expr));
    2224                 :      181516 :           last_rval = expr;
    2225                 :             :         }
    2226                 :             : 
    2227                 :      323031 :       while (current_instantiation () != actual_inst)
    2228                 :      145114 :         pop_tinst_level ();
    2229                 :             : 
    2230                 :      177917 :       if (last_rval == NULL_TREE)
    2231                 :             :         {
    2232                 :           8 :           if (complain & tf_error)
    2233                 :           8 :             error ("base operand of %<->%> has non-pointer type %qT", type);
    2234                 :           8 :           return error_mark_node;
    2235                 :             :         }
    2236                 :             : 
    2237                 :      177909 :       if (TYPE_REF_P (TREE_TYPE (last_rval)))
    2238                 :           0 :         last_rval = convert_from_reference (last_rval);
    2239                 :             :     }
    2240                 :             :   else
    2241                 :             :     {
    2242                 :    24854214 :       last_rval = decay_conversion (expr, complain);
    2243                 :    24854214 :       if (last_rval == error_mark_node)
    2244                 :             :         return error_mark_node;
    2245                 :             :     }
    2246                 :             : 
    2247                 :    25032119 :   if (TYPE_PTR_P (TREE_TYPE (last_rval)))
    2248                 :             :     {
    2249                 :    25032118 :       if (processing_template_decl)
    2250                 :             :         {
    2251                 :    21249182 :           expr = build_min (ARROW_EXPR, TREE_TYPE (TREE_TYPE (last_rval)),
    2252                 :             :                             orig_expr);
    2253                 :    21249182 :           TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (last_rval);
    2254                 :    21249182 :           return expr;
    2255                 :             :         }
    2256                 :             : 
    2257                 :     3782936 :       return cp_build_indirect_ref (loc, last_rval, RO_ARROW, complain);
    2258                 :             :     }
    2259                 :             : 
    2260                 :           1 :   if (complain & tf_error)
    2261                 :             :     {
    2262                 :           1 :       if (types_memoized)
    2263                 :           0 :         error ("result of %<operator->()%> yields non-pointer result");
    2264                 :             :       else
    2265                 :           1 :         error ("base operand of %<->%> is not a pointer");
    2266                 :             :     }
    2267                 :           1 :   return error_mark_node;
    2268                 :             : }
    2269                 :             : 
    2270                 :             : /* Return an expression for "DATUM .* COMPONENT".  DATUM has not
    2271                 :             :    already been checked out to be of aggregate type.  */
    2272                 :             : 
    2273                 :             : tree
    2274                 :      105825 : build_m_component_ref (tree datum, tree component, tsubst_flags_t complain)
    2275                 :             : {
    2276                 :      105825 :   tree ptrmem_type;
    2277                 :      105825 :   tree objtype;
    2278                 :      105825 :   tree type;
    2279                 :      105825 :   tree binfo;
    2280                 :      105825 :   tree ctype;
    2281                 :             : 
    2282                 :      105825 :   datum = mark_lvalue_use (datum);
    2283                 :      105825 :   component = mark_rvalue_use (component);
    2284                 :             : 
    2285                 :      105825 :   if (error_operand_p (datum) || error_operand_p (component))
    2286                 :          54 :     return error_mark_node;
    2287                 :             : 
    2288                 :      105771 :   ptrmem_type = TREE_TYPE (component);
    2289                 :      105771 :   if (!TYPE_PTRMEM_P (ptrmem_type))
    2290                 :             :     {
    2291                 :           7 :       if (complain & tf_error)
    2292                 :           4 :         error ("%qE cannot be used as a member pointer, since it is of "
    2293                 :             :                "type %qT", component, ptrmem_type);
    2294                 :           7 :       return error_mark_node;
    2295                 :             :     }
    2296                 :             : 
    2297                 :      105764 :   objtype = TYPE_MAIN_VARIANT (TREE_TYPE (datum));
    2298                 :      105764 :   if (! MAYBE_CLASS_TYPE_P (objtype))
    2299                 :             :     {
    2300                 :           0 :       if (complain & tf_error)
    2301                 :           0 :         error ("cannot apply member pointer %qE to %qE, which is of "
    2302                 :             :                "non-class type %qT", component, datum, objtype);
    2303                 :           0 :       return error_mark_node;
    2304                 :             :     }
    2305                 :             : 
    2306                 :      105764 :   type = TYPE_PTRMEM_POINTED_TO_TYPE (ptrmem_type);
    2307                 :      105764 :   ctype = complete_type (TYPE_PTRMEM_CLASS_TYPE (ptrmem_type));
    2308                 :             : 
    2309                 :      105764 :   if (!COMPLETE_TYPE_P (ctype))
    2310                 :             :     {
    2311                 :          94 :       if (!same_type_p (ctype, objtype))
    2312                 :           0 :         goto mismatch;
    2313                 :             :       binfo = NULL;
    2314                 :             :     }
    2315                 :             :   else
    2316                 :             :     {
    2317                 :      105670 :       binfo = lookup_base (objtype, ctype, ba_check, NULL, complain);
    2318                 :             : 
    2319                 :      105670 :       if (!binfo)
    2320                 :             :         {
    2321                 :           3 :         mismatch:
    2322                 :           3 :           if (complain & tf_error)
    2323                 :           0 :             error ("pointer to member type %qT incompatible with object "
    2324                 :             :                    "type %qT", type, objtype);
    2325                 :           3 :           return error_mark_node;
    2326                 :             :         }
    2327                 :      105667 :       else if (binfo == error_mark_node)
    2328                 :             :         return error_mark_node;
    2329                 :             :     }
    2330                 :             : 
    2331                 :      105755 :   if (TYPE_PTRDATAMEM_P (ptrmem_type))
    2332                 :             :     {
    2333                 :        1122 :       bool is_lval = real_lvalue_p (datum);
    2334                 :        1122 :       tree ptype;
    2335                 :             : 
    2336                 :             :       /* Compute the type of the field, as described in [expr.ref].
    2337                 :             :          There's no such thing as a mutable pointer-to-member, so
    2338                 :             :          things are not as complex as they are for references to
    2339                 :             :          non-static data members.  */
    2340                 :        1122 :       type = cp_build_qualified_type (type,
    2341                 :        1122 :                                       (cp_type_quals (type)
    2342                 :        1122 :                                        | cp_type_quals (TREE_TYPE (datum))));
    2343                 :             : 
    2344                 :        1122 :       datum = build_address (datum);
    2345                 :             : 
    2346                 :             :       /* Convert object to the correct base.  */
    2347                 :        1122 :       if (binfo)
    2348                 :             :         {
    2349                 :        1094 :           datum = build_base_path (PLUS_EXPR, datum, binfo, 1, complain);
    2350                 :        1094 :           if (datum == error_mark_node)
    2351                 :             :             return error_mark_node;
    2352                 :             :         }
    2353                 :             : 
    2354                 :             :       /* Build an expression for "object + offset" where offset is the
    2355                 :             :          value stored in the pointer-to-data-member.  */
    2356                 :        1122 :       ptype = build_pointer_type (type);
    2357                 :        1122 :       datum = convert (ptype, datum);
    2358                 :        1122 :       if (!processing_template_decl)
    2359                 :        1096 :         datum = build2 (POINTER_PLUS_EXPR, ptype,
    2360                 :             :                         datum, convert_to_ptrofftype (component));
    2361                 :        1122 :       datum = cp_fully_fold (datum);
    2362                 :        1122 :       datum = cp_build_fold_indirect_ref (datum);
    2363                 :        1122 :       if (datum == error_mark_node)
    2364                 :             :         return error_mark_node;
    2365                 :             : 
    2366                 :             :       /* If the object expression was an rvalue, return an rvalue.  */
    2367                 :        1122 :       if (!is_lval)
    2368                 :          37 :         datum = move (datum);
    2369                 :        1122 :       return datum;
    2370                 :             :     }
    2371                 :             :   else
    2372                 :             :     {
    2373                 :             :       /* 5.5/6: In a .* expression whose object expression is an rvalue, the
    2374                 :             :          program is ill-formed if the second operand is a pointer to member
    2375                 :             :          function with ref-qualifier & (for C++20: unless its cv-qualifier-seq
    2376                 :             :          is const). In a .* expression whose object expression is an lvalue,
    2377                 :             :          the program is ill-formed if the second operand is a pointer to member
    2378                 :             :          function with ref-qualifier &&.  */
    2379                 :      104633 :       if (FUNCTION_REF_QUALIFIED (type))
    2380                 :             :         {
    2381                 :         116 :           bool lval = lvalue_p (datum);
    2382                 :         116 :           if (lval && FUNCTION_RVALUE_QUALIFIED (type))
    2383                 :             :             {
    2384                 :           9 :               if (complain & tf_error)
    2385                 :           6 :                 error ("pointer-to-member-function type %qT requires an rvalue",
    2386                 :             :                        ptrmem_type);
    2387                 :           9 :               return error_mark_node;
    2388                 :             :             }
    2389                 :         107 :           else if (!lval && !FUNCTION_RVALUE_QUALIFIED (type))
    2390                 :             :             {
    2391                 :          33 :               if ((type_memfn_quals (type)
    2392                 :          33 :                    & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))
    2393                 :             :                   != TYPE_QUAL_CONST)
    2394                 :             :                 {
    2395                 :          27 :                   if (complain & tf_error)
    2396                 :          24 :                     error ("pointer-to-member-function type %qT requires "
    2397                 :             :                            "an lvalue", ptrmem_type);
    2398                 :          27 :                   return error_mark_node;
    2399                 :             :                 }
    2400                 :           6 :               else if (cxx_dialect < cxx20)
    2401                 :             :                 {
    2402                 :           4 :                   if (complain & tf_warning_or_error)
    2403                 :           4 :                     pedwarn (input_location, OPT_Wpedantic,
    2404                 :             :                              "pointer-to-member-function type %qT requires "
    2405                 :             :                              "an lvalue before C++20", ptrmem_type);
    2406                 :             :                   else
    2407                 :           0 :                     return error_mark_node;
    2408                 :             :                 }
    2409                 :             :             }
    2410                 :             :         }
    2411                 :      104597 :       return build2 (OFFSET_REF, type, datum, component);
    2412                 :             :     }
    2413                 :             : }
    2414                 :             : 
    2415                 :             : /* Return a tree node for the expression TYPENAME '(' PARMS ')'.  */
    2416                 :             : 
    2417                 :             : static tree
    2418                 :    61749032 : build_functional_cast_1 (location_t loc, tree exp, tree parms,
    2419                 :             :                          tsubst_flags_t complain)
    2420                 :             : {
    2421                 :             :   /* This is either a call to a constructor,
    2422                 :             :      or a C cast in C++'s `functional' notation.  */
    2423                 :             : 
    2424                 :             :   /* The type to which we are casting.  */
    2425                 :    61749032 :   tree type;
    2426                 :             : 
    2427                 :    61749032 :   if (error_operand_p (exp) || parms == error_mark_node)
    2428                 :        1352 :     return error_mark_node;
    2429                 :             : 
    2430                 :    61747680 :   if (TREE_CODE (exp) == TYPE_DECL)
    2431                 :             :     {
    2432                 :    35059991 :       type = TREE_TYPE (exp);
    2433                 :             : 
    2434                 :    35059991 :       if (DECL_ARTIFICIAL (exp))
    2435                 :    23434658 :         cp_handle_deprecated_or_unavailable (type);
    2436                 :             :     }
    2437                 :             :   else
    2438                 :             :     type = exp;
    2439                 :             : 
    2440                 :             :   /* We need to check this explicitly, since value-initialization of
    2441                 :             :      arrays is allowed in other situations.  */
    2442                 :    61747680 :   if (TREE_CODE (type) == ARRAY_TYPE)
    2443                 :             :     {
    2444                 :          14 :       if (complain & tf_error)
    2445                 :           8 :         error_at (loc, "functional cast to array type %qT", type);
    2446                 :          14 :       return error_mark_node;
    2447                 :             :     }
    2448                 :             : 
    2449                 :    61747666 :   if (tree anode = type_uses_auto (type))
    2450                 :             :     {
    2451                 :      143701 :       tree init;
    2452                 :      143701 :       if (CLASS_PLACEHOLDER_TEMPLATE (anode))
    2453                 :             :         init = parms;
    2454                 :             :       /* C++23 auto(x).  */
    2455                 :        3480 :       else if (!AUTO_IS_DECLTYPE (anode)
    2456                 :        3480 :                && list_length (parms) == 1)
    2457                 :             :         {
    2458                 :        3469 :           init = TREE_VALUE (parms);
    2459                 :        3469 :           if (is_constrained_auto (anode))
    2460                 :             :             {
    2461                 :           2 :               if (complain & tf_error)
    2462                 :           2 :                 error_at (loc, "%<auto(x)%> cannot be constrained");
    2463                 :           2 :               return error_mark_node;
    2464                 :             :             }
    2465                 :        3467 :           else if (cxx_dialect < cxx23)
    2466                 :          16 :             pedwarn (loc, OPT_Wc__23_extensions,
    2467                 :             :                      "%<auto(x)%> only available with "
    2468                 :             :                      "%<-std=c++2b%> or %<-std=gnu++2b%>");
    2469                 :             :         }
    2470                 :             :       else
    2471                 :             :         {
    2472                 :          11 :           if (complain & tf_error)
    2473                 :          11 :             error_at (loc, "invalid use of %qT", anode);
    2474                 :          11 :           return error_mark_node;
    2475                 :             :         }
    2476                 :      143688 :       type = do_auto_deduction (type, init, anode, complain,
    2477                 :             :                                 adc_variable_type);
    2478                 :      143688 :       if (type == error_mark_node)
    2479                 :             :         return error_mark_node;
    2480                 :             :     }
    2481                 :             : 
    2482                 :    61747552 :   if (processing_template_decl)
    2483                 :             :     {
    2484                 :    33403212 :       tree t;
    2485                 :             : 
    2486                 :             :       /* Diagnose this even in a template.  We could also try harder
    2487                 :             :          to give all the usual errors when the type and args are
    2488                 :             :          non-dependent...  */
    2489                 :    33403212 :       if (TYPE_REF_P (type) && !parms)
    2490                 :             :         {
    2491                 :           4 :           if (complain & tf_error)
    2492                 :           4 :             error_at (loc, "invalid value-initialization of reference type");
    2493                 :           4 :           return error_mark_node;
    2494                 :             :         }
    2495                 :             : 
    2496                 :    33403208 :       t = build_min (CAST_EXPR, type, parms);
    2497                 :             :       /* We don't know if it will or will not have side effects.  */
    2498                 :    33403208 :       TREE_SIDE_EFFECTS (t) = 1;
    2499                 :    33403208 :       return t;
    2500                 :             :     }
    2501                 :             : 
    2502                 :    28344340 :   if (! MAYBE_CLASS_TYPE_P (type))
    2503                 :             :     {
    2504                 :    25963448 :       if (parms == NULL_TREE)
    2505                 :             :         {
    2506                 :      462453 :           if (VOID_TYPE_P (type))
    2507                 :        4037 :             return void_node;
    2508                 :      458416 :           return build_value_init (cv_unqualified (type), complain);
    2509                 :             :         }
    2510                 :             : 
    2511                 :             :       /* This must build a C cast.  */
    2512                 :    25500995 :       parms = build_x_compound_expr_from_list (parms, ELK_FUNC_CAST, complain);
    2513                 :    25500995 :       return cp_build_c_cast (loc, type, parms, complain);
    2514                 :             :     }
    2515                 :             : 
    2516                 :             :   /* Prepare to evaluate as a call to a constructor.  If this expression
    2517                 :             :      is actually used, for example,
    2518                 :             : 
    2519                 :             :      return X (arg1, arg2, ...);
    2520                 :             : 
    2521                 :             :      then the slot being initialized will be filled in.  */
    2522                 :             : 
    2523                 :     2380892 :   if (!complete_type_or_maybe_complain (type, NULL_TREE, complain))
    2524                 :          21 :     return error_mark_node;
    2525                 :     2380868 :   if (abstract_virtuals_error (ACU_CAST, type, complain))
    2526                 :          15 :     return error_mark_node;
    2527                 :             : 
    2528                 :             :   /* [expr.type.conv]
    2529                 :             : 
    2530                 :             :      If the expression list is a single-expression, the type
    2531                 :             :      conversion is equivalent (in definedness, and if defined in
    2532                 :             :      meaning) to the corresponding cast expression.  */
    2533                 :     2380853 :   if (parms && TREE_CHAIN (parms) == NULL_TREE)
    2534                 :     1191808 :     return cp_build_c_cast (loc, type, TREE_VALUE (parms), complain);
    2535                 :             : 
    2536                 :             :   /* [expr.type.conv]
    2537                 :             : 
    2538                 :             :      The expression T(), where T is a simple-type-specifier for a
    2539                 :             :      non-array complete object type or the (possibly cv-qualified)
    2540                 :             :      void type, creates an rvalue of the specified type, which is
    2541                 :             :      value-initialized.  */
    2542                 :             : 
    2543                 :     1189045 :   if (parms == NULL_TREE)
    2544                 :             :     {
    2545                 :      859155 :       exp = build_value_init (type, complain);
    2546                 :      859155 :       exp = get_target_expr (exp, complain);
    2547                 :      859155 :       return exp;
    2548                 :             :     }
    2549                 :             : 
    2550                 :             :   /* Call the constructor.  */
    2551                 :      329890 :   releasing_vec parmvec;
    2552                 :     1023641 :   for (; parms != NULL_TREE; parms = TREE_CHAIN (parms))
    2553                 :      693751 :     vec_safe_push (parmvec, TREE_VALUE (parms));
    2554                 :      329890 :   exp = build_special_member_call (NULL_TREE, complete_ctor_identifier,
    2555                 :             :                                    &parmvec, type, LOOKUP_NORMAL, complain);
    2556                 :             : 
    2557                 :      329890 :   if (exp == error_mark_node)
    2558                 :             :     return error_mark_node;
    2559                 :             : 
    2560                 :      329874 :   return build_cplus_new (type, exp, complain);
    2561                 :      329890 : }
    2562                 :             : 
    2563                 :             : tree
    2564                 :    61749032 : build_functional_cast (location_t loc, tree exp, tree parms,
    2565                 :             :                        tsubst_flags_t complain)
    2566                 :             : {
    2567                 :    61749032 :   tree result = build_functional_cast_1 (loc, exp, parms, complain);
    2568                 :    61749029 :   protected_set_expr_location (result, loc);
    2569                 :    61749029 :   return result;  
    2570                 :             : }
    2571                 :             : 
    2572                 :             : 
    2573                 :             : /* Add new exception specifier SPEC, to the LIST we currently have.
    2574                 :             :    If it's already in LIST then do nothing.
    2575                 :             :    Moan if it's bad and we're allowed to. COMPLAIN < 0 means we
    2576                 :             :    know what we're doing.  */
    2577                 :             : 
    2578                 :             : tree
    2579                 :       15049 : add_exception_specifier (tree list, tree spec, tsubst_flags_t complain)
    2580                 :             : {
    2581                 :       15049 :   bool ok;
    2582                 :       15049 :   tree core = spec;
    2583                 :       15049 :   bool is_ptr;
    2584                 :       15049 :   diagnostic_t diag_type = DK_UNSPECIFIED; /* none */
    2585                 :             : 
    2586                 :       15049 :   if (spec == error_mark_node)
    2587                 :             :     return list;
    2588                 :             : 
    2589                 :       15097 :   gcc_assert (spec && (!list || TREE_VALUE (list)));
    2590                 :             : 
    2591                 :             :   /* [except.spec] 1, type in an exception specifier shall not be
    2592                 :             :      incomplete, or pointer or ref to incomplete other than pointer
    2593                 :             :      to cv void.  */
    2594                 :       15035 :   is_ptr = TYPE_PTR_P (core);
    2595                 :       15035 :   if (is_ptr || TYPE_REF_P (core))
    2596                 :          38 :     core = TREE_TYPE (core);
    2597                 :       15035 :   if (complain < 0)
    2598                 :             :     ok = true;
    2599                 :        1459 :   else if (VOID_TYPE_P (core))
    2600                 :             :     ok = is_ptr;
    2601                 :        1443 :   else if (TREE_CODE (core) == TEMPLATE_TYPE_PARM)
    2602                 :             :     ok = true;
    2603                 :        1431 :   else if (processing_template_decl)
    2604                 :             :     ok = true;
    2605                 :        1394 :   else if (!verify_type_context (input_location, TCTX_EXCEPTIONS, core,
    2606                 :        1394 :                                  !(complain & tf_error)))
    2607                 :           0 :     return error_mark_node;
    2608                 :             :   else
    2609                 :             :     {
    2610                 :        1394 :       ok = true;
    2611                 :             :       /* 15.4/1 says that types in an exception specifier must be complete,
    2612                 :             :          but it seems more reasonable to only require this on definitions
    2613                 :             :          and calls.  So just give a pedwarn at this point; we will give an
    2614                 :             :          error later if we hit one of those two cases.  */
    2615                 :        1394 :       if (!COMPLETE_TYPE_P (complete_type (core)))
    2616                 :       15035 :         diag_type = DK_PEDWARN; /* pedwarn */
    2617                 :             :     }
    2618                 :             : 
    2619                 :       15035 :   if (ok)
    2620                 :             :     {
    2621                 :             :       tree probe;
    2622                 :             : 
    2623                 :       15091 :       for (probe = list; probe; probe = TREE_CHAIN (probe))
    2624                 :          72 :         if (same_type_p (TREE_VALUE (probe), spec))
    2625                 :             :           break;
    2626                 :       15023 :       if (!probe)
    2627                 :       15019 :         list = tree_cons (NULL_TREE, spec, list);
    2628                 :             :     }
    2629                 :             :   else
    2630                 :             :     diag_type = DK_ERROR; /* error */
    2631                 :             : 
    2632                 :       15023 :   if (diag_type != DK_UNSPECIFIED
    2633                 :          24 :       && (complain & tf_warning_or_error))
    2634                 :          20 :     cxx_incomplete_type_diagnostic (NULL_TREE, core, diag_type);
    2635                 :             : 
    2636                 :             :   return list;
    2637                 :             : }
    2638                 :             : 
    2639                 :             : /* Like nothrow_spec_p, but don't abort on deferred noexcept.  */
    2640                 :             : 
    2641                 :             : static bool
    2642                 :     3729487 : nothrow_spec_p_uninst (const_tree spec)
    2643                 :             : {
    2644                 :     7458974 :   if (DEFERRED_NOEXCEPT_SPEC_P (spec))
    2645                 :             :     return false;
    2646                 :     3729484 :   return nothrow_spec_p (spec);
    2647                 :             : }
    2648                 :             : 
    2649                 :             : /* Combine the two exceptions specifier lists LIST and ADD, and return
    2650                 :             :    their union.  */
    2651                 :             : 
    2652                 :             : tree
    2653                 :    11189835 : merge_exception_specifiers (tree list, tree add)
    2654                 :             : {
    2655                 :    11189835 :   tree noex, orig_list;
    2656                 :             : 
    2657                 :    11189835 :   if (list == error_mark_node || add == error_mark_node)
    2658                 :             :     return error_mark_node;
    2659                 :             : 
    2660                 :             :   /* No exception-specifier or noexcept(false) are less strict than
    2661                 :             :      anything else.  Prefer the newer variant (LIST).  */
    2662                 :    11189835 :   if (!list || list == noexcept_false_spec)
    2663                 :             :     return list;
    2664                 :     3817921 :   else if (!add || add == noexcept_false_spec)
    2665                 :             :     return add;
    2666                 :             : 
    2667                 :             :   /* noexcept(true) and throw() are stricter than anything else.
    2668                 :             :      As above, prefer the more recent one (LIST).  */
    2669                 :     3720014 :   if (nothrow_spec_p_uninst (add))
    2670                 :             :     return list;
    2671                 :             : 
    2672                 :             :   /* Two implicit noexcept specs (e.g. on a destructor) are equivalent.  */
    2673                 :        9476 :   if (UNEVALUATED_NOEXCEPT_SPEC_P (add)
    2674                 :           3 :       && UNEVALUATED_NOEXCEPT_SPEC_P (list))
    2675                 :             :     return list;
    2676                 :             :   /* We should have instantiated other deferred noexcept specs by now.  */
    2677                 :        9473 :   gcc_assert (!DEFERRED_NOEXCEPT_SPEC_P (add));
    2678                 :             : 
    2679                 :        9473 :   if (nothrow_spec_p_uninst (list))
    2680                 :             :     return add;
    2681                 :        9468 :   noex = TREE_PURPOSE (list);
    2682                 :        9468 :   gcc_checking_assert (!TREE_PURPOSE (add)
    2683                 :             :                        || errorcount || !flag_exceptions
    2684                 :             :                        || cp_tree_equal (noex, TREE_PURPOSE (add)));
    2685                 :             : 
    2686                 :             :   /* Combine the dynamic-exception-specifiers, if any.  */
    2687                 :             :   orig_list = list;
    2688                 :       18991 :   for (; add && TREE_VALUE (add); add = TREE_CHAIN (add))
    2689                 :             :     {
    2690                 :          65 :       tree spec = TREE_VALUE (add);
    2691                 :             :       tree probe;
    2692                 :             : 
    2693                 :         118 :       for (probe = orig_list; probe && TREE_VALUE (probe);
    2694                 :          24 :            probe = TREE_CHAIN (probe))
    2695                 :          53 :         if (same_type_p (TREE_VALUE (probe), spec))
    2696                 :             :           break;
    2697                 :          41 :       if (!probe)
    2698                 :             :         {
    2699                 :          12 :           spec = build_tree_list (NULL_TREE, spec);
    2700                 :          12 :           TREE_CHAIN (spec) = list;
    2701                 :          12 :           list = spec;
    2702                 :             :         }
    2703                 :             :     }
    2704                 :             : 
    2705                 :             :   /* Keep the noexcept-specifier at the beginning of the list.  */
    2706                 :        9468 :   if (noex != TREE_PURPOSE (list))
    2707                 :           0 :     list = tree_cons (noex, TREE_VALUE (list), TREE_CHAIN (list));
    2708                 :             : 
    2709                 :             :   return list;
    2710                 :             : }
    2711                 :             : 
    2712                 :             : /* Subroutine of build_call.  Ensure that each of the types in the
    2713                 :             :    exception specification is complete.  Technically, 15.4/1 says that
    2714                 :             :    they need to be complete when we see a declaration of the function,
    2715                 :             :    but we should be able to get away with only requiring this when the
    2716                 :             :    function is defined or called.  See also add_exception_specifier.  */
    2717                 :             : 
    2718                 :             : void
    2719                 :   104328860 : require_complete_eh_spec_types (tree fntype, tree decl)
    2720                 :             : {
    2721                 :   104328860 :   tree raises;
    2722                 :             :   /* Don't complain about calls to op new.  */
    2723                 :   104328860 :   if (decl && DECL_ARTIFICIAL (decl))
    2724                 :             :     return;
    2725                 :   142868869 :   for (raises = TYPE_RAISES_EXCEPTIONS (fntype); raises;
    2726                 :    48245699 :        raises = TREE_CHAIN (raises))
    2727                 :             :     {
    2728                 :    48245699 :       tree type = TREE_VALUE (raises);
    2729                 :    48245699 :       if (type && !COMPLETE_TYPE_P (type))
    2730                 :             :         {
    2731                 :           2 :           if (decl)
    2732                 :           2 :             error
    2733                 :           2 :               ("call to function %qD which throws incomplete type %q#T",
    2734                 :             :                decl, type);
    2735                 :             :           else
    2736                 :           0 :             error ("call to function which throws incomplete type %q#T",
    2737                 :             :                    decl);
    2738                 :             :         }
    2739                 :             :     }
    2740                 :             : }
    2741                 :             : 
    2742                 :             : /* Record that any TARGET_EXPR in T are going to be elided in
    2743                 :             :    cp_gimplify_init_expr (or sooner).  */
    2744                 :             : 
    2745                 :             : void
    2746                 :    87207517 : set_target_expr_eliding (tree t)
    2747                 :             : {
    2748                 :    88929669 :   if (!t)
    2749                 :             :     return;
    2750                 :    88297807 :   switch (TREE_CODE (t))
    2751                 :             :     {
    2752                 :     5831213 :     case TARGET_EXPR:
    2753                 :     5831213 :       TARGET_EXPR_ELIDING_P (t) = true;
    2754                 :     5831213 :       break;
    2755                 :      791243 :     case COMPOUND_EXPR:
    2756                 :      791243 :       set_target_expr_eliding (TREE_OPERAND (t, 1));
    2757                 :      791243 :       break;
    2758                 :      930909 :     case COND_EXPR:
    2759                 :      930909 :       set_target_expr_eliding (TREE_OPERAND (t, 1));
    2760                 :      930909 :       set_target_expr_eliding (TREE_OPERAND (t, 2));
    2761                 :      930909 :       break;
    2762                 :             : 
    2763                 :             :     default:
    2764                 :             :       break;
    2765                 :             :     }
    2766                 :             : }
    2767                 :             : 
    2768                 :             : /* Call the above in the process of building an INIT_EXPR.  */
    2769                 :             : 
    2770                 :             : tree
    2771                 :    47542676 : cp_build_init_expr (location_t loc, tree target, tree init)
    2772                 :             : {
    2773                 :    47542676 :   set_target_expr_eliding (init);
    2774                 :    47542676 :   tree ie = build2_loc (loc, INIT_EXPR, TREE_TYPE (target),
    2775                 :             :                         target, init);
    2776                 :    47542676 :   TREE_SIDE_EFFECTS (ie) = true;
    2777                 :    47542676 :   return ie;
    2778                 :             : }
        

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.