LCOV - code coverage report
Current view: top level - gcc/cp - typeck2.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 94.0 % 1358 1276
Test Date: 2026-10-03 16:17:38 Functions: 100.0 % 40 40
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Report error messages, build initializers, and perform
       2              :    some front-end optimizations for C++ compiler.
       3              :    Copyright (C) 1987-2026 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           29 : error_not_base_type (tree basetype, tree type)
      48              : {
      49           29 :   if (TREE_CODE (basetype) == FUNCTION_DECL)
      50            0 :     basetype = DECL_CONTEXT (basetype);
      51           29 :   error ("type %qT is not a base type for type %qT", basetype, type);
      52           29 :   return error_mark_node;
      53              : }
      54              : 
      55              : tree
      56         1115 : binfo_or_else (tree base, tree type)
      57              : {
      58         1115 :   tree binfo = lookup_base (type, base, ba_unique,
      59              :                             NULL, tf_warning_or_error);
      60              : 
      61         1115 :   if (binfo == error_mark_node)
      62              :     return NULL_TREE;
      63         1115 :   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          271 : 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          271 :   if (VAR_P (arg)
     103           15 :       && DECL_LANG_SPECIFIC (arg)
     104            0 :       && DECL_IN_AGGR_P (arg)
     105          271 :       && !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          271 :   else if (INDIRECT_REF_P (arg)
     113           40 :            && TYPE_REF_P (TREE_TYPE (TREE_OPERAND (arg, 0)))
     114          305 :            && (VAR_P (TREE_OPERAND (arg, 0))
     115           21 :                || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
     116           17 :     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          254 :   else if (is_stub_object (arg))
     123              :     {
     124            7 :       gcc_assert (errstring == lv_assign);
     125            7 :       error_at (loc, "assignment to read-only type %qT", TREE_TYPE (arg));
     126              :     }
     127              :   else
     128          247 :     readonly_error (loc, arg, errstring);
     129          271 : }
     130              : 
     131              : /* If TYPE has abstract virtual functions, issue an error about trying
     132              :    to create an object of that type.  DECL is the object declared, or
     133              :    NULL_TREE if the declaration is unavailable, in which case USE specifies
     134              :    the kind of invalid use.  Returns 1 if an error occurred; zero if
     135              :    all was well.  */
     136              : 
     137              : static int
     138    417780247 : abstract_virtuals_error (tree decl, tree type, abstract_class_use use,
     139              :                          tsubst_flags_t complain)
     140              : {
     141    417780247 :   vec<tree, va_gc> *pure;
     142              : 
     143    417780247 :   if (TREE_CODE (type) == ARRAY_TYPE)
     144              :     {
     145       983334 :       decl = NULL_TREE;
     146       983334 :       use = ACU_ARRAY;
     147       983334 :       type = strip_array_types (type);
     148              :     }
     149              : 
     150              :   /* This function applies only to classes. Any other entity can never
     151              :      be abstract.  */
     152    417780247 :   if (!CLASS_TYPE_P (type))
     153              :     return 0;
     154              : 
     155     80023903 :   if (ANON_AGGR_TYPE_P (type))
     156              :     {
     157              :       /* [class.union.anon]/1: Each object of such an unnamed type shall be
     158              :          such an unnamed object.  */
     159          426 :       auto_diagnostic_group d;
     160          426 :       location_t aloc
     161          426 :         = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (TYPE_MAIN_VARIANT (type)));
     162          426 :       if (decl
     163          372 :           && VAR_P (decl)
     164          364 :           && DECL_NAME (decl) == NULL_TREE
     165          767 :           && ANON_UNION_TYPE_P (type))
     166              :         /* Unnamed variables are ok, those are assumed to be the variable
     167              :            created for namespace scope anonymous union.  For temporaries
     168              :            even when in the end they create VAR_DECLs with NULL DECL_NAME,
     169              :            this function is called first with !decl and so invalid code
     170              :            can be diagnosed below at that point.  */;
     171           85 :       else if (!(complain & tf_error))
     172              :         return 1;
     173           85 :       else if (ANON_UNION_TYPE_P (type))
     174              :         {
     175           51 :           if (!decl)
     176           32 :             switch (use)
     177              :               {
     178           20 :               default:
     179           20 :                 error ("temporary object with anonymous union type %qT", type);
     180           20 :                 break;
     181            4 :               case ACU_CATCH:
     182            4 :                 error ("%<catch%> parameter with anonymous union type %qT",
     183              :                        type);
     184            4 :                 break;
     185            4 :               case ACU_THROW:
     186            4 :                 error ("%<throw%> operand has anonymous union type %qT", type);
     187            4 :                 break;
     188            4 :               case ACU_ARRAY:
     189            4 :                 error ("object with array of anonymous union type %qT", type);
     190            4 :                 break;
     191              :               }
     192           19 :           else if (VAR_P (decl))
     193           15 :             error_at (location_of (decl),
     194              :                       "declaration of variable %qD with anonymous union type "
     195              :                       "%qT", decl, type);
     196            4 :           else if (TREE_CODE (decl) == PARM_DECL && DECL_NAME (decl))
     197            2 :             error_at (location_of (decl),
     198              :                       "declaration of parameter %qD with anonymous union type "
     199              :                       "%qT", decl, type);
     200            2 :           else if (TREE_CODE (decl) == PARM_DECL)
     201            2 :             error_at (location_of (decl),
     202              :                       "declaration of a parameter with anonymous union type "
     203              :                       "%qT", type);
     204           51 :           inform (aloc, "anonymous union declared here");
     205           51 :           if (decl)
     206           19 :             TREE_TYPE (decl) = error_mark_node;
     207              :           return 1;
     208              :         }
     209              :       else
     210              :         {
     211           34 :           if (!decl)
     212           22 :             switch (use)
     213              :               {
     214           14 :               default:
     215           14 :                 error ("temporary object with anonymous struct type %qT",
     216              :                        type);
     217           14 :                 break;
     218            4 :               case ACU_CATCH:
     219            4 :                 error ("%<catch%> parameter with anonymous struct type %qT",
     220              :                        type);
     221            4 :                 break;
     222            2 :               case ACU_THROW:
     223            2 :                 error ("%<throw%> operand has anonymous struct type %qT",
     224              :                        type);
     225            2 :                 break;
     226            2 :               case ACU_ARRAY:
     227            2 :                 error ("object with array of anonymous struct type %qT", type);
     228            2 :                 break;
     229              :               }
     230           12 :           else if (VAR_P (decl))
     231            8 :             error_at (location_of (decl),
     232              :                       "declaration of variable %qD with anonymous struct type "
     233              :                       "%qT", decl, type);
     234            4 :           else if (TREE_CODE (decl) == PARM_DECL && DECL_NAME (decl))
     235            2 :             error_at (location_of (decl),
     236              :                       "declaration of parameter %qD with anonymous struct type "
     237              :                       "%qT", decl, type);
     238            2 :           else if (TREE_CODE (decl) == PARM_DECL)
     239            2 :             error_at (location_of (decl),
     240              :                       "declaration of a parameter with anonymous struct type "
     241              :                       "%qT", type);
     242           34 :           inform (aloc, "anonymous struct declared here");
     243           34 :           if (decl)
     244           12 :             TREE_TYPE (decl) = error_mark_node;
     245              :           return 1;
     246              :         }
     247          426 :     }
     248              : 
     249     80023818 :   type = TYPE_MAIN_VARIANT (type);
     250              : 
     251              : #if 0
     252              :   /* Instantiation here seems to be required by the standard,
     253              :      but breaks e.g. boost::bind.  FIXME!  */
     254              :   /* In SFINAE, non-N3276 context, force instantiation.  */
     255              :   if (!(complain & (tf_error|tf_decltype)))
     256              :     complete_type (type);
     257              : #endif
     258              : 
     259     80023818 :   if (!TYPE_SIZE (type))
     260              :     /* TYPE is being defined, and during that time
     261              :        CLASSTYPE_PURE_VIRTUALS holds the inline friends.  */
     262              :     return 0;
     263              : 
     264     80023755 :   pure = CLASSTYPE_PURE_VIRTUALS (type);
     265     80023755 :   if (!pure)
     266              :     return 0;
     267              : 
     268          235 :   if (!(complain & tf_error))
     269              :     return 1;
     270              : 
     271          111 :   auto_diagnostic_group d;
     272          111 :   if (decl)
     273              :     {
     274           54 :       if (VAR_P (decl))
     275            9 :         error ("cannot declare variable %q+D to be of abstract "
     276              :                "type %qT", decl, type);
     277           45 :       else if (TREE_CODE (decl) == PARM_DECL)
     278              :         {
     279           27 :           if (DECL_NAME (decl))
     280           24 :             error ("cannot declare parameter %q+D to be of abstract type %qT",
     281              :                    decl, type);
     282              :           else
     283            3 :             error ("cannot declare parameter to be of abstract type %qT",
     284              :                    type);
     285              :         }
     286           18 :       else if (TREE_CODE (decl) == FIELD_DECL)
     287           15 :         error ("cannot declare field %q+D to be of abstract type %qT",
     288              :                decl, type);
     289            3 :       else if (TREE_CODE (decl) == FUNCTION_DECL
     290            3 :                && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
     291            0 :         error ("invalid abstract return type for member function %q+#D", decl);
     292            3 :       else if (TREE_CODE (decl) == FUNCTION_DECL)
     293            3 :         error ("invalid abstract return type for function %q+#D", decl);
     294            0 :       else if (identifier_p (decl))
     295              :         /* Here we do not have location information.  */
     296            0 :         error ("invalid abstract type %qT for %qE", type, decl);
     297              :       else
     298            0 :         error ("invalid abstract type for %q+D", decl);
     299              :     }
     300           57 :   else switch (use)
     301              :     {
     302           12 :     case ACU_ARRAY:
     303           12 :       error ("creating array of %qT, which is an abstract class type", type);
     304           12 :       break;
     305            9 :     case ACU_CAST:
     306            9 :       error ("invalid cast to abstract class type %qT", type);
     307            9 :       break;
     308            0 :     case ACU_NEW:
     309            0 :       error ("invalid new-expression of abstract class type %qT", type);
     310            0 :       break;
     311            0 :     case ACU_RETURN:
     312            0 :       error ("invalid abstract return type %qT", type);
     313            0 :       break;
     314            0 :     case ACU_PARM:
     315            0 :       error ("invalid abstract parameter type %qT", type);
     316            0 :       break;
     317            6 :     case ACU_THROW:
     318            6 :       error ("expression of abstract class type %qT cannot "
     319              :              "be used in throw-expression", type);
     320            6 :       break;
     321            3 :     case ACU_CATCH:
     322            3 :       error ("cannot declare %<catch%> parameter to be of abstract "
     323              :              "class type %qT", type);
     324            3 :       break;
     325           27 :     default:
     326           27 :       error ("cannot construct an object of abstract type %qT", type);
     327              :     }
     328              : 
     329              :   /* Only go through this once.  */
     330          111 :   if (pure->length ())
     331              :     {
     332           48 :       unsigned ix;
     333           48 :       tree fn;
     334              : 
     335           48 :       inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)),
     336              :               "because the following virtual functions are pure within %qT:",
     337              :               type);
     338              : 
     339           48 :       auto_diagnostic_nesting_level adnl;
     340          144 :       FOR_EACH_VEC_ELT (*pure, ix, fn)
     341           96 :         if (! DECL_CLONED_FUNCTION_P (fn)
     342           48 :             || DECL_COMPLETE_DESTRUCTOR_P (fn))
     343           48 :           inform (DECL_SOURCE_LOCATION (fn), "%#qD", fn);
     344              : 
     345              :       /* Now truncate the vector.  This leaves it non-null, so we know
     346              :          there are pure virtuals, but empty so we don't list them out
     347              :          again.  */
     348           48 :       pure->truncate (0);
     349           48 :     }
     350              : 
     351          111 :   return 1;
     352              : }
     353              : 
     354              : int
     355    359895171 : abstract_virtuals_error (tree decl, tree type,
     356              :                          tsubst_flags_t complain /* = tf_warning_or_error */)
     357              : {
     358    359895171 :   return abstract_virtuals_error (decl, type, ACU_UNKNOWN, complain);
     359              : }
     360              : 
     361              : int
     362     57885076 : abstract_virtuals_error (abstract_class_use use, tree type,
     363              :                          tsubst_flags_t complain /* = tf_warning_or_error */)
     364              : {
     365     57885076 :   return abstract_virtuals_error (NULL_TREE, type, use, complain);
     366              : }
     367              : 
     368              : 
     369              : /* Print an inform about the declaration of the incomplete type TYPE.  */
     370              : 
     371              : void
     372         1225 : cxx_incomplete_type_inform (const_tree type)
     373              : {
     374         1225 :   if (!TYPE_MAIN_DECL (type))
     375              :     return;
     376              : 
     377         1135 :   location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type));
     378         1135 :   tree ptype = strip_top_quals (const_cast<tree> (type));
     379              : 
     380              :   /* When defining a template, current_class_type will be the pattern on
     381              :      the template definition, while non-self-reference usages of this
     382              :      template will be an instantiation; we should pull out the pattern to
     383              :      compare against.  And for partial specs we should use the loc of the
     384              :      partial spec rather than the primary template.  */
     385         1135 :   tree ttype = NULL_TREE;
     386         1135 :   tree tinfo = TYPE_TEMPLATE_INFO (ptype);
     387         1135 :   if (tinfo)
     388              :     {
     389          303 :       tree tmpl = TI_TEMPLATE (tinfo);
     390          303 :       if (PRIMARY_TEMPLATE_P (tmpl) && TI_PARTIAL_INFO (tinfo))
     391              :         {
     392           37 :           tree partial = TI_TEMPLATE (TI_PARTIAL_INFO (tinfo));
     393           37 :           loc = DECL_SOURCE_LOCATION (partial);
     394           37 :           ttype = TREE_TYPE (partial);
     395              :         }
     396              :       else
     397          266 :         ttype = TREE_TYPE (tmpl);
     398              :     }
     399              : 
     400         1135 :   if (current_class_type
     401          279 :       && TYPE_BEING_DEFINED (current_class_type)
     402         1366 :       && (same_type_p (ptype, current_class_type)
     403          135 :           || (ttype && same_type_p (ttype, current_class_type))))
     404          106 :     inform (loc, "definition of %q#T is not complete until "
     405              :             "the closing brace", ptype);
     406              :   else
     407              :     {
     408         1029 :       if (!tinfo)
     409          787 :         inform (loc, "forward declaration of %q#T", ptype);
     410              :       else
     411          242 :         inform (loc, "declaration of %q#T", ptype);
     412              : 
     413              :       /* If there's a similar-looking complete type attached
     414              :          to a different module, point at that as a suggestion.  */
     415         1029 :       if (modules_p () && TYPE_NAMESPACE_SCOPE_P (ptype))
     416              :         {
     417           24 :           tree result = lookup_qualified_name (CP_TYPE_CONTEXT (ptype),
     418           24 :                                                TYPE_IDENTIFIER (ptype),
     419              :                                                LOOK_want::TYPE);
     420           24 :           if (TREE_CODE (result) == TREE_LIST)
     421           72 :             for (; result; result = TREE_CHAIN (result))
     422              :               {
     423           48 :                 tree cand = TREE_VALUE (result);
     424              : 
     425              :                 /* Typedefs are not likely intended to correspond.  */
     426           48 :                 if (is_typedef_decl (STRIP_TEMPLATE (cand))
     427           42 :                     || DECL_ALIAS_TEMPLATE_P (cand))
     428            6 :                   continue;
     429              : 
     430              :                 /* Only look at templates if type was a template.  */
     431           42 :                 if ((tinfo != nullptr) != (TREE_CODE (cand) == TEMPLATE_DECL))
     432            3 :                   continue;
     433              : 
     434              :                 /* If we're looking for a template specialisation,
     435              :                    only consider matching specialisations.  */
     436           39 :                 if (tinfo)
     437              :                   {
     438           27 :                     tree t = lookup_template_class (cand, TI_ARGS (tinfo),
     439              :                                                     NULL_TREE, NULL_TREE,
     440              :                                                     tf_none);
     441           27 :                     if (t == error_mark_node
     442           27 :                         || !CLASS_TYPE_P (t)
     443           54 :                         || TYPE_BEING_DEFINED (t))
     444            0 :                       continue;
     445              : 
     446           27 :                     if (CLASSTYPE_TEMPLATE_INSTANTIATION (t))
     447              :                       {
     448              :                         /* An uninstantiated template: check if there is a
     449              :                            pattern that could be used.  We don't want to
     450              :                            call instantiate_class_template as that could
     451              :                            cause further errors; this is just a hint.  */
     452           21 :                         tree part = most_specialized_partial_spec (t, tf_none);
     453           27 :                         cand = (part ? TI_TEMPLATE (part)
     454           15 :                                 : CLASSTYPE_TI_TEMPLATE (t));
     455              :                       }
     456              :                     else
     457            6 :                       cand = TYPE_NAME (t);
     458              :                   }
     459              : 
     460           39 :                 if (!COMPLETE_TYPE_P (TREE_TYPE (cand)))
     461           24 :                   continue;
     462              : 
     463           15 :                 inform (DECL_SOURCE_LOCATION (cand),
     464              :                         "%q#T has a definition but does not correspond with "
     465              :                         "%q#T because it is attached to a different module",
     466           15 :                         TREE_TYPE (cand), ptype);
     467              :               }
     468              :         }
     469              :     }
     470              : }
     471              : 
     472              : /* Print an error message for invalid use of an incomplete type.
     473              :    VALUE is the expression that was used (or 0 if that isn't known)
     474              :    and TYPE is the type that was invalid.  DIAG_KIND indicates the
     475              :    type of diagnostic (see diagnostics/kinds.def).  */
     476              : 
     477              : bool
     478         1226 : cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
     479              :                                 const_tree type,
     480              :                                 enum diagnostics::kind diag_kind)
     481              : {
     482         1226 :   bool is_decl = false, complained = false;
     483              : 
     484              :   /* Avoid duplicate error message.  */
     485         1226 :   if (TREE_CODE (type) == ERROR_MARK)
     486              :     return false;
     487              : 
     488         1226 :   auto_diagnostic_group d;
     489         1226 :   if (value)
     490              :     {
     491          416 :       STRIP_ANY_LOCATION_WRAPPER (value);
     492              : 
     493          416 :       if (VAR_P (value)
     494          371 :           || TREE_CODE (value) == PARM_DECL
     495          326 :           || TREE_CODE (value) == FIELD_DECL)
     496              :         {
     497          121 :           complained = emit_diagnostic (diag_kind, DECL_SOURCE_LOCATION (value), 0,
     498              :                                         "%qD has incomplete type", value);
     499          121 :           is_decl = true;
     500              :         }
     501              :     }
     502         1226 :  retry:
     503              :   /* We must print an error message.  Be clever about what it says.  */
     504              : 
     505         1306 :   switch (TREE_CODE (type))
     506              :     {
     507          960 :     case RECORD_TYPE:
     508          960 :     case UNION_TYPE:
     509          960 :     case ENUMERAL_TYPE:
     510          960 :       if (!is_decl)
     511          862 :         complained = emit_diagnostic (diag_kind, loc, 0,
     512              :                                       "invalid use of incomplete type %q#T",
     513              :                                       type);
     514          960 :       if (complained)
     515          957 :         cxx_incomplete_type_inform (type);
     516              :       break;
     517              : 
     518           12 :     case VOID_TYPE:
     519           12 :       complained = emit_diagnostic (diag_kind, loc, 0,
     520              :                        "invalid use of %qT", type);
     521           12 :       break;
     522              : 
     523          134 :     case ARRAY_TYPE:
     524          134 :       if (TYPE_DOMAIN (type))
     525              :         {
     526           80 :           type = TREE_TYPE (type);
     527           80 :           goto retry;
     528              :         }
     529           54 :       complained = emit_diagnostic (diag_kind, loc, 0,
     530              :                        "invalid use of array with unspecified bounds");
     531           54 :       break;
     532              : 
     533           72 :     case OFFSET_TYPE:
     534           72 :     bad_member:
     535           72 :       {
     536           72 :         tree member = TREE_OPERAND (value, 1);
     537           72 :         if (is_overloaded_fn (member) && !flag_ms_extensions)
     538              :           {
     539           69 :             gcc_rich_location richloc (loc);
     540              :             /* If "member" has no arguments (other than "this"), then
     541              :                add a fix-it hint.  */
     542           69 :             member = MAYBE_BASELINK_FUNCTIONS (member);
     543           69 :             if (TREE_CODE (member) == FUNCTION_DECL
     544           57 :                 && DECL_OBJECT_MEMBER_FUNCTION_P (member)
     545          126 :                 && type_num_arguments (TREE_TYPE (member)) == 1)
     546           54 :               richloc.add_fixit_insert_after ("()");
     547           69 :             complained = emit_diagnostic (diag_kind, &richloc, 0,
     548              :                              "invalid use of member function %qD "
     549              :                              "(did you forget the %<()%> ?)", member);
     550           69 :           }
     551              :         else
     552            3 :           complained = emit_diagnostic (diag_kind, loc, 0,
     553              :                            "invalid use of member %qD "
     554              :                            "(did you forget the %<&%> ?)", member);
     555              :       }
     556              :       break;
     557              : 
     558           31 :     case TEMPLATE_TYPE_PARM:
     559           31 :       if (is_auto (type))
     560              :         {
     561           19 :           if (CLASS_PLACEHOLDER_TEMPLATE (type))
     562            3 :             complained = emit_diagnostic (diag_kind, loc, 0,
     563              :                              "invalid use of placeholder %qT", type);
     564              :           else
     565           16 :             complained = emit_diagnostic (diag_kind, loc, 0,
     566              :                              "invalid use of %qT", type);
     567              :         }
     568              :       else
     569           12 :         complained = emit_diagnostic (diag_kind, loc, 0,
     570              :                          "invalid use of template type parameter %qT", type);
     571              :       break;
     572              : 
     573            3 :     case BOUND_TEMPLATE_TEMPLATE_PARM:
     574            3 :       complained = emit_diagnostic (diag_kind, loc, 0,
     575              :                        "invalid use of template template parameter %qT",
     576            3 :                        TYPE_NAME (type));
     577            3 :       break;
     578              : 
     579            0 :     case TYPE_PACK_EXPANSION:
     580            0 :       complained = emit_diagnostic (diag_kind, loc, 0,
     581              :                        "invalid use of pack expansion %qT", type);
     582            0 :       break;
     583              : 
     584           16 :     case TYPENAME_TYPE:
     585           16 :     case DECLTYPE_TYPE:
     586           16 :       complained = emit_diagnostic (diag_kind, loc, 0,
     587              :                        "invalid use of dependent type %qT", type);
     588           16 :       break;
     589              : 
     590          150 :     case LANG_TYPE:
     591          150 :       if (type == init_list_type_node)
     592              :         {
     593            3 :           complained = emit_diagnostic (diag_kind, loc, 0,
     594              :                            "invalid use of brace-enclosed initializer list");
     595            3 :           break;
     596              :         }
     597          147 :       gcc_assert (type == unknown_type_node);
     598          147 :       if (value && TREE_CODE (value) == COMPONENT_REF)
     599           72 :         goto bad_member;
     600           75 :       else if (value && TREE_CODE (value) == ADDR_EXPR)
     601           27 :         complained = emit_diagnostic (diag_kind, loc, 0,
     602              :                          "address of overloaded function with no contextual "
     603              :                          "type information");
     604           48 :       else if (value && TREE_CODE (value) == OVERLOAD)
     605           42 :         complained = emit_diagnostic (diag_kind, loc, 0,
     606              :                          "overloaded function with no contextual type information");
     607              :       else
     608            6 :         complained = emit_diagnostic (diag_kind, loc, 0,
     609              :                          "insufficient contextual information to determine type");
     610              :       break;
     611              : 
     612            0 :     default:
     613            0 :       gcc_unreachable ();
     614              :     }
     615              : 
     616         1226 :   return complained;
     617         1226 : }
     618              : 
     619              : /* Print an error message for invalid use of an incomplete type.
     620              :    VALUE is the expression that was used (or 0 if that isn't known)
     621              :    and TYPE is the type that was invalid.  */
     622              : 
     623              : void
     624           58 : cxx_incomplete_type_error (location_t loc, const_tree value, const_tree type)
     625              : {
     626           58 :   cxx_incomplete_type_diagnostic (loc, value, type, diagnostics::kind::error);
     627           58 : }
     628              : 
     629              : 
     630              : /* We've just initialized subobject SUB; also insert a TARGET_EXPR with an
     631              :    EH-only cleanup for SUB.  Because of EH region nesting issues, we need to
     632              :    make the cleanup conditional on a flag that we will clear once the object is
     633              :    fully initialized, so push a new flag onto FLAGS.  */
     634              : 
     635              : static void
     636       360572 : maybe_push_temp_cleanup (tree sub, vec<tree,va_gc> **flags)
     637              : {
     638       360572 :   if (!flag_exceptions)
     639              :     return;
     640       718272 :   if (tree cleanup
     641       359136 :       = cxx_maybe_build_cleanup (sub, tf_warning_or_error))
     642              :     {
     643          217 :       tree tx = get_internal_target_expr (boolean_true_node);
     644          217 :       tree flag = TARGET_EXPR_SLOT (tx);
     645          217 :       TARGET_EXPR_CLEANUP (tx) = build3 (COND_EXPR, void_type_node,
     646              :                                          flag, cleanup, void_node);
     647          217 :       add_stmt (tx);
     648          217 :       vec_safe_push (*flags, flag);
     649              :     }
     650              : }
     651              : 
     652              : /* F is something added to a cleanup flags vec by maybe_push_temp_cleanup or
     653              :    build_vec_init.  Return the code to disable the cleanup it controls.  */
     654              : 
     655              : tree
     656         1211 : build_disable_temp_cleanup (tree f)
     657              : {
     658         1211 :   tree d = f;
     659         1211 :   tree i = boolean_false_node;
     660         1211 :   if (TREE_CODE (f) == TREE_LIST)
     661              :     {
     662              :       /* To disable a build_vec_init cleanup, set
     663              :          iterator = maxindex.  */
     664          994 :       d = TREE_PURPOSE (f);
     665          994 :       i = TREE_VALUE (f);
     666          994 :       ggc_free (f);
     667              :     }
     668         1211 :   return build2 (MODIFY_EXPR, TREE_TYPE (d), d, i);
     669              : }
     670              : 
     671              : /* The recursive part of split_nonconstant_init.  DEST is an lvalue
     672              :    expression to which INIT should be assigned.  INIT is a CONSTRUCTOR.
     673              :    Return true if the whole of the value was initialized by the
     674              :    generated statements or modifying DECL_INITIAL.  */
     675              : 
     676              : static bool
     677       363494 : split_nonconstant_init_1 (tree dest, tree init, bool last,
     678              :                           vec<tree,va_gc> **flags)
     679              : {
     680       363494 :   unsigned HOST_WIDE_INT idx, tidx = HOST_WIDE_INT_M1U;
     681       363494 :   tree field_index, value;
     682       363494 :   tree type = TREE_TYPE (dest);
     683       363494 :   tree inner_type = NULL;
     684       363494 :   bool array_type_p = false;
     685       363494 :   bool complete_p = true;
     686       363494 :   HOST_WIDE_INT num_split_elts = 0;
     687       363494 :   tree last_split_elt = NULL_TREE;
     688              : 
     689       363494 :   switch (TREE_CODE (type))
     690              :     {
     691         6379 :     case ARRAY_TYPE:
     692         6379 :       inner_type = TREE_TYPE (type);
     693         6379 :       array_type_p = true;
     694         6379 :       if ((TREE_SIDE_EFFECTS (init)
     695         2300 :            && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
     696         7978 :           || vla_type_p (type))
     697              :         {
     698          769 :           if (!TYPE_DOMAIN (type)
     699            3 :               && TREE_CODE (init) == CONSTRUCTOR
     700          772 :               && CONSTRUCTOR_NELTS (init))
     701              :             {
     702              :               /* Flexible array.  */
     703            3 :               cp_complete_array_type (&type, init, /*default*/true);
     704            3 :               dest = build1 (VIEW_CONVERT_EXPR, type, dest);
     705              :             }
     706              : 
     707              :           /* For an array, we only need/want a single cleanup region rather
     708              :              than one per element.  build_vec_init will handle it.  */
     709          769 :           tree code = build_vec_init (dest, NULL_TREE, init, false, 1,
     710              :                                       tf_warning_or_error, flags);
     711          769 :           add_stmt (code);
     712          769 :           return true;
     713              :         }
     714              :       /* FALLTHRU */
     715              : 
     716       361437 :     case RECORD_TYPE:
     717       361437 :     case UNION_TYPE:
     718       361437 :     case QUAL_UNION_TYPE:
     719      1053439 :       FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), idx,
     720              :                                 field_index, value)
     721              :         {
     722              :           /* The current implementation of this algorithm assumes that
     723              :              the field was set for all the elements. This is usually done
     724              :              by process_init_constructor.  */
     725       692002 :           gcc_assert (field_index);
     726              : 
     727       692002 :           if (!array_type_p)
     728       678187 :             inner_type = TREE_TYPE (field_index);
     729              : 
     730       678187 :           tree sub;
     731       678187 :           if (array_type_p)
     732        13815 :             sub = build4 (ARRAY_REF, inner_type, dest, field_index,
     733              :                           NULL_TREE, NULL_TREE);
     734              :           else
     735       678187 :             sub = build3 (COMPONENT_REF, inner_type, dest, field_index,
     736              :                           NULL_TREE);
     737              : 
     738      2072706 :           bool elt_last = last && idx == CONSTRUCTOR_NELTS (init) - 1;
     739              : 
     740              :           /* We need to see sub-array TARGET_EXPR before cp_fold_r so we can
     741              :              handle cleanup flags properly.  */
     742       692002 :           gcc_checking_assert (!target_expr_needs_replace (value));
     743              : 
     744       692002 :           if (TREE_CODE (value) == CONSTRUCTOR)
     745              :             {
     746         2812 :               if (!split_nonconstant_init_1 (sub, value, elt_last, flags)
     747              :                       /* For flexible array member with initializer we
     748              :                          can't remove the initializer, because only the
     749              :                          initializer determines how many elements the
     750              :                          flexible array member has.  */
     751         2812 :                   || (!array_type_p
     752         1158 :                       && TREE_CODE (inner_type) == ARRAY_TYPE
     753         1037 :                       && TYPE_DOMAIN (inner_type) == NULL
     754           49 :                       && TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
     755           49 :                       && COMPLETE_TYPE_P (TREE_TYPE (value))
     756           49 :                       && !integer_zerop (TYPE_SIZE (TREE_TYPE (value)))
     757           49 :                       && elt_last
     758           49 :                       && TYPE_HAS_TRIVIAL_DESTRUCTOR
     759              :                                 (strip_array_types (inner_type))))
     760              :                 complete_p = false;
     761              :               else
     762              :                 {
     763              :                   /* Mark element for removal.  */
     764         1262 :                   last_split_elt = field_index;
     765         1262 :                   CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE;
     766         1262 :                   if (idx < tidx)
     767              :                     tidx = idx;
     768         1262 :                   num_split_elts++;
     769              :                 }
     770              :             }
     771       689190 :           else if (tree vi = get_vec_init_expr (value))
     772              :             {
     773           33 :               add_stmt (expand_vec_init_expr (sub, vi, tf_warning_or_error,
     774              :                                               flags));
     775              : 
     776              :               /* Mark element for removal.  */
     777           33 :               last_split_elt = field_index;
     778           33 :               CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE;
     779           33 :               if (idx < tidx)
     780              :                 tidx = idx;
     781           33 :               num_split_elts++;
     782              :             }
     783       689157 :           else if (!initializer_constant_valid_p (value, inner_type))
     784              :             {
     785       563919 :               tree code;
     786              : 
     787              :               /* Push cleanups for any preceding members with constant
     788              :                  initialization.  */
     789       563919 :               if (CLASS_TYPE_P (type))
     790       553545 :                 for (tree prev = (last_split_elt ?
     791       235536 :                                   DECL_CHAIN (last_split_elt)
     792       553545 :                                   : TYPE_FIELDS (type));
     793         1876 :                      ; prev = DECL_CHAIN (prev))
     794              :                   {
     795       555421 :                     prev = next_aggregate_field (prev);
     796       555421 :                     if (prev == field_index)
     797              :                       break;
     798         1876 :                     tree ptype = TREE_TYPE (prev);
     799         1876 :                     if (TYPE_P (ptype) && type_build_dtor_call (ptype))
     800              :                       {
     801           43 :                         tree pcref = build3 (COMPONENT_REF, ptype, dest, prev,
     802              :                                              NULL_TREE);
     803           43 :                         maybe_push_temp_cleanup (pcref, flags);
     804              :                       }
     805         1876 :                   }
     806              : 
     807              :               /* Mark element for removal.  */
     808       563919 :               CONSTRUCTOR_ELT (init, idx)->index = NULL_TREE;
     809       563919 :               if (idx < tidx)
     810              :                 tidx = idx;
     811              : 
     812       563919 :               if (TREE_CODE (field_index) == RANGE_EXPR)
     813              :                 {
     814              :                   /* Use build_vec_init to initialize a range.  */
     815            0 :                   tree low = TREE_OPERAND (field_index, 0);
     816            0 :                   tree hi = TREE_OPERAND (field_index, 1);
     817            0 :                   sub = build4 (ARRAY_REF, inner_type, dest, low,
     818              :                                 NULL_TREE, NULL_TREE);
     819            0 :                   sub = cp_build_addr_expr (sub, tf_warning_or_error);
     820            0 :                   tree max = size_binop (MINUS_EXPR, hi, low);
     821            0 :                   code = build_vec_init (sub, max, value, false, 0,
     822              :                                          tf_warning_or_error);
     823            0 :                   add_stmt (code);
     824            0 :                   if (tree_fits_shwi_p (max))
     825            0 :                     num_split_elts += tree_to_shwi (max);
     826              :                 }
     827              :               else
     828              :                 {
     829              :                   /* We may need to add a copy constructor call if
     830              :                      the field has [[no_unique_address]].  */
     831       563919 :                   if (unsafe_return_slot_p (sub))
     832              :                     {
     833              :                       /* But not if the initializer is an implicit ctor call
     834              :                          we just built in digest_init.  */
     835          540 :                       if (TREE_CODE (value) == TARGET_EXPR
     836          540 :                           && TARGET_EXPR_LIST_INIT_P (value)
     837          562 :                           && make_safe_copy_elision (sub, value))
     838           22 :                         goto build_init;
     839              : 
     840          518 :                       if (TREE_CODE (value) == TARGET_EXPR)
     841              :                         /* We have to add this constructor, so we will not
     842              :                            elide.  */
     843          518 :                         TARGET_EXPR_ELIDING_P (value) = false;
     844              : 
     845          518 :                       tree name = (DECL_FIELD_IS_BASE (field_index)
     846          518 :                                    ? base_ctor_identifier
     847          518 :                                    : complete_ctor_identifier);
     848          518 :                       releasing_vec args = make_tree_vector_single (value);
     849          518 :                       code = build_special_member_call
     850          518 :                         (sub, name, &args, inner_type,
     851              :                          LOOKUP_NORMAL, tf_warning_or_error);
     852          518 :                     }
     853              :                   else
     854              :                     {
     855       563379 :                     build_init:
     856       563401 :                       code = cp_build_init_expr (sub, value);
     857              :                     }
     858       563919 :                   code = build_stmt (input_location, EXPR_STMT, code);
     859       563919 :                   add_stmt (code);
     860       563919 :                   if (!elt_last)
     861       360529 :                     maybe_push_temp_cleanup (sub, flags);
     862              :                 }
     863              : 
     864       563919 :               last_split_elt = field_index;
     865       563919 :               num_split_elts++;
     866              :             }
     867              :         }
     868       361437 :       if (num_split_elts == 1)
     869       198238 :         CONSTRUCTOR_ELTS (init)->ordered_remove (tidx);
     870       163199 :       else if (num_split_elts > 1)
     871              :         {
     872              :           /* Perform the delayed ordered removal of non-constant elements
     873              :              we split out.  */
     874       492999 :           for (idx = tidx; idx < CONSTRUCTOR_NELTS (init); ++idx)
     875       367327 :             if (CONSTRUCTOR_ELT (init, idx)->index == NULL_TREE)
     876              :               ;
     877              :             else
     878              :               {
     879          351 :                 *CONSTRUCTOR_ELT (init, tidx) = *CONSTRUCTOR_ELT (init, idx);
     880          351 :                 ++tidx;
     881              :               }
     882       125672 :           vec_safe_truncate (CONSTRUCTOR_ELTS (init), tidx);
     883              :         }
     884              :       break;
     885              : 
     886         1288 :     case VECTOR_TYPE:
     887         1288 :       if (!initializer_constant_valid_p (init, type))
     888              :         {
     889         1265 :           tree code;
     890         1265 :           tree cons = copy_node (init);
     891         1265 :           CONSTRUCTOR_ELTS (init) = NULL;
     892         1265 :           code = build2 (MODIFY_EXPR, type, dest, cons);
     893         1265 :           code = build_stmt (input_location, EXPR_STMT, code);
     894         1265 :           add_stmt (code);
     895         1265 :           num_split_elts += CONSTRUCTOR_NELTS (init);
     896              :         }
     897              :       break;
     898              : 
     899            0 :     default:
     900            0 :       gcc_unreachable ();
     901              :     }
     902              : 
     903              :   /* The rest of the initializer is now a constant. */
     904       362725 :   TREE_CONSTANT (init) = 1;
     905       362725 :   TREE_SIDE_EFFECTS (init) = 0;
     906              : 
     907              :   /* We didn't split out anything.  */
     908       362725 :   if (num_split_elts == 0)
     909              :     return false;
     910              : 
     911       323910 :   return complete_p && complete_ctor_at_level_p (TREE_TYPE (init),
     912              :                                                  num_split_elts, inner_type);
     913              : }
     914              : 
     915              : /* A subroutine of store_init_value.  Splits non-constant static
     916              :    initializer INIT into a constant part and generates code to
     917              :    perform the non-constant part of the initialization to DEST.
     918              :    Returns the code for the runtime init.  */
     919              : 
     920              : tree
     921     15085428 : split_nonconstant_init (tree dest, tree init)
     922              : {
     923     15085428 :   tree code;
     924              : 
     925     15085428 :   if (TREE_CODE (init) == TARGET_EXPR)
     926       789724 :     init = TARGET_EXPR_INITIAL (init);
     927     15085428 :   if (TREE_CODE (init) == CONSTRUCTOR)
     928              :     {
     929              :       /* Subobject initializers are not full-expressions.  */
     930       360682 :       auto fe = (make_temp_override
     931       360682 :                  (current_stmt_tree ()->stmts_are_full_exprs_p, 0));
     932              : 
     933       360682 :       init = cp_fully_fold_init (init);
     934       360682 :       code = push_stmt_list ();
     935              : 
     936              :       /* If the complete object is an array, build_vec_init's cleanup is
     937              :          enough.  Otherwise, collect flags for disabling subobject
     938              :          cleanups once the complete object is fully constructed.  */
     939       360682 :       vec<tree, va_gc> *flags = nullptr;
     940       360682 :       if (TREE_CODE (TREE_TYPE (dest)) != ARRAY_TYPE)
     941       356269 :         flags = make_tree_vector ();
     942              : 
     943              :       /* We are about to call split_nonconstant_init_1 which might
     944              :          set DECL_INITIAL, so make sure we aren't overwriting an
     945              :          existing initializer.  Also, if we split out everything,
     946              :          we clear INIT so won't set DECL_INITIAL below.  Make
     947              :          sure it's null so that we're not forgetting to clear it.  */
     948       360682 :       gcc_assert (!(VAR_P (dest) && DECL_INITIAL (dest)));
     949              : 
     950       360682 :       if (split_nonconstant_init_1 (dest, init, true, &flags))
     951       203203 :         init = NULL_TREE;
     952              : 
     953      1075509 :       for (tree f : flags)
     954          937 :         finish_expr_stmt (build_disable_temp_cleanup (f));
     955       360682 :       release_tree_vector (flags);
     956              : 
     957       360682 :       code = pop_stmt_list (code);
     958       360682 :       if (VAR_P (dest) && !is_local_temp (dest))
     959              :         {
     960              :           /* If we are initializing an array, split_nonconstant_init_1
     961              :              might've delegated to build_vec_init in which case it always
     962              :              returns true so we clear INIT.  But if we're initializing
     963              :              a static array, build_vec_init can put constant initializers
     964              :              into DECL_INITIAL.  Clearing it would mean losing some of the
     965              :              initializers as in c++/126335.  */
     966       358862 :           if (init)
     967       157096 :             DECL_INITIAL (dest) = init;
     968       358862 :           if (TREE_SIDE_EFFECTS (code))
     969       322766 :             TREE_READONLY (dest) = 0;
     970              :         }
     971         1820 :       else if (init)
     972              :         {
     973          383 :           tree ie = cp_build_init_expr (dest, init);
     974          383 :           code = add_stmt_to_compound (ie, code);
     975              :         }
     976       360682 :     }
     977     14724746 :   else if (TREE_CODE (init) == STRING_CST
     978     14724746 :            && array_of_runtime_bound_p (TREE_TYPE (dest)))
     979           25 :     code = build_vec_init (dest, NULL_TREE, init, /*value-init*/false,
     980              :                            /*from array*/1, tf_warning_or_error);
     981              :   else
     982     14724721 :     code = cp_build_init_expr (dest, init);
     983              : 
     984     15085428 :   return code;
     985              : }
     986              : 
     987              : /* T is the initializer of a constexpr variable.  Set CONSTRUCTOR_MUTABLE_POISON
     988              :    for any CONSTRUCTOR within T that contains (directly or indirectly) a mutable
     989              :    member, thereby poisoning it so it can't be copied to another a constexpr
     990              :    variable or read during constexpr evaluation.  */
     991              : 
     992              : static void
     993     37456664 : poison_mutable_constructors (tree t)
     994              : {
     995     37456664 :   if (TREE_CODE (t) != CONSTRUCTOR)
     996              :     return;
     997              : 
     998      2768252 :   if (cp_has_mutable_p (TREE_TYPE (t)))
     999              :     {
    1000          163 :       CONSTRUCTOR_MUTABLE_POISON (t) = true;
    1001              : 
    1002          163 :       if (vec<constructor_elt, va_gc> *elts = CONSTRUCTOR_ELTS (t))
    1003          358 :         for (const constructor_elt &ce : *elts)
    1004          201 :           poison_mutable_constructors (ce.value);
    1005              :     }
    1006              : }
    1007              : 
    1008              : /* Perform appropriate conversions on the initial value of a variable,
    1009              :    store it in the declaration DECL,
    1010              :    and print any error messages that are appropriate.
    1011              :    If the init is invalid, store an ERROR_MARK.
    1012              : 
    1013              :    C++: Note that INIT might be a TREE_LIST, which would mean that it is
    1014              :    a base class initializer for some aggregate type, hopefully compatible
    1015              :    with DECL.  If INIT is a single element, and DECL is an aggregate
    1016              :    type, we silently convert INIT into a TREE_LIST, allowing a constructor
    1017              :    to be called.
    1018              : 
    1019              :    If INIT is a TREE_LIST and there is no constructor, turn INIT
    1020              :    into a CONSTRUCTOR and use standard initialization techniques.
    1021              :    Perhaps a warning should be generated?
    1022              : 
    1023              :    Returns code to be executed if initialization could not be performed
    1024              :    for static variable.  In that case, caller must emit the code.  */
    1025              : 
    1026              : tree
    1027     54479658 : store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
    1028              : {
    1029     54479658 :   tree value, type;
    1030              : 
    1031              :   /* If variable's type was invalidly declared, just ignore it.  */
    1032              : 
    1033     54479658 :   type = TREE_TYPE (decl);
    1034     54479658 :   if (TREE_CODE (type) == ERROR_MARK)
    1035              :     return NULL_TREE;
    1036              : 
    1037      4423412 :   if (MAYBE_CLASS_TYPE_P (type))
    1038              :     {
    1039      4392613 :       if (TREE_CODE (init) == TREE_LIST)
    1040              :         {
    1041            0 :           error ("constructor syntax used, but no constructor declared "
    1042              :                  "for type %qT", type);
    1043            0 :           init = build_constructor_from_list (init_list_type_node, nreverse (init));
    1044              :         }
    1045              :     }
    1046              : 
    1047              :   /* End of special C++ code.  */
    1048              : 
    1049     54479658 :   if (flags & LOOKUP_ALREADY_DIGESTED)
    1050              :     value = init;
    1051              :   else
    1052              :     {
    1053     51931705 :       if (TREE_STATIC (decl))
    1054     32208594 :         flags |= LOOKUP_ALLOW_FLEXARRAY_INIT;
    1055              :       /* Digest the specified initializer into an expression.  */
    1056     51931705 :       value = digest_init_flags (type, init, flags, tf_warning_or_error);
    1057              :     }
    1058              : 
    1059     54479658 :   current_ref_temp_count = 0;
    1060     54479658 :   value = extend_ref_init_temps (decl, value, cleanups);
    1061              : 
    1062              :   /* In C++11 constant expression is a semantic, not syntactic, property.
    1063              :      In C++98, make sure that what we thought was a constant expression at
    1064              :      template definition time is still constant and otherwise perform this
    1065              :      as optimization, e.g. to fold SIZEOF_EXPRs in the initializer.  */
    1066     54479658 :   if (decl_maybe_constant_var_p (decl) || TREE_STATIC (decl))
    1067              :     {
    1068     37459160 :       bool const_init;
    1069     37459160 :       tree oldval = value;
    1070     37459160 :       if (DECL_DECLARED_CONSTEXPR_P (decl)
    1071      6679839 :           || DECL_DECLARED_CONSTINIT_P (decl)
    1072     44138592 :           || (DECL_IN_AGGR_P (decl)
    1073      1314678 :               && DECL_INITIALIZED_IN_CLASS_P (decl)))
    1074              :         {
    1075              :           /* As in massage_init_elt, do not fold a CONSTRUCTOR in a template
    1076              :              it has already been folded c++/126811.  */
    1077     32094272 :           if (!(processing_template_decl && TREE_CODE (value) == CONSTRUCTOR))
    1078     32072610 :             value = fold_non_dependent_expr (value, tf_warning_or_error,
    1079              :                                              /*manifestly_const_eval=*/true,
    1080              :                                              decl);
    1081     32091575 :           if (value == error_mark_node)
    1082              :             ;
    1083              :           /* Diagnose a non-constant initializer for constexpr variable or
    1084              :              non-inline in-class-initialized static data member.  */
    1085     32091317 :           else if (!is_constant_expression (value))
    1086              :             {
    1087              :               /* Maybe we want to give this message for constexpr variables as
    1088              :                  well, but that will mean a lot of testsuite adjustment.  */
    1089          267 :               if (DECL_DECLARED_CONSTINIT_P (decl))
    1090           88 :               error_at (location_of (decl),
    1091              :                         "%<constinit%> variable %qD does not have a "
    1092              :                         "constant initializer", decl);
    1093          267 :               require_constant_expression (value);
    1094          267 :               value = error_mark_node;
    1095              :             }
    1096              :           else
    1097              :             {
    1098     32091050 :               value = maybe_constant_init (value, decl, true);
    1099              : 
    1100              :               /* In a template we might not have done the necessary
    1101              :                  transformations to make value actually constant,
    1102              :                  e.g. extend_ref_init_temps.  */
    1103     32091050 :               if (!processing_template_decl
    1104     32091050 :                   && !TREE_CONSTANT (value))
    1105              :                 {
    1106         2229 :                   if (DECL_DECLARED_CONSTINIT_P (decl))
    1107           41 :                   error_at (location_of (decl),
    1108              :                             "%<constinit%> variable %qD does not have a "
    1109              :                             "constant initializer", decl);
    1110         2229 :                   value = cxx_constant_init (value, decl);
    1111              :                 }
    1112              :             }
    1113              :         }
    1114              :       else
    1115      5364888 :         value = fold_non_dependent_init (value, tf_warning_or_error,
    1116              :                                          /*manifestly_const_eval=*/true, decl);
    1117     37456463 :       poison_mutable_constructors (value);
    1118     37456463 :       const_init = (reduced_constant_expression_p (value)
    1119     37456463 :                     || error_operand_p (value));
    1120     37456463 :       DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = const_init;
    1121              :       /* FIXME setting TREE_CONSTANT on refs breaks the back end.  */
    1122     37456463 :       if (!TYPE_REF_P (type))
    1123     40605937 :         TREE_CONSTANT (decl) = const_init && decl_maybe_constant_var_p (decl);
    1124     37456463 :       if (!const_init)
    1125     19868966 :         value = oldval;
    1126              :     }
    1127              :   /* Don't fold initializers of automatic variables in constexpr functions,
    1128              :      that might fold away something that needs to be diagnosed at constexpr
    1129              :      evaluation time.  */
    1130     54476961 :   if (!current_function_decl
    1131     21894083 :       || !maybe_constexpr_fn (current_function_decl)
    1132     60959471 :       || TREE_STATIC (decl))
    1133     48000112 :     value = cp_fully_fold_init (value);
    1134              : 
    1135              :   /* Handle aggregate NSDMI in non-constant initializers, too.  */
    1136     54476961 :   value = replace_placeholders (value, decl);
    1137              : 
    1138              :   /* Look for braced array initializers for character arrays and
    1139              :      recursively convert them into STRING_CSTs.  */
    1140     54476961 :   value = braced_lists_to_strings (type, value);
    1141              : 
    1142              :   /* Detect stuff like 'info r = ^^int;' outside a manifestly
    1143              :      constant-evaluated context.  */
    1144     54476961 :   if (flag_reflection
    1145      1668176 :       && !processing_template_decl
    1146     56056451 :       && !DECL_DECLARED_CONSTEXPR_P (decl))
    1147              :     {
    1148       344000 :       const bool mce_p
    1149       344000 :         = (decl_maybe_constant_var_p (decl)
    1150       344000 :            || (TREE_STATIC (decl)
    1151         7078 :                && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)));
    1152       344000 :       bool bad = check_out_of_consteval_use (value, /*complain=*/false);
    1153              :       /* A non-constexpr variable at namespace scope with a constant
    1154              :          initializer has constant initialization, so we check the folded
    1155              :          value not to wrongly reject "int e = (^^int, 42);".  For non-static
    1156              :          local variables, there is no such rule, so we check the unfolded
    1157              :          initializer.  But we should also reject
    1158              : 
    1159              :            consteval auto fn () { return ^^int; }
    1160              :            void g() { auto r = fn (); }
    1161              : 
    1162              :          so we may have to check both.  Note that the first call could
    1163              :          have escalated and so we may find ourselves in an immediate
    1164              :          context now.  */
    1165       344000 :       if (!bad && !mce_p && value != init)
    1166        97532 :         bad = check_out_of_consteval_use (init, /*complain=*/false);
    1167       344000 :       if (bad)
    1168              :         {
    1169          264 :           auto_diagnostic_group d;
    1170          264 :           error_at (DECL_SOURCE_LOCATION (decl),
    1171              :                     "%qD is initialized with a consteval-only value but is "
    1172              :                     "not declared %<constexpr%>", decl);
    1173          264 :           inform (DECL_SOURCE_LOCATION (decl), "add %<constexpr%>");
    1174          264 :           value = error_mark_node;
    1175          264 :         }
    1176              :     }
    1177              : 
    1178              :   /* A COMPOUND_LITERAL_P CONSTRUCTOR is the syntactic form; by the time we get
    1179              :      here it should have been digested into an actual value for the type.  */
    1180     54476961 :   gcc_checking_assert (TREE_CODE (value) != CONSTRUCTOR
    1181              :                        || processing_template_decl
    1182              :                        || VECTOR_TYPE_P (type)
    1183              :                        || !TREE_HAS_CONSTRUCTOR (value));
    1184              : 
    1185              :   /* If the initializer is not a constant, fill in DECL_INITIAL with
    1186              :      the bits that are constant, and then return an expression that
    1187              :      will perform the dynamic initialization.  */
    1188     54476961 :   if (value != error_mark_node
    1189     54470946 :       && !processing_template_decl
    1190    106450778 :       && (TREE_SIDE_EFFECTS (value)
    1191     44913089 :           || vla_type_p (type)
    1192     44912996 :           || ! reduced_constant_expression_p (value)))
    1193     15075958 :     return split_nonconstant_init (decl, value);
    1194              : 
    1195              :   /* DECL may change value; purge caches.  */
    1196     39401003 :   clear_cv_and_fold_caches ();
    1197              : 
    1198              :   /* If the value is a constant, just put it in DECL_INITIAL.  If DECL
    1199              :      is an automatic variable, the middle end will turn this into a
    1200              :      dynamic initialization later.  */
    1201     39401003 :   DECL_INITIAL (decl) = value;
    1202     39401003 :   return NULL_TREE;
    1203              : }
    1204              : 
    1205              : 
    1206              : /* Give diagnostic about narrowing conversions within { }, or as part of
    1207              :    a converted constant expression.  If CONST_ONLY, only check
    1208              :    constants.  */
    1209              : 
    1210              : bool
    1211     57520176 : check_narrowing (tree type, tree init, tsubst_flags_t complain,
    1212              :                  bool const_only/*= false*/)
    1213              : {
    1214     57520176 :   tree ftype = unlowered_expr_type (init);
    1215     57520176 :   bool ok = true;
    1216     57520176 :   REAL_VALUE_TYPE d;
    1217              : 
    1218     57469271 :   if (((!warn_narrowing || !(complain & tf_warning))
    1219      4247515 :        && cxx_dialect == cxx98)
    1220     57470176 :       || !ARITHMETIC_TYPE_P (type)
    1221              :       /* Don't emit bogus warnings with e.g. value-dependent trees.  */
    1222    114772158 :       || instantiation_dependent_expression_p (init))
    1223              :     return ok;
    1224              : 
    1225           18 :   if (BRACE_ENCLOSED_INITIALIZER_P (init)
    1226     57049188 :       && TREE_CODE (type) == COMPLEX_TYPE)
    1227              :     {
    1228            0 :       tree elttype = TREE_TYPE (type);
    1229            0 :       if (CONSTRUCTOR_NELTS (init) > 0)
    1230            0 :         ok &= check_narrowing (elttype, CONSTRUCTOR_ELT (init, 0)->value,
    1231              :                                complain);
    1232            0 :       if (CONSTRUCTOR_NELTS (init) > 1)
    1233            0 :         ok &= check_narrowing (elttype, CONSTRUCTOR_ELT (init, 1)->value,
    1234              :                                complain);
    1235              :       return ok;
    1236              :     }
    1237              : 
    1238              :   /* Even non-dependent expressions can still have template
    1239              :      codes like CAST_EXPR, so use *_non_dependent_expr to cope.  */
    1240     57049188 :   init = fold_non_dependent_expr (init, complain, /*manifest*/true);
    1241     57049188 :   if (init == error_mark_node)
    1242              :     return ok;
    1243              : 
    1244              :   /* If we were asked to only check constants, return early.  */
    1245     57049185 :   if (const_only && !TREE_CONSTANT (init))
    1246              :     return ok;
    1247              : 
    1248     57047674 :   if (CP_INTEGRAL_TYPE_P (type)
    1249     57033193 :       && SCALAR_FLOAT_TYPE_P (ftype))
    1250              :     ok = false;
    1251     57047454 :   else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
    1252     56822662 :            && CP_INTEGRAL_TYPE_P (type))
    1253              :     {
    1254     56816683 :       if (TREE_CODE (ftype) == ENUMERAL_TYPE)
    1255              :         /* Check for narrowing based on the values of the enumeration. */
    1256       322482 :         ftype = ENUM_UNDERLYING_TYPE (ftype);
    1257              :       /* Undo convert_bitfield_to_declared_type (STRIP_NOPS isn't enough).  */
    1258     56816683 :       tree op = init;
    1259     56821566 :       while (CONVERT_EXPR_P (op))
    1260         4883 :         op = TREE_OPERAND (op, 0);
    1261              :       /* Core 2627 says that we shouldn't warn when "the source is a bit-field
    1262              :          whose width w is less than that of its type (or, for an enumeration
    1263              :          type, its underlying type) and the target type can represent all the
    1264              :          values of a hypothetical extended integer type with width w and with
    1265              :          the same signedness as the original type".  */
    1266     56816683 :       if (is_bitfield_expr_with_lowered_type (op)
    1267     56816683 :           && TYPE_PRECISION (TREE_TYPE (op)) < TYPE_PRECISION (ftype))
    1268           70 :         ftype = TREE_TYPE (op);
    1269     56816683 :       if ((tree_int_cst_lt (TYPE_MAX_VALUE (type),
    1270     56816683 :                             TYPE_MAX_VALUE (ftype))
    1271     56608052 :            || tree_int_cst_lt (TYPE_MIN_VALUE (ftype),
    1272     56608052 :                                TYPE_MIN_VALUE (type)))
    1273    110977485 :           && (TREE_CODE (init) != INTEGER_CST
    1274     54369317 :               || !int_fits_type_p (init, type)))
    1275              :         ok = false;
    1276              :     }
    1277              :   /* [dcl.init.list]#7.2: "from long double to double or float, or from
    1278              :       double to float".  */
    1279       230771 :   else if (SCALAR_FLOAT_TYPE_P (ftype)
    1280         8502 :            && SCALAR_FLOAT_TYPE_P (type))
    1281              :     {
    1282        17049 :       if ((extended_float_type_p (ftype) || extended_float_type_p (type))
    1283         8493 :           ? /* "from a floating-point type T to another floating-point type
    1284              :                whose floating-point conversion rank is neither greater than
    1285              :                nor equal to that of T".
    1286              :                So, it is ok if
    1287              :                cp_compare_floating_point_conversion_ranks (ftype, type)
    1288              :                returns -2 (type has greater conversion rank than ftype)
    1289              :                or [-1..1] (type has equal conversion rank as ftype, possibly
    1290              :                different subrank.  Only do this if at least one of the
    1291              :                types is extended floating-point type, otherwise keep doing
    1292              :                what we did before (for the sake of non-standard
    1293              :                backend types).  */
    1294          458 :             cp_compare_floating_point_conversion_ranks (ftype, type) >= 2
    1295         8035 :           : ((same_type_p (ftype, long_double_type_node)
    1296           79 :               && (same_type_p (type, double_type_node)
    1297           67 :                   || same_type_p (type, float_type_node)))
    1298         8020 :              || (same_type_p (ftype, double_type_node)
    1299         7499 :                  && same_type_p (type, float_type_node))
    1300        10193 :              || (TYPE_PRECISION (type) < TYPE_PRECISION (ftype))))
    1301              :         {
    1302         5957 :           if (TREE_CODE (init) == REAL_CST)
    1303              :             {
    1304              :               /* Issue 703: Loss of precision is OK as long as the value is
    1305              :                  within the representable range of the new type.  */
    1306         5852 :               REAL_VALUE_TYPE r;
    1307         5852 :               d = TREE_REAL_CST (init);
    1308         5852 :               real_convert (&r, TYPE_MODE (type), &d);
    1309         5852 :               if (real_isinf (&r))
    1310            0 :                 ok = false;
    1311              :             }
    1312              :           else
    1313              :             ok = false;
    1314              :         }
    1315              :     }
    1316       222278 :   else if (INTEGRAL_OR_ENUMERATION_TYPE_P (ftype)
    1317         5979 :            && SCALAR_FLOAT_TYPE_P (type))
    1318              :     {
    1319         5944 :       ok = false;
    1320         5944 :       if (TREE_CODE (init) == INTEGER_CST)
    1321              :         {
    1322         5906 :           d = real_value_from_int_cst (0, init);
    1323         5906 :           if (exact_real_truncate (TYPE_MODE (type), &d))
    1324              :             ok = true;
    1325              :         }
    1326              :     }
    1327       216334 :   else if (TREE_CODE (type) == BOOLEAN_TYPE
    1328       216334 :            && (TYPE_PTR_P (ftype) || TYPE_PTRMEM_P (ftype)))
    1329              :     /* C++20 P1957R2: converting from a pointer type or a pointer-to-member
    1330              :        type to bool should be considered narrowing.  This is a DR so is not
    1331              :        limited to C++20 only.  */
    1332              :     ok = false;
    1333              : 
    1334         6779 :   bool almost_ok = ok;
    1335         6779 :   if (!ok && !CONSTANT_CLASS_P (init) && (complain & tf_warning_or_error))
    1336              :     {
    1337          161 :       tree folded = cp_fully_fold (init);
    1338          161 :       if (TREE_CONSTANT (folded) && check_narrowing (type, folded, tf_none))
    1339              :         almost_ok = true;
    1340              :     }
    1341              : 
    1342          927 :   if (!ok)
    1343              :     {
    1344          927 :       location_t loc = cp_expr_loc_or_input_loc (init);
    1345          927 :       if (cxx_dialect == cxx98)
    1346              :         {
    1347            1 :           if (complain & tf_warning)
    1348            1 :             warning_at (loc, OPT_Wnarrowing, "narrowing conversion of %qE "
    1349              :                         "from %qH to %qI is ill-formed in C++11",
    1350              :                         init, ftype, type);
    1351              :           ok = true;
    1352              :         }
    1353          926 :       else if (!CONSTANT_CLASS_P (init))
    1354              :         {
    1355          315 :           if (complain & tf_warning_or_error)
    1356              :             {
    1357          161 :               auto_diagnostic_group d;
    1358            4 :               if ((!almost_ok || pedantic)
    1359          304 :                   && pedwarn (loc, OPT_Wnarrowing,
    1360              :                               "narrowing conversion of %qE from %qH to %qI",
    1361              :                               init, ftype, type)
    1362          306 :                   && almost_ok)
    1363            2 :                 inform (loc, " the expression has a constant value but is not "
    1364              :                         "a C++ constant-expression");
    1365          161 :               ok = true;
    1366          161 :             }
    1367              :         }
    1368          611 :       else if (complain & tf_error)
    1369              :         {
    1370          597 :           int savederrorcount = errorcount;
    1371          597 :           permerror_opt (loc, OPT_Wnarrowing,
    1372              :                          "narrowing conversion of %qE from %qH to %qI",
    1373              :                          init, ftype, type);
    1374          597 :           if (errorcount == savederrorcount)
    1375     57519526 :             ok = true;
    1376              :         }
    1377              :     }
    1378              : 
    1379              :   return ok;
    1380              : }
    1381              : 
    1382              : /* True iff TYPE is a C++20 "ordinary" character type.  */
    1383              : 
    1384              : bool
    1385        43387 : ordinary_char_type_p (tree type)
    1386              : {
    1387        43387 :   type = TYPE_MAIN_VARIANT (type);
    1388        43387 :   return (type == char_type_node
    1389        21752 :           || type == signed_char_type_node
    1390        65117 :           || type == unsigned_char_type_node);
    1391              : }
    1392              : 
    1393              : /* True iff the string literal INIT has a type suitable for initializing array
    1394              :    TYPE.  */
    1395              : 
    1396              : bool
    1397       649805 : array_string_literal_compatible_p (tree type, tree init)
    1398              : {
    1399       649805 :   tree to_char_type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
    1400       649805 :   tree from_char_type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (init)));
    1401              : 
    1402       649805 :   if (to_char_type == from_char_type)
    1403              :     return true;
    1404              :   /* The array element type does not match the initializing string
    1405              :      literal element type; this is only allowed when both types are
    1406              :      ordinary character type.  There are no string literals of
    1407              :      signed or unsigned char type in the language, but we can get
    1408              :      them internally from converting braced-init-lists to
    1409              :      STRING_CST.  */
    1410        21738 :   if (ordinary_char_type_p (to_char_type)
    1411        21738 :       && ordinary_char_type_p (from_char_type))
    1412              :     return true;
    1413              : 
    1414              :   /* P2513 (C++20/C++23): "an array of char or unsigned char may
    1415              :      be initialized by a UTF-8 string literal, or by such a string
    1416              :      literal enclosed in braces."  */
    1417          190 :   if (from_char_type == char8_type_node
    1418           98 :       && (to_char_type == char_type_node
    1419           32 :           || to_char_type == unsigned_char_type_node))
    1420           73 :     return true;
    1421              : 
    1422              :   return false;
    1423              : }
    1424              : 
    1425              : /* Process the initializer INIT for a variable of type TYPE, emitting
    1426              :    diagnostics for invalid initializers and converting the initializer as
    1427              :    appropriate.
    1428              : 
    1429              :    For aggregate types, it assumes that reshape_init has already run, thus the
    1430              :    initializer will have the right shape (brace elision has been undone).
    1431              : 
    1432              :    NESTED is non-zero iff we are being called for an element of a CONSTRUCTOR,
    1433              :    2 iff the element of a CONSTRUCTOR is inside another CONSTRUCTOR.  */
    1434              : 
    1435              : static tree
    1436    117464495 : digest_init_r (tree type, tree init, int nested, int flags,
    1437              :                tsubst_flags_t complain)
    1438              : {
    1439    117464495 :   enum tree_code code = TREE_CODE (type);
    1440              : 
    1441    117464495 :   if (error_operand_p (init))
    1442         2164 :     return error_mark_node;
    1443              : 
    1444    117462331 :   gcc_assert (init);
    1445              : 
    1446              :   /* We must strip the outermost array type when completing the type,
    1447              :      because the its bounds might be incomplete at the moment.  */
    1448    118512829 :   if (!complete_type_or_maybe_complain (code == ARRAY_TYPE
    1449      1050498 :                                         ? TREE_TYPE (type) : type, NULL_TREE,
    1450              :                                         complain))
    1451           32 :     return error_mark_node;
    1452              : 
    1453    117462299 :   location_t loc = cp_expr_loc_or_input_loc (init);
    1454              : 
    1455    117462299 :   tree stripped_init = init;
    1456              : 
    1457     11427165 :   if (BRACE_ENCLOSED_INITIALIZER_P (init)
    1458    128885552 :       && CONSTRUCTOR_IS_PAREN_INIT (init))
    1459         1617 :     flags |= LOOKUP_AGGREGATE_PAREN_INIT;
    1460              : 
    1461              :   /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue
    1462              :      (g++.old-deja/g++.law/casts2.C).  */
    1463    117462299 :   if (TREE_CODE (init) == NON_LVALUE_EXPR)
    1464     32773653 :     stripped_init = TREE_OPERAND (init, 0);
    1465              : 
    1466    117462299 :   stripped_init = tree_strip_any_location_wrapper (stripped_init);
    1467              : 
    1468              :   /* Initialization of an array of chars from a string constant. The initializer
    1469              :      can be optionally enclosed in braces, but reshape_init has already removed
    1470              :      them if they were present.  */
    1471    117462299 :   if (code == ARRAY_TYPE)
    1472              :     {
    1473      1173504 :       if (nested && !TYPE_DOMAIN (type))
    1474              :         /* C++ flexible array members have a null domain.  */
    1475              :         {
    1476          460 :           if (flags & LOOKUP_ALLOW_FLEXARRAY_INIT)
    1477          409 :             pedwarn (loc, OPT_Wpedantic,
    1478              :                      "initialization of a flexible array member");
    1479              :           else
    1480              :             {
    1481           51 :               if (complain & tf_error)
    1482           51 :                 error_at (loc, "non-static initialization of"
    1483              :                                " a flexible array member");
    1484           51 :               return error_mark_node;
    1485              :             }
    1486              :         }
    1487              : 
    1488      1050447 :       tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
    1489      1050447 :       if (char_type_p (typ1)
    1490      1050447 :           && TREE_CODE (stripped_init) == STRING_CST)
    1491              :         {
    1492       649760 :           if (!array_string_literal_compatible_p (type, init))
    1493              :             {
    1494          111 :               if (complain & tf_error)
    1495          111 :                 error_at (loc, "cannot initialize array of %qT from "
    1496              :                           "a string literal with type array of %qT",
    1497              :                           typ1,
    1498          111 :                           TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (init))));
    1499          111 :               return error_mark_node;
    1500              :             }
    1501              : 
    1502       650034 :           if (nested == 2 && !TYPE_DOMAIN (type))
    1503              :             {
    1504           24 :               if (complain & tf_error)
    1505           24 :                 error_at (loc, "initialization of flexible array member "
    1506              :                                "in a nested context");
    1507           24 :               return error_mark_node;
    1508              :             }
    1509              : 
    1510       649625 :           if (type != TREE_TYPE (init)
    1511       649625 :               && !variably_modified_type_p (type, NULL_TREE))
    1512              :             {
    1513        23813 :               init = copy_node (init);
    1514        23813 :               TREE_TYPE (init) = type;
    1515              :               /* If we have a location wrapper, then also copy the wrapped
    1516              :                  node, and update the copy's type.  */
    1517        23813 :               if (location_wrapper_p (init))
    1518              :                 {
    1519        22884 :                   stripped_init = copy_node (stripped_init);
    1520        22884 :                   TREE_OPERAND (init, 0) = stripped_init;
    1521        22884 :                   TREE_TYPE (stripped_init) = type;
    1522              :                 }
    1523              :             }
    1524       649625 :           if (TYPE_DOMAIN (type) && TREE_CONSTANT (TYPE_SIZE (type)))
    1525              :             {
    1526              :               /* Not a flexible array member.  */
    1527       649555 :               int size = TREE_INT_CST_LOW (TYPE_SIZE (type));
    1528       649555 :               size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
    1529              :               /* In C it is ok to subtract 1 from the length of the string
    1530              :                  because it's ok to ignore the terminating null char that is
    1531              :                  counted in the length of the constant, but in C++ this would
    1532              :                  be invalid.  */
    1533       649555 :               if (size < TREE_STRING_LENGTH (stripped_init))
    1534              :                 {
    1535          159 :                   permerror (loc, "initializer-string for %qT is too long",
    1536              :                              type);
    1537              : 
    1538          159 :                   init = build_string (size,
    1539          159 :                                        TREE_STRING_POINTER (stripped_init));
    1540          159 :                   TREE_TYPE (init) = type;
    1541              :                 }
    1542              :             }
    1543              :           return init;
    1544              :         }
    1545              :     }
    1546              : 
    1547              :   /* Handle scalar types (including conversions) and references.  */
    1548         1220 :   if ((code != COMPLEX_TYPE || BRACE_ENCLOSED_INITIALIZER_P (stripped_init))
    1549    116812533 :       && (SCALAR_TYPE_P (type) || code == REFERENCE_TYPE))
    1550              :     {
    1551              :       /* Narrowing is OK when initializing an aggregate from
    1552              :          a parenthesized list.  */
    1553    105613257 :       if (nested && !(flags & LOOKUP_AGGREGATE_PAREN_INIT))
    1554     55664503 :         flags |= LOOKUP_NO_NARROWING;
    1555    105613257 :       if (TREE_CODE (init) == RAW_DATA_CST && !TYPE_UNSIGNED (type))
    1556              :         {
    1557           52 :           tree ret = init;
    1558           52 :           if ((flags & LOOKUP_NO_NARROWING) || warn_conversion)
    1559       226202 :             for (unsigned int i = 0;
    1560       226254 :                  i < (unsigned) RAW_DATA_LENGTH (init); ++i)
    1561       226202 :               if (RAW_DATA_SCHAR_ELT (init, i) < 0)
    1562              :                 {
    1563           60 :                   if ((flags & LOOKUP_NO_NARROWING))
    1564              :                     {
    1565           60 :                       tree elt
    1566           60 :                         = build_int_cst (integer_type_node,
    1567           60 :                                          RAW_DATA_UCHAR_ELT (init, i));
    1568           60 :                       if (!check_narrowing (type, elt, complain, false))
    1569              :                         {
    1570           30 :                           if (!(complain & tf_warning_or_error))
    1571            0 :                             ret = error_mark_node;
    1572           30 :                           continue;
    1573              :                         }
    1574              :                     }
    1575           30 :                   if (warn_conversion)
    1576           60 :                     warning (OPT_Wconversion,
    1577              :                              "conversion from %qT to %qT changes value from "
    1578              :                              "%qd to %qd",
    1579              :                              integer_type_node, type,
    1580           30 :                              RAW_DATA_UCHAR_ELT (init, i),
    1581           30 :                              RAW_DATA_SCHAR_ELT (init, i));
    1582              :                 }
    1583              :           return ret;
    1584              :         }
    1585    105613205 :       init = convert_for_initialization (0, type, init, flags,
    1586              :                                          ICR_INIT, NULL_TREE, 0,
    1587              :                                          complain);
    1588              : 
    1589    105613205 :       return init;
    1590              :     }
    1591              : 
    1592              :   /* Come here only for aggregates: records, arrays, unions, complex numbers
    1593              :      and vectors.  */
    1594     11199231 :   gcc_assert (code == ARRAY_TYPE
    1595              :               || VECTOR_TYPE_P (type)
    1596              :               || code == RECORD_TYPE
    1597              :               || code == UNION_TYPE
    1598              :               || code == OPAQUE_TYPE
    1599              :               || code == COMPLEX_TYPE);
    1600              : 
    1601              :   /* "If T is a class type and the initializer list has a single
    1602              :      element of type cv U, where U is T or a class derived from T,
    1603              :      the object is initialized from that element."  */
    1604     11199231 :   if (cxx_dialect >= cxx11
    1605     11160845 :       && BRACE_ENCLOSED_INITIALIZER_P (stripped_init)
    1606     10825847 :       && !CONSTRUCTOR_IS_DESIGNATED_INIT (stripped_init)
    1607     10458520 :       && CONSTRUCTOR_NELTS (stripped_init) == 1
    1608     11772750 :       && ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type))
    1609        84240 :           || VECTOR_TYPE_P (type)))
    1610              :     {
    1611       489662 :       tree elt = CONSTRUCTOR_ELT (stripped_init, 0)->value;
    1612       489662 :       if (reference_related_p (type, TREE_TYPE (elt)))
    1613              :         {
    1614              :           /* In C++17, aggregates can have bases, thus participate in
    1615              :              aggregate initialization.  In the following case:
    1616              : 
    1617              :                struct B { int c; };
    1618              :                struct D : B { };
    1619              :                D d{{D{{42}}}};
    1620              : 
    1621              :             there's an extra set of braces, so the D temporary initializes
    1622              :             the first element of d, which is the B base subobject.  The base
    1623              :             of type B is copy-initialized from the D temporary, causing
    1624              :             object slicing.  */
    1625           30 :           tree field = next_aggregate_field (TYPE_FIELDS (type));
    1626           60 :           if (field && DECL_FIELD_IS_BASE (field))
    1627              :             {
    1628           30 :               auto_diagnostic_group d;
    1629           30 :               if (warning_at (loc, 0, "initializing a base class of type %qT "
    1630           30 :                               "results in object slicing", TREE_TYPE (field)))
    1631           30 :                 inform (loc, "remove %<{ }%> around initializer");
    1632           30 :             }
    1633            0 :           else if (flag_checking)
    1634              :             /* We should have fixed this in reshape_init.  */
    1635            0 :             gcc_unreachable ();
    1636              :         }
    1637              :     }
    1638              : 
    1639     11199231 :   if (SIMPLE_TARGET_EXPR_P (stripped_init))
    1640        21259 :     stripped_init = TARGET_EXPR_INITIAL (stripped_init);
    1641              : 
    1642     10851579 :   if (BRACE_ENCLOSED_INITIALIZER_P (stripped_init)
    1643     22042337 :       && !TYPE_NON_AGGREGATE_CLASS (type))
    1644     10476813 :     return process_init_constructor (type, stripped_init, nested, flags,
    1645     10476813 :                                      complain);
    1646              :   else
    1647              :     {
    1648       722418 :       if (COMPOUND_LITERAL_P (stripped_init) && code == ARRAY_TYPE)
    1649              :         {
    1650            0 :           if (complain & tf_error)
    1651            0 :             error_at (loc, "cannot initialize aggregate of type %qT with "
    1652              :                       "a compound literal", type);
    1653              : 
    1654            0 :           return error_mark_node;
    1655              :         }
    1656              : 
    1657       722418 :       if (code == ARRAY_TYPE
    1658       722418 :           && !BRACE_ENCLOSED_INITIALIZER_P (stripped_init))
    1659              :         {
    1660              :           /* Allow the result of build_array_copy and of
    1661              :              build_value_init_noctor.  */
    1662          212 :           if ((TREE_CODE (stripped_init) == VEC_INIT_EXPR
    1663          193 :                || TREE_CODE (stripped_init) == CONSTRUCTOR)
    1664          380 :               && (same_type_ignoring_top_level_qualifiers_p
    1665          168 :                   (type, TREE_TYPE (init))))
    1666              :             return init;
    1667              : 
    1668           53 :           if (complain & tf_error)
    1669           53 :             error_at (loc, "array must be initialized with a brace-enclosed"
    1670              :                       " initializer");
    1671           53 :           return error_mark_node;
    1672              :         }
    1673              : 
    1674       722206 :       return convert_for_initialization (NULL_TREE, type, init,
    1675              :                                          flags,
    1676              :                                          ICR_INIT, NULL_TREE, 0,
    1677       722206 :                                          complain);
    1678              :     }
    1679              : }
    1680              : 
    1681              : tree
    1682      1416094 : digest_init (tree type, tree init, tsubst_flags_t complain)
    1683              : {
    1684      1416094 :   return digest_init_r (type, init, 0, LOOKUP_IMPLICIT, complain);
    1685              : }
    1686              : 
    1687              : tree
    1688     58140356 : digest_init_flags (tree type, tree init, int flags, tsubst_flags_t complain)
    1689              : {
    1690     58140356 :   return digest_init_r (type, init, 0, flags, complain);
    1691              : }
    1692              : 
    1693              : /* Callback to replace PLACEHOLDER_EXPRs in a TARGET_EXPR (which isn't used
    1694              :    in the context of guaranteed copy elision).  */
    1695              : 
    1696              : static tree
    1697      3168177 : replace_placeholders_for_class_temp_r (tree *tp, int *, void *)
    1698              : {
    1699      3168177 :   tree t = *tp;
    1700              : 
    1701              :   /* We're looking for a TARGET_EXPR nested in the whole expression.  */
    1702      3168177 :   if (TREE_CODE (t) == TARGET_EXPR
    1703              :       /* That serves as temporary materialization, not an initializer.  */
    1704      3168177 :       && !TARGET_EXPR_ELIDING_P (t))
    1705              :     {
    1706         1707 :       tree init = TARGET_EXPR_INITIAL (t);
    1707         1710 :       while (TREE_CODE (init) == COMPOUND_EXPR)
    1708            3 :         init = TREE_OPERAND (init, 1);
    1709         1707 :       if (TREE_CODE (init) == CONSTRUCTOR
    1710         1707 :           && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init))
    1711              :         {
    1712          129 :           tree obj = TARGET_EXPR_SLOT (t);
    1713          129 :           replace_placeholders (init, obj);
    1714              :           /* We should have dealt with all PLACEHOLDER_EXPRs.  */
    1715          129 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = false;
    1716          129 :           gcc_checking_assert (!find_placeholders (init));
    1717              :         }
    1718              :     }
    1719              : 
    1720      3168177 :   return NULL_TREE;
    1721              : }
    1722              : 
    1723              : /* Process the initializer INIT for an NSDMI DECL (a FIELD_DECL).  */
    1724              : tree
    1725       742340 : digest_nsdmi_init (tree decl, tree init, tsubst_flags_t complain)
    1726              : {
    1727       742340 :   gcc_assert (TREE_CODE (decl) == FIELD_DECL);
    1728              : 
    1729       742340 :   tree type = TREE_TYPE (decl);
    1730       742340 :   if (DECL_BIT_FIELD_TYPE (decl))
    1731          144 :     type = DECL_BIT_FIELD_TYPE (decl);
    1732       742340 :   int flags = LOOKUP_IMPLICIT;
    1733       742340 :   if (DIRECT_LIST_INIT_P (init))
    1734              :     {
    1735        88906 :       flags = LOOKUP_NORMAL;
    1736        88906 :       complain |= tf_no_cleanup;
    1737              :     }
    1738       230722 :   if (BRACE_ENCLOSED_INITIALIZER_P (init)
    1739       973062 :       && CP_AGGREGATE_TYPE_P (type))
    1740       126924 :     init = reshape_init (type, init, complain);
    1741       742340 :   init = digest_init_flags (type, init, flags, complain);
    1742              : 
    1743              :   /* Fold away any non-ODR used constants so that we don't need to
    1744              :      stream them in modules.  */
    1745       742340 :   init = cp_fold_non_odr_use (init, /*rval=*/!TYPE_REF_P (type));
    1746              : 
    1747       742340 :   set_target_expr_eliding (init);
    1748              : 
    1749              :   /* We may have temporary materialization in a NSDMI, if the initializer
    1750              :      has something like A{} in it.  Digesting the {} could have introduced
    1751              :      a PLACEHOLDER_EXPR referring to A.  Now that we've got a TARGET_EXPR,
    1752              :      we have an object we can refer to.  The reason we bother doing this
    1753              :      here is for code like
    1754              : 
    1755              :        struct A {
    1756              :          int x;
    1757              :          int y = x;
    1758              :        };
    1759              : 
    1760              :        struct B {
    1761              :          int x = 0;
    1762              :          int y = A{x}.y; // #1
    1763              :        };
    1764              : 
    1765              :      where in #1 we don't want to end up with two PLACEHOLDER_EXPRs for
    1766              :      different types on the same level in a {} when lookup_placeholder
    1767              :      wouldn't find a named object for the PLACEHOLDER_EXPR for A.  Note,
    1768              :      temporary materialization does not occur when initializing an object
    1769              :      from a prvalue of the same type, therefore we must not replace the
    1770              :      placeholder with a temporary object so that it can be elided.  */
    1771       742340 :   cp_walk_tree_without_duplicates (&init, replace_placeholders_for_class_temp_r,
    1772              :                                    nullptr);
    1773              : 
    1774       742340 :   return init;
    1775              : }
    1776              : 
    1777              : /* Set of flags used within process_init_constructor to describe the
    1778              :    initializers.  */
    1779              : #define PICFLAG_ERRONEOUS 1
    1780              : #define PICFLAG_NOT_ALL_CONSTANT 2
    1781              : #define PICFLAG_NOT_ALL_SIMPLE 4
    1782              : #define PICFLAG_SIDE_EFFECTS 8
    1783              : #define PICFLAG_VEC_INIT 16
    1784              : 
    1785              : /* Given an initializer INIT, return the flag (PICFLAG_*) which better
    1786              :    describe it.  */
    1787              : 
    1788              : static int
    1789     58444440 : picflag_from_initializer (tree init)
    1790              : {
    1791     58444440 :   if (init == error_mark_node)
    1792              :     return PICFLAG_ERRONEOUS;
    1793     58443958 :   else if (!TREE_CONSTANT (init))
    1794              :     {
    1795      1633550 :       if (TREE_SIDE_EFFECTS (init))
    1796              :         return PICFLAG_SIDE_EFFECTS;
    1797              :       else
    1798      1386157 :         return PICFLAG_NOT_ALL_CONSTANT;
    1799              :     }
    1800     56810408 :   else if (!initializer_constant_valid_p (init, TREE_TYPE (init)))
    1801        91516 :     return PICFLAG_NOT_ALL_SIMPLE;
    1802              :   return 0;
    1803              : }
    1804              : 
    1805              : /* Adjust INIT for going into a CONSTRUCTOR.  */
    1806              : 
    1807              : static tree
    1808     57908045 : massage_init_elt (tree type, tree init, int nested, int flags,
    1809              :                   tsubst_flags_t complain)
    1810              : {
    1811     57908045 :   int new_flags = LOOKUP_IMPLICIT;
    1812     57908045 :   if (flags & LOOKUP_ALLOW_FLEXARRAY_INIT)
    1813     53513862 :     new_flags |= LOOKUP_ALLOW_FLEXARRAY_INIT;
    1814     57908045 :   if (flags & LOOKUP_AGGREGATE_PAREN_INIT)
    1815         2617 :     new_flags |= LOOKUP_AGGREGATE_PAREN_INIT;
    1816    111652334 :   init = digest_init_r (type, init, nested ? 2 : 1, new_flags, complain);
    1817              :   /* When we defer constant folding within a statement, we may want to
    1818              :      defer this folding as well.  Don't call this on CONSTRUCTORs in
    1819              :      a template because their elements have already been folded, and
    1820              :      we must avoid folding the result of get_nsdmi.  */
    1821     57908045 :   if (!(processing_template_decl && TREE_CODE (init) == CONSTRUCTOR))
    1822              :     {
    1823     57907800 :       tree t = fold_non_dependent_init (init, complain);
    1824     57907800 :       if (TREE_CONSTANT (t))
    1825     56295268 :         init = t;
    1826     57907800 :       set_target_expr_eliding (init);
    1827              :     }
    1828     57908045 :   return init;
    1829              : }
    1830              : 
    1831              : /* Subroutine of process_init_constructor, which will process an initializer
    1832              :    INIT for an array or vector of type TYPE. Returns the flags (PICFLAG_*)
    1833              :    which describe the initializers.  */
    1834              : 
    1835              : static int
    1836       450561 : process_init_constructor_array (tree type, tree init, int nested, int flags,
    1837              :                                 tsubst_flags_t complain)
    1838              : {
    1839       450561 :   unsigned HOST_WIDE_INT i, j, len = 0;
    1840       450561 :   int picflags = 0;
    1841       450561 :   bool unbounded = false;
    1842       450561 :   constructor_elt *ce;
    1843       450561 :   vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (init);
    1844              : 
    1845       450561 :   gcc_assert (TREE_CODE (type) == ARRAY_TYPE
    1846              :               || VECTOR_TYPE_P (type));
    1847              : 
    1848       450561 :   if (TREE_CODE (type) == ARRAY_TYPE)
    1849              :     {
    1850              :       /* C++ flexible array members have a null domain.  */
    1851       400475 :       tree domain = TYPE_DOMAIN (type);
    1852       400475 :       if (domain && TREE_CONSTANT (TYPE_MAX_VALUE (domain)))
    1853       800034 :         len = wi::ext (wi::to_offset (TYPE_MAX_VALUE (domain))
    1854       800034 :                        - wi::to_offset (TYPE_MIN_VALUE (domain)) + 1,
    1855       400017 :                        TYPE_PRECISION (TREE_TYPE (domain)),
    1856       800034 :                        TYPE_SIGN (TREE_TYPE (domain))).to_uhwi ();
    1857              :       else
    1858              :         unbounded = true;  /* Take as many as there are.  */
    1859              : 
    1860       400475 :       if (nested == 2 && !domain && !vec_safe_is_empty (v))
    1861              :         {
    1862           68 :           if (complain & tf_error)
    1863          136 :             error_at (cp_expr_loc_or_input_loc (init),
    1864              :                       "initialization of flexible array member "
    1865              :                       "in a nested context");
    1866              :           return PICFLAG_ERRONEOUS;
    1867              :         }
    1868              :     }
    1869              :   else
    1870              :     /* Vectors are like simple fixed-size arrays.  */
    1871        50086 :     unbounded = !TYPE_VECTOR_SUBPARTS (type).is_constant (&len);
    1872              : 
    1873              :   /* There must not be more initializers than needed.  */
    1874       450493 :   if (!unbounded && vec_safe_length (v) > len)
    1875              :     {
    1876           14 :       if (complain & tf_error)
    1877           14 :         error ("too many initializers for %qT", type);
    1878              :       else
    1879              :         return PICFLAG_ERRONEOUS;
    1880              :     }
    1881              : 
    1882       450493 :   j = 0;
    1883     51554673 :   FOR_EACH_VEC_SAFE_ELT (v, i, ce)
    1884              :     {
    1885     51104180 :       if (!ce->index)
    1886          634 :         ce->index = size_int (j);
    1887     51103546 :       else if (!check_array_designated_initializer (ce, j))
    1888            0 :         ce->index = error_mark_node;
    1889     51104180 :       gcc_assert (ce->value);
    1890     51104180 :       ce->value
    1891     51104180 :         = massage_init_elt (TREE_TYPE (type), ce->value, nested, flags,
    1892              :                             complain);
    1893              : 
    1894     51104180 :       gcc_checking_assert
    1895              :         (ce->value == error_mark_node
    1896              :          || (same_type_ignoring_top_level_qualifiers_p
    1897              :              (strip_array_types (TREE_TYPE (type)),
    1898              :               strip_array_types (TREE_TYPE (ce->value)))));
    1899              : 
    1900     51104180 :       picflags |= picflag_from_initializer (ce->value);
    1901              :       /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer
    1902              :          CONSTRUCTOR.  */
    1903     51104180 :       if (TREE_CODE (ce->value) == CONSTRUCTOR
    1904     51104180 :           && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value))
    1905              :         {
    1906           17 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    1907           17 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value) = 0;
    1908              :         }
    1909     51104180 :       if (TREE_CODE (ce->value) == RAW_DATA_CST)
    1910          304 :         j += RAW_DATA_LENGTH (ce->value);
    1911              :       else
    1912     51103876 :         ++j;
    1913              :     }
    1914              : 
    1915              :   /* No more initializers. If the array is unbounded, we are done. Otherwise,
    1916              :      we must add initializers ourselves.  */
    1917       450493 :   if (!unbounded)
    1918       450196 :     for (; i < len; ++i)
    1919              :       {
    1920        38301 :         tree next;
    1921              : 
    1922        38301 :         if (type_build_ctor_call (TREE_TYPE (type)))
    1923              :           {
    1924              :             /* If this type needs constructors run for default-initialization,
    1925              :                we can't rely on the back end to do it for us, so make the
    1926              :                initialization explicit by list-initializing from T{}.  */
    1927          606 :             next = build_constructor (init_list_type_node, NULL);
    1928          606 :             next = massage_init_elt (TREE_TYPE (type), next, nested, flags,
    1929              :                                      complain);
    1930          606 :             if (initializer_zerop (next))
    1931              :               /* The default zero-initialization is fine for us; don't
    1932              :                  add anything to the CONSTRUCTOR.  */
    1933              :               next = NULL_TREE;
    1934              :           }
    1935        37695 :         else if (!zero_init_p (TREE_TYPE (type)))
    1936          147 :           next = build_zero_init (TREE_TYPE (type),
    1937              :                                   /*nelts=*/NULL_TREE,
    1938              :                                   /*static_storage_p=*/false);
    1939              :         else
    1940              :           /* The default zero-initialization is fine for us; don't
    1941              :              add anything to the CONSTRUCTOR.  */
    1942              :           next = NULL_TREE;
    1943              : 
    1944          433 :         if (next)
    1945              :           {
    1946          433 :             if (next != error_mark_node
    1947          433 :                 && (initializer_constant_valid_p (next, TREE_TYPE (next))
    1948          421 :                     != null_pointer_node))
    1949              :               {
    1950              :                 /* Use VEC_INIT_EXPR for non-constant initialization of
    1951              :                    trailing elements with no explicit initializers.  */
    1952          227 :                 picflags |= PICFLAG_VEC_INIT;
    1953          227 :                 break;
    1954              :               }
    1955              : 
    1956          206 :             picflags |= picflag_from_initializer (next);
    1957              :             /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer
    1958              :                CONSTRUCTOR.  */
    1959          206 :             if (TREE_CODE (next) == CONSTRUCTOR
    1960          206 :                 && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next))
    1961              :               {
    1962            0 :                 CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    1963            0 :                 CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next) = 0;
    1964              :               }
    1965          206 :             if (len > i+1)
    1966              :               {
    1967          113 :                 tree range = build2 (RANGE_EXPR, size_type_node,
    1968          113 :                                      build_int_cst (size_type_node, i),
    1969          113 :                                      build_int_cst (size_type_node, len - 1));
    1970          113 :                 CONSTRUCTOR_APPEND_ELT (v, range, next);
    1971          113 :                 break;
    1972              :               }
    1973              :             else
    1974           93 :               CONSTRUCTOR_APPEND_ELT (v, size_int (i), next);
    1975              :           }
    1976              :         else
    1977              :           /* Don't bother checking all the other elements.  */
    1978              :           break;
    1979              :       }
    1980              : 
    1981       450493 :   CONSTRUCTOR_ELTS (init) = v;
    1982       450493 :   return picflags;
    1983              : }
    1984              : 
    1985              : /* Subroutine of process_init_constructor, which will process an initializer
    1986              :    INIT for a class of type TYPE. Returns the flags (PICFLAG_*) which describe
    1987              :    the initializers.  */
    1988              : 
    1989              : static int
    1990      9908204 : process_init_constructor_record (tree type, tree init, int nested, int flags,
    1991              :                                  tsubst_flags_t complain)
    1992              : {
    1993      9908204 :   vec<constructor_elt, va_gc> *v = NULL;
    1994      9908204 :   tree field;
    1995      9908204 :   int skipped = 0;
    1996              : 
    1997      9908204 :   gcc_assert (TREE_CODE (type) == RECORD_TYPE);
    1998      9908204 :   gcc_assert (!CLASSTYPE_VBASECLASSES (type));
    1999      9908204 :   gcc_assert (!TYPE_BINFO (type)
    2000              :               || cxx_dialect >= cxx17
    2001              :               || !BINFO_N_BASE_BINFOS (TYPE_BINFO (type)));
    2002      9908204 :   gcc_assert (!TYPE_POLYMORPHIC_P (type));
    2003              : 
    2004      9908204 :  restart:
    2005      9934927 :   int picflags = 0;
    2006      9934927 :   unsigned HOST_WIDE_INT idx = 0;
    2007      9934927 :   int designator_skip = -1;
    2008              :   /* Generally, we will always have an index for each initializer (which is
    2009              :      a FIELD_DECL, put by reshape_init), but compound literals don't go trough
    2010              :      reshape_init. So we need to handle both cases.  */
    2011     95995185 :   for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
    2012              :     {
    2013     86087608 :       tree next;
    2014              : 
    2015    163956926 :       if (TREE_CODE (field) != FIELD_DECL
    2016     86087608 :           || (DECL_ARTIFICIAL (field)
    2017       733460 :               && !(cxx_dialect >= cxx17 && DECL_FIELD_IS_BASE (field))))
    2018     77869318 :         continue;
    2019              : 
    2020      8218290 :       if (DECL_UNNAMED_BIT_FIELD (field))
    2021          152 :         continue;
    2022              : 
    2023              :       /* If this is a bitfield, first convert to the declared type.  */
    2024      8218138 :       tree fldtype = TREE_TYPE (field);
    2025      8218138 :       if (DECL_BIT_FIELD_TYPE (field))
    2026       268847 :         fldtype = DECL_BIT_FIELD_TYPE (field);
    2027      8218138 :       if (fldtype == error_mark_node)
    2028              :         return PICFLAG_ERRONEOUS;
    2029              : 
    2030      8218121 :       next = NULL_TREE;
    2031      8218121 :       if (idx < CONSTRUCTOR_NELTS (init))
    2032              :         {
    2033      6666792 :           constructor_elt *ce = &(*CONSTRUCTOR_ELTS (init))[idx];
    2034      6666792 :           if (ce->index)
    2035              :             {
    2036              :               /* We can have either a FIELD_DECL or an IDENTIFIER_NODE. The
    2037              :                  latter case can happen in templates where lookup has to be
    2038              :                  deferred.  */
    2039      6664845 :               gcc_assert (TREE_CODE (ce->index) == FIELD_DECL
    2040              :                           || identifier_p (ce->index));
    2041      6664845 :               if (ce->index == field || ce->index == DECL_NAME (field))
    2042      6664282 :                 next = ce->value;
    2043              :               else
    2044              :                 {
    2045          563 :                   ce = NULL;
    2046          563 :                   if (designator_skip == -1)
    2047              :                     designator_skip = 1;
    2048              :                 }
    2049              :             }
    2050              :           else
    2051              :             {
    2052         1947 :               designator_skip = 0;
    2053         1947 :               next = ce->value;
    2054              :             }
    2055              : 
    2056      6666229 :           if (ce)
    2057              :             {
    2058      6666229 :               gcc_assert (ce->value);
    2059      6666229 :               next = massage_init_elt (fldtype, next, nested, flags, complain);
    2060      6666229 :               ++idx;
    2061              :             }
    2062              :         }
    2063      8218121 :       if (next == error_mark_node)
    2064              :         /* We skip initializers for empty bases/fields, so skipping an invalid
    2065              :            one could make us accept invalid code.  */
    2066              :         return PICFLAG_ERRONEOUS;
    2067      8217511 :       else if (next)
    2068              :         /* Already handled above.  */;
    2069      1551892 :       else if (DECL_INITIAL (field))
    2070              :         {
    2071       265383 :           if (skipped > 0)
    2072              :             {
    2073              :               /* We're using an NSDMI past a field with implicit
    2074              :                  zero-init.  Go back and make it explicit.  */
    2075        26723 :               skipped = -1;
    2076        26723 :               vec_safe_truncate (v, 0);
    2077        26723 :               goto restart;
    2078              :             }
    2079              :           /* C++14 aggregate NSDMI.  */
    2080       238660 :           next = get_nsdmi (field, /*ctor*/false, complain);
    2081       238660 :           if (!CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init)
    2082       238660 :               && find_placeholders (next))
    2083          988 :             CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    2084              :         }
    2085      1286509 :       else if (type_build_ctor_call (fldtype))
    2086              :         {
    2087              :           /* If this type needs constructors run for
    2088              :              default-initialization, we can't rely on the back end to do it
    2089              :              for us, so build up TARGET_EXPRs.  If the type in question is
    2090              :              a class, just build one up; if it's an array, recurse.  */
    2091        28630 :           next = build_constructor (init_list_type_node, NULL);
    2092        28630 :           next = massage_init_elt (fldtype, next, nested, flags, complain);
    2093        28630 :           if (TREE_CODE (next) == TARGET_EXPR
    2094        28630 :               && unsafe_copy_elision_p (field, next))
    2095            0 :             TARGET_EXPR_ELIDING_P (next) = false;
    2096              : 
    2097              :           /* Warn when some struct elements are implicitly initialized.  */
    2098        28630 :           if ((complain & tf_warning)
    2099        10809 :               && !cp_unevaluated_operand
    2100        39414 :               && !EMPTY_CONSTRUCTOR_P (init))
    2101          102 :             warning (OPT_Wmissing_field_initializers,
    2102              :                      "missing initializer for member %qD", field);
    2103              :         }
    2104              :       else
    2105              :         {
    2106      1257879 :           if (TYPE_REF_P (fldtype))
    2107              :             {
    2108           22 :               if (complain & tf_error)
    2109           22 :                 error ("member %qD is uninitialized reference", field);
    2110              :               else
    2111              :                 return PICFLAG_ERRONEOUS;
    2112              :             }
    2113      1257857 :           else if (CLASSTYPE_REF_FIELDS_NEED_INIT (fldtype))
    2114              :             {
    2115            1 :               if (complain & tf_error)
    2116            1 :                 error ("member %qD with uninitialized reference fields", field);
    2117              :               else
    2118              :                 return PICFLAG_ERRONEOUS;
    2119              :             }
    2120              :           /* Do nothing for flexible array members since they need not have any
    2121              :              elements.  Don't worry about 'skipped' because a flexarray has to
    2122              :              be the last field.  */
    2123      1257856 :           else if (TREE_CODE (fldtype) == ARRAY_TYPE && !TYPE_DOMAIN (fldtype))
    2124          102 :             continue;
    2125              : 
    2126              :           /* Warn when some struct elements are implicitly initialized
    2127              :              to zero.  */
    2128      1257777 :           if ((complain & tf_warning)
    2129      1233894 :               && !cp_unevaluated_operand
    2130      1233370 :               && !EMPTY_CONSTRUCTOR_P (init)
    2131      1259063 :               && !is_really_empty_class (fldtype, /*ignore_vptr*/false))
    2132         1187 :             warning (OPT_Wmissing_field_initializers,
    2133              :                      "missing initializer for member %qD", field);
    2134              : 
    2135      1257777 :           if (!zero_init_p (fldtype) || skipped < 0)
    2136              :             {
    2137       346376 :               if (TYPE_REF_P (fldtype))
    2138            3 :                 next = build_zero_cst (fldtype);
    2139              :               else
    2140       346373 :                 next = build_zero_init (fldtype, /*nelts=*/NULL_TREE,
    2141              :                                         /*static_storage_p=*/false);
    2142              :             }
    2143              :           else
    2144              :             {
    2145              :               /* The default zero-initialization is fine for us; don't
    2146              :                  add anything to the CONSTRUCTOR.  */
    2147       911401 :               skipped = 1;
    2148       911401 :               continue;
    2149              :             }
    2150              :         }
    2151              : 
    2152              :       /* We can't actually elide the temporary when initializing a
    2153              :          potentially-overlapping field from a function that returns by
    2154              :          value.  */
    2155      7279285 :       if (TREE_CODE (next) == TARGET_EXPR
    2156      7279285 :           && unsafe_copy_elision_p (field, next))
    2157           25 :         TARGET_EXPR_ELIDING_P (next) = false;
    2158              : 
    2159      7279285 :       if (is_empty_field (field)
    2160      7279285 :           && !TREE_SIDE_EFFECTS (next))
    2161              :         /* Don't add trivial initialization of an empty base/field to the
    2162              :            constructor, as they might not be ordered the way the back-end
    2163              :            expects.  */
    2164        47633 :         continue;
    2165              : 
    2166              :       /* If this is a bitfield, now convert to the lowered type.  */
    2167      7231652 :       if (fldtype != TREE_TYPE (field))
    2168       267207 :         next = cp_convert_and_check (TREE_TYPE (field), next, complain);
    2169      7231652 :       picflags |= picflag_from_initializer (next);
    2170              :       /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer CONSTRUCTOR.  */
    2171      7231652 :       if (TREE_CODE (next) == CONSTRUCTOR
    2172      7231652 :           && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next))
    2173              :         {
    2174           81 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    2175           81 :           CONSTRUCTOR_PLACEHOLDER_BOUNDARY (next) = 0;
    2176              :         }
    2177     93291910 :       CONSTRUCTOR_APPEND_ELT (v, field, next);
    2178              :     }
    2179              : 
    2180      9907577 :   if (idx < CONSTRUCTOR_NELTS (init))
    2181              :     {
    2182          193 :       if (complain & tf_error)
    2183              :         {
    2184           36 :           constructor_elt *ce = &(*CONSTRUCTOR_ELTS (init))[idx];
    2185              :           /* For better diagnostics, try to find out if it is really
    2186              :              the case of too many initializers or if designators are
    2187              :              in incorrect order.  */
    2188           36 :           if (designator_skip == 1 && ce->index)
    2189              :             {
    2190           25 :               gcc_assert (TREE_CODE (ce->index) == FIELD_DECL
    2191              :                           || identifier_p (ce->index));
    2192           25 :               for (field = TYPE_FIELDS (type);
    2193          184 :                    field; field = DECL_CHAIN (field))
    2194              :                 {
    2195          337 :                   if (TREE_CODE (field) != FIELD_DECL
    2196          184 :                       || (DECL_ARTIFICIAL (field)
    2197           12 :                           && !(cxx_dialect >= cxx17
    2198           12 :                                && DECL_FIELD_IS_BASE (field))))
    2199          153 :                     continue;
    2200              : 
    2201           31 :                   if (DECL_UNNAMED_BIT_FIELD (field))
    2202            0 :                     continue;
    2203              : 
    2204           31 :                   if (ce->index == field || ce->index == DECL_NAME (field))
    2205              :                     break;
    2206              :                 }
    2207              :             }
    2208           36 :           if (field)
    2209           25 :             error ("designator order for field %qD does not match declaration "
    2210              :                    "order in %qT", field, type);
    2211              :           else
    2212           11 :             error ("too many initializers for %qT", type);
    2213              :         }
    2214              :       else
    2215              :         return PICFLAG_ERRONEOUS;
    2216              :     }
    2217              : 
    2218      9907420 :   CONSTRUCTOR_ELTS (init) = v;
    2219      9907420 :   return picflags;
    2220              : }
    2221              : 
    2222              : /* Subroutine of process_init_constructor, which will process a single
    2223              :    initializer INIT for a union of type TYPE. Returns the flags (PICFLAG_*)
    2224              :    which describe the initializer.  */
    2225              : 
    2226              : static int
    2227       118048 : process_init_constructor_union (tree type, tree init, int nested, int flags,
    2228              :                                 tsubst_flags_t complain)
    2229              : {
    2230       118048 :   constructor_elt *ce;
    2231       118048 :   int len;
    2232              : 
    2233              :   /* If the initializer was empty, use the union's NSDMI if it has one.
    2234              :      Otherwise use default zero initialization.  */
    2235       118048 :   if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    2236              :     {
    2237       106806 :       for (tree field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    2238              :         {
    2239        97166 :           if (TREE_CODE (field) == FIELD_DECL
    2240        97166 :               && DECL_INITIAL (field) != NULL_TREE)
    2241              :             {
    2242          281 :               tree val = get_nsdmi (field, /*in_ctor=*/false, complain);
    2243          281 :               if (!CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init)
    2244          281 :                   && find_placeholders (val))
    2245           19 :                 CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    2246          281 :               CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (init), field, val);
    2247          281 :               break;
    2248              :             }
    2249              :         }
    2250              : 
    2251         9921 :       if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    2252              :         return 0;
    2253              :     }
    2254              : 
    2255       108408 :   len = CONSTRUCTOR_ELTS (init)->length ();
    2256       108408 :   if (len > 1)
    2257              :     {
    2258            9 :       if (!(complain & tf_error))
    2259              :         return PICFLAG_ERRONEOUS;
    2260            3 :       error ("too many initializers for %qT", type);
    2261            3 :       CONSTRUCTOR_ELTS (init)->block_remove (1, len-1);
    2262              :     }
    2263              : 
    2264       108402 :   ce = &(*CONSTRUCTOR_ELTS (init))[0];
    2265              : 
    2266              :   /* If this element specifies a field, initialize via that field.  */
    2267       108402 :   if (ce->index)
    2268              :     {
    2269       108383 :       if (TREE_CODE (ce->index) == FIELD_DECL)
    2270              :         ;
    2271            0 :       else if (identifier_p (ce->index))
    2272              :         {
    2273              :           /* This can happen within a cast, see g++.dg/opt/cse2.C.  */
    2274            0 :           tree name = ce->index;
    2275            0 :           tree field;
    2276            0 :           for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
    2277            0 :             if (DECL_NAME (field) == name)
    2278              :               break;
    2279            0 :           if (!field)
    2280              :             {
    2281            0 :               if (complain & tf_error)
    2282            0 :                 error ("no field %qD found in union being initialized",
    2283              :                        field);
    2284            0 :               ce->value = error_mark_node;
    2285              :             }
    2286            0 :           ce->index = field;
    2287              :         }
    2288              :       else
    2289              :         {
    2290            0 :           gcc_assert (TREE_CODE (ce->index) == INTEGER_CST
    2291              :                       || TREE_CODE (ce->index) == RANGE_EXPR);
    2292            0 :           if (complain & tf_error)
    2293            0 :             error ("index value instead of field name in union initializer");
    2294            0 :           ce->value = error_mark_node;
    2295              :         }
    2296              :     }
    2297              :   else
    2298              :     {
    2299              :       /* Find the first named field.  ANSI decided in September 1990
    2300              :          that only named fields count here.  */
    2301           19 :       tree field = TYPE_FIELDS (type);
    2302          228 :       while (field && (!DECL_NAME (field) || TREE_CODE (field) != FIELD_DECL))
    2303          209 :         field = TREE_CHAIN (field);
    2304           19 :       if (field == NULL_TREE)
    2305              :         {
    2306            2 :           if (complain & tf_error)
    2307            2 :             error ("too many initializers for %qT", type);
    2308            2 :           ce->value = error_mark_node;
    2309              :         }
    2310           19 :       ce->index = field;
    2311              :     }
    2312              : 
    2313       108402 :   if (ce->value && ce->value != error_mark_node)
    2314       108400 :     ce->value = massage_init_elt (TREE_TYPE (ce->index), ce->value, nested,
    2315              :                                   flags, complain);
    2316              : 
    2317              :   /* Propagate CONSTRUCTOR_PLACEHOLDER_BOUNDARY to outer CONSTRUCTOR.  */
    2318       108402 :   if (ce->value
    2319       108402 :       && TREE_CODE (ce->value) == CONSTRUCTOR
    2320       176275 :       && CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value))
    2321              :     {
    2322            0 :       CONSTRUCTOR_PLACEHOLDER_BOUNDARY (init) = 1;
    2323            0 :       CONSTRUCTOR_PLACEHOLDER_BOUNDARY (ce->value) = 0;
    2324              :     }
    2325       108402 :   return picflag_from_initializer (ce->value);
    2326              : }
    2327              : 
    2328              : /* Process INIT, a constructor for a variable of aggregate type TYPE. The
    2329              :    constructor is a brace-enclosed initializer, and will be modified in-place.
    2330              : 
    2331              :    Each element is converted to the right type through digest_init, and
    2332              :    missing initializers are added following the language rules (zero-padding,
    2333              :    etc.).
    2334              : 
    2335              :    After the execution, the initializer will have TREE_CONSTANT if all elts are
    2336              :    constant, and TREE_STATIC set if, in addition, all elts are simple enough
    2337              :    constants that the assembler and linker can compute them.
    2338              : 
    2339              :    The function returns the initializer itself, or error_mark_node in case
    2340              :    of error.  */
    2341              : 
    2342              : static tree
    2343     10476813 : process_init_constructor (tree type, tree init, int nested, int flags,
    2344              :                           tsubst_flags_t complain)
    2345              : {
    2346     10476813 :   int picflags;
    2347              : 
    2348     10476813 :   gcc_assert (BRACE_ENCLOSED_INITIALIZER_P (init));
    2349              : 
    2350     10476813 :   if (TREE_CODE (type) == ARRAY_TYPE || VECTOR_TYPE_P (type))
    2351       450561 :     picflags = process_init_constructor_array (type, init, nested, flags,
    2352              :                                                complain);
    2353     10026252 :   else if (TREE_CODE (type) == RECORD_TYPE)
    2354      9908204 :     picflags = process_init_constructor_record (type, init, nested, flags,
    2355              :                                                 complain);
    2356       118048 :   else if (TREE_CODE (type) == UNION_TYPE)
    2357       118048 :     picflags = process_init_constructor_union (type, init, nested, flags,
    2358              :                                                complain);
    2359              :   else
    2360            0 :     gcc_unreachable ();
    2361              : 
    2362     10476813 :   if (picflags & PICFLAG_ERRONEOUS)
    2363         1276 :     return error_mark_node;
    2364              : 
    2365     10475537 :   TREE_TYPE (init) = type;
    2366     10475537 :   if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == NULL_TREE)
    2367          325 :     cp_complete_array_type (&TREE_TYPE (init), init, /*do_default=*/0);
    2368     10475537 :   if (picflags & PICFLAG_SIDE_EFFECTS)
    2369              :     {
    2370       200415 :       TREE_CONSTANT (init) = false;
    2371       200415 :       TREE_SIDE_EFFECTS (init) = true;
    2372              :     }
    2373     10275122 :   else if (picflags & PICFLAG_NOT_ALL_CONSTANT)
    2374              :     {
    2375              :       /* Make sure TREE_CONSTANT isn't set from build_constructor.  */
    2376       872939 :       TREE_CONSTANT (init) = false;
    2377       872939 :       TREE_SIDE_EFFECTS (init) = false;
    2378              :     }
    2379              :   else
    2380              :     {
    2381      9402183 :       TREE_CONSTANT (init) = 1;
    2382      9402183 :       TREE_SIDE_EFFECTS (init) = false;
    2383      9402183 :       if (!(picflags & PICFLAG_NOT_ALL_SIMPLE))
    2384      9371792 :         TREE_STATIC (init) = 1;
    2385              :     }
    2386     10475537 :   if (picflags & PICFLAG_VEC_INIT)
    2387              :     {
    2388              :       /* Defer default-initialization of array elements with no corresponding
    2389              :          initializer-clause until later so we can use a loop.  */
    2390          227 :       TREE_TYPE (init) = init_list_type_node;
    2391          227 :       init = build_vec_init_expr (type, init, complain);
    2392          227 :       init = get_target_expr (init);
    2393              :     }
    2394              :   return init;
    2395              : }
    2396              : 
    2397              : /* Given a structure or union value DATUM, construct and return
    2398              :    the structure or union component which results from narrowing
    2399              :    that value to the base specified in BASETYPE.  For example, given the
    2400              :    hierarchy
    2401              : 
    2402              :    class L { int ii; };
    2403              :    class A : L { ... };
    2404              :    class B : L { ... };
    2405              :    class C : A, B { ... };
    2406              : 
    2407              :    and the declaration
    2408              : 
    2409              :    C x;
    2410              : 
    2411              :    then the expression
    2412              : 
    2413              :    x.A::ii refers to the ii member of the L part of
    2414              :    the A part of the C object named by X.  In this case,
    2415              :    DATUM would be x, and BASETYPE would be A.
    2416              : 
    2417              :    I used to think that this was nonconformant, that the standard specified
    2418              :    that first we look up ii in A, then convert x to an L& and pull out the
    2419              :    ii part.  But in fact, it does say that we convert x to an A&; A here
    2420              :    is known as the "naming class".  (jason 2000-12-19)
    2421              : 
    2422              :    BINFO_P points to a variable initialized either to NULL_TREE or to the
    2423              :    binfo for the specific base subobject we want to convert to.  */
    2424              : 
    2425              : tree
    2426         2631 : build_scoped_ref (tree datum, tree basetype, tree* binfo_p)
    2427              : {
    2428         2631 :   tree binfo;
    2429              : 
    2430         2631 :   if (datum == error_mark_node)
    2431              :     return error_mark_node;
    2432         2631 :   if (*binfo_p)
    2433              :     binfo = *binfo_p;
    2434              :   else
    2435         2631 :     binfo = lookup_base (TREE_TYPE (datum), basetype, ba_check,
    2436              :                          NULL, tf_warning_or_error);
    2437              : 
    2438         2631 :   if (!binfo || binfo == error_mark_node)
    2439              :     {
    2440            6 :       *binfo_p = NULL_TREE;
    2441            6 :       if (!binfo)
    2442            0 :         error_not_base_type (basetype, TREE_TYPE (datum));
    2443            6 :       return error_mark_node;
    2444              :     }
    2445              : 
    2446         2625 :   *binfo_p = binfo;
    2447         2625 :   return build_base_path (PLUS_EXPR, datum, binfo, 1,
    2448         2625 :                           tf_warning_or_error);
    2449              : }
    2450              : 
    2451              : /* Build a reference to an object specified by the C++ `->' operator.
    2452              :    Usually this just involves dereferencing the object, but if the
    2453              :    `->' operator is overloaded, then such overloads must be
    2454              :    performed until an object which does not have the `->' operator
    2455              :    overloaded is found.  An error is reported when circular pointer
    2456              :    delegation is detected.  */
    2457              : 
    2458              : tree
    2459     39868436 : build_x_arrow (location_t loc, tree expr, tsubst_flags_t complain)
    2460              : {
    2461     39868436 :   tree orig_expr = expr;
    2462     39868436 :   tree type = TREE_TYPE (expr);
    2463     39868436 :   tree last_rval = NULL_TREE;
    2464     39868436 :   vec<tree, va_gc> *types_memoized = NULL;
    2465              : 
    2466     39868436 :   if (type == error_mark_node)
    2467              :     return error_mark_node;
    2468              : 
    2469     39868382 :   if (processing_template_decl)
    2470              :     {
    2471     34841082 :       tree ttype = NULL_TREE;
    2472     34841082 :       if (type && TYPE_PTR_P (type))
    2473     28630848 :         ttype = TREE_TYPE (type);
    2474     28630848 :       if (ttype && !dependent_scope_p (ttype))
    2475              :         /* Pointer to current instantiation, don't treat as dependent.  */;
    2476     10457950 :       else if (type_dependent_expression_p (expr))
    2477              :         {
    2478     10362408 :           expr = build_min_nt_loc (loc, ARROW_EXPR, expr);
    2479     10362408 :           TREE_TYPE (expr) = ttype;
    2480     10362408 :           return expr;
    2481              :         }
    2482              :     }
    2483              : 
    2484     29505974 :   if (MAYBE_CLASS_TYPE_P (type))
    2485              :     {
    2486       254685 :       struct tinst_level *actual_inst = current_instantiation ();
    2487       254685 :       tree fn = NULL;
    2488              : 
    2489       512190 :       while ((expr = build_new_op (loc, COMPONENT_REF,
    2490              :                                    LOOKUP_NORMAL, expr, NULL_TREE, NULL_TREE,
    2491              :                                    NULL_TREE, &fn, complain)))
    2492              :         {
    2493       257529 :           if (expr == error_mark_node)
    2494           32 :             return error_mark_node;
    2495              : 
    2496              :           /* This provides a better instantiation backtrace in case of
    2497              :              error.  */
    2498       257505 :           if (fn && DECL_USE_TEMPLATE (fn))
    2499       156640 :             push_tinst_level_loc (fn,
    2500       153790 :                                   (current_instantiation () != actual_inst)
    2501         2850 :                                   ? DECL_SOURCE_LOCATION (fn)
    2502              :                                   : input_location);
    2503       257505 :           fn = NULL;
    2504              : 
    2505       257505 :           if (vec_member (TREE_TYPE (expr), types_memoized))
    2506              :             {
    2507            0 :               if (complain & tf_error)
    2508            0 :                 error ("circular pointer delegation detected");
    2509            0 :               return error_mark_node;
    2510              :             }
    2511              : 
    2512       257505 :           vec_safe_push (types_memoized, TREE_TYPE (expr));
    2513       257505 :           last_rval = expr;
    2514              :         }
    2515              : 
    2516       405748 :       while (current_instantiation () != actual_inst)
    2517       151090 :         pop_tinst_level ();
    2518              : 
    2519       254658 :       if (last_rval == NULL_TREE)
    2520              :         {
    2521            8 :           if (complain & tf_error)
    2522            8 :             error ("base operand of %<->%> has non-pointer type %qT", type);
    2523            8 :           return error_mark_node;
    2524              :         }
    2525              : 
    2526       254650 :       if (TYPE_REF_P (TREE_TYPE (last_rval)))
    2527            0 :         last_rval = convert_from_reference (last_rval);
    2528              :     }
    2529              :   else
    2530              :     {
    2531     29251289 :       last_rval = decay_conversion (expr, complain);
    2532     29251289 :       if (last_rval == error_mark_node)
    2533              :         return error_mark_node;
    2534              :     }
    2535              : 
    2536     29505936 :   if (TYPE_PTR_P (TREE_TYPE (last_rval)))
    2537              :     {
    2538     29505933 :       if (processing_template_decl)
    2539              :         {
    2540     24478671 :           expr = build_min (ARROW_EXPR, TREE_TYPE (TREE_TYPE (last_rval)),
    2541              :                             orig_expr);
    2542     24478671 :           TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (last_rval);
    2543     24478671 :           return expr;
    2544              :         }
    2545              : 
    2546      5027262 :       return cp_build_indirect_ref (loc, last_rval, RO_ARROW, complain);
    2547              :     }
    2548              : 
    2549            3 :   if (complain & tf_error)
    2550              :     {
    2551            3 :       if (types_memoized)
    2552            0 :         error ("result of %<operator->()%> yields non-pointer result");
    2553              :       else
    2554            3 :         error ("base operand of %<->%> is not a pointer");
    2555              :     }
    2556            3 :   return error_mark_node;
    2557              : }
    2558              : 
    2559              : /* Return an expression for "DATUM .* COMPONENT".  DATUM has not
    2560              :    already been checked out to be of aggregate type.  */
    2561              : 
    2562              : tree
    2563       108114 : build_m_component_ref (tree datum, tree component, tsubst_flags_t complain)
    2564              : {
    2565       108114 :   tree ptrmem_type;
    2566       108114 :   tree objtype;
    2567       108114 :   tree type;
    2568       108114 :   tree binfo;
    2569       108114 :   tree ctype;
    2570              : 
    2571       108114 :   datum = mark_lvalue_use (datum);
    2572       108114 :   component = mark_rvalue_use (component);
    2573              : 
    2574       108114 :   if (error_operand_p (datum) || error_operand_p (component))
    2575           59 :     return error_mark_node;
    2576              : 
    2577       108055 :   ptrmem_type = TREE_TYPE (component);
    2578       108055 :   if (!TYPE_PTRMEM_P (ptrmem_type))
    2579              :     {
    2580            6 :       if (complain & tf_error)
    2581            3 :         error ("%qE cannot be used as a member pointer, since it is of "
    2582              :                "type %qT", component, ptrmem_type);
    2583            6 :       return error_mark_node;
    2584              :     }
    2585              : 
    2586       108049 :   objtype = TYPE_MAIN_VARIANT (TREE_TYPE (datum));
    2587       108049 :   if (! MAYBE_CLASS_TYPE_P (objtype))
    2588              :     {
    2589           28 :       if (complain & tf_error)
    2590            0 :         error ("cannot apply member pointer %qE to %qE, which is of "
    2591              :                "non-class type %qT", component, datum, objtype);
    2592           28 :       return error_mark_node;
    2593              :     }
    2594              : 
    2595       108021 :   type = TYPE_PTRMEM_POINTED_TO_TYPE (ptrmem_type);
    2596       108021 :   ctype = complete_type (TYPE_PTRMEM_CLASS_TYPE (ptrmem_type));
    2597              : 
    2598       108021 :   if (!COMPLETE_TYPE_P (ctype))
    2599              :     {
    2600           83 :       if (!same_type_p (ctype, objtype))
    2601            0 :         goto mismatch;
    2602              :       binfo = NULL;
    2603              :     }
    2604              :   else
    2605              :     {
    2606       107938 :       binfo = lookup_base (objtype, ctype, ba_check, NULL, complain);
    2607              : 
    2608       107938 :       if (!binfo)
    2609              :         {
    2610           36 :         mismatch:
    2611           36 :           if (complain & tf_error)
    2612              :             {
    2613            6 :               if (COMPLETE_TYPE_P (objtype))
    2614            3 :                 error ("pointer to member type %qT incompatible "
    2615              :                        "with object type %qT because %qT is not "
    2616              :                        "derived from %qT", ptrmem_type, objtype,
    2617              :                        objtype, ctype);
    2618              :               else
    2619            3 :                 error ("pointer to member type %qT incompatible with "
    2620              :                        "incomplete object type %qT", ptrmem_type, objtype);
    2621              :             }
    2622           36 :           return error_mark_node;
    2623              :         }
    2624       107902 :       else if (binfo == error_mark_node)
    2625              :         return error_mark_node;
    2626              :     }
    2627              : 
    2628       107976 :   if (TYPE_PTRDATAMEM_P (ptrmem_type))
    2629              :     {
    2630         1372 :       bool is_lval = real_lvalue_p (datum);
    2631         1372 :       tree ptype;
    2632              : 
    2633              :       /* Compute the type of the field, as described in [expr.ref].
    2634              :          There's no such thing as a mutable pointer-to-member, so
    2635              :          things are not as complex as they are for references to
    2636              :          non-static data members.  */
    2637         1372 :       type = cp_build_qualified_type (type,
    2638         1372 :                                       (cp_type_quals (type)
    2639         1372 :                                        | cp_type_quals (TREE_TYPE (datum))));
    2640              : 
    2641         1372 :       datum = cp_build_addr_expr (datum, complain);
    2642              : 
    2643              :       /* Convert object to the correct base.  */
    2644         1372 :       if (binfo)
    2645              :         {
    2646         1345 :           datum = build_base_path (PLUS_EXPR, datum, binfo, 1, complain);
    2647         1345 :           if (datum == error_mark_node)
    2648              :             return error_mark_node;
    2649              :         }
    2650              : 
    2651              :       /* Build an expression for "object + offset" where offset is the
    2652              :          value stored in the pointer-to-data-member.  */
    2653         1372 :       ptype = build_pointer_type (type);
    2654         1372 :       datum = convert (ptype, datum);
    2655         1372 :       if (!processing_template_decl)
    2656         1351 :         datum = build2 (POINTER_PLUS_EXPR, ptype,
    2657              :                         datum, convert_to_ptrofftype (component));
    2658         1372 :       datum = cp_fully_fold (datum);
    2659         1372 :       datum = cp_build_fold_indirect_ref (datum);
    2660         1372 :       if (datum == error_mark_node)
    2661              :         return error_mark_node;
    2662              : 
    2663              :       /* If the object expression was an rvalue, return an rvalue.  */
    2664         1372 :       if (!is_lval)
    2665          157 :         datum = move (datum);
    2666              :       return datum;
    2667              :     }
    2668              :   else
    2669              :     {
    2670              :       /* 5.5/6: In a .* expression whose object expression is an rvalue, the
    2671              :          program is ill-formed if the second operand is a pointer to member
    2672              :          function with ref-qualifier & (for C++20: unless its cv-qualifier-seq
    2673              :          is const). In a .* expression whose object expression is an lvalue,
    2674              :          the program is ill-formed if the second operand is a pointer to member
    2675              :          function with ref-qualifier &&.  */
    2676       106604 :       if (FUNCTION_REF_QUALIFIED (type))
    2677              :         {
    2678          136 :           bool lval = lvalue_p (datum);
    2679          136 :           if (lval && FUNCTION_RVALUE_QUALIFIED (type))
    2680              :             {
    2681           15 :               if (complain & tf_error)
    2682            6 :                 error ("pointer-to-member-function type %qT requires an rvalue",
    2683              :                        ptrmem_type);
    2684           15 :               return error_mark_node;
    2685              :             }
    2686          121 :           else if (!lval && !FUNCTION_RVALUE_QUALIFIED (type))
    2687              :             {
    2688           33 :               if ((type_memfn_quals (type)
    2689           33 :                    & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))
    2690              :                   != TYPE_QUAL_CONST)
    2691              :                 {
    2692           27 :                   if (complain & tf_error)
    2693           24 :                     error ("pointer-to-member-function type %qT requires "
    2694              :                            "an lvalue", ptrmem_type);
    2695           27 :                   return error_mark_node;
    2696              :                 }
    2697            6 :               else if (cxx_dialect < cxx20)
    2698              :                 {
    2699            3 :                   if (complain & tf_warning_or_error)
    2700            3 :                     pedwarn (input_location, OPT_Wpedantic,
    2701              :                              "pointer-to-member-function type %qT requires "
    2702              :                              "an lvalue before C++20", ptrmem_type);
    2703              :                   else
    2704            0 :                     return error_mark_node;
    2705              :                 }
    2706              :             }
    2707              :         }
    2708       106562 :       return build2 (OFFSET_REF, type, datum, component);
    2709              :     }
    2710              : }
    2711              : 
    2712              : /* Return a tree node for the expression TYPENAME '(' PARMS ')'.  */
    2713              : 
    2714              : static tree
    2715     77732037 : build_functional_cast_1 (location_t loc, tree exp, tree parms,
    2716              :                          tsubst_flags_t complain)
    2717              : {
    2718              :   /* This is either a call to a constructor,
    2719              :      or a C cast in C++'s `functional' notation.  */
    2720              : 
    2721              :   /* The type to which we are casting.  */
    2722     77732037 :   tree type;
    2723              : 
    2724     77732037 :   if (error_operand_p (exp) || parms == error_mark_node)
    2725        42439 :     return error_mark_node;
    2726              : 
    2727     77689598 :   if (TREE_CODE (exp) == TYPE_DECL)
    2728              :     {
    2729     45740221 :       type = TREE_TYPE (exp);
    2730              : 
    2731     45740221 :       if (DECL_ARTIFICIAL (exp))
    2732     29141517 :         cp_handle_deprecated_or_unavailable (type);
    2733              :     }
    2734              :   else
    2735              :     type = exp;
    2736              : 
    2737              :   /* We need to check this explicitly, since value-initialization of
    2738              :      arrays is allowed in other situations.  */
    2739     77689598 :   if (TREE_CODE (type) == ARRAY_TYPE)
    2740              :     {
    2741           12 :       if (complain & tf_error)
    2742            6 :         error_at (loc, "functional cast to array type %qT", type);
    2743           12 :       return error_mark_node;
    2744              :     }
    2745              : 
    2746     77689586 :   if (tree anode = type_uses_auto (type))
    2747              :     {
    2748       673155 :       tree init;
    2749       673155 :       if (CLASS_PLACEHOLDER_TEMPLATE (anode))
    2750              :         init = parms;
    2751              :       /* C++23 auto(x).  */
    2752       203338 :       else if (!AUTO_IS_DECLTYPE (anode)
    2753       203338 :                && list_length (parms) == 1)
    2754              :         {
    2755       203323 :           init = TREE_VALUE (parms);
    2756       203323 :           if (is_constrained_auto (anode))
    2757              :             {
    2758            3 :               if (complain & tf_error)
    2759            3 :                 error_at (loc, "%<auto(x)%> cannot be constrained");
    2760            3 :               return error_mark_node;
    2761              :             }
    2762       203320 :           else if (cxx_dialect < cxx23)
    2763              :             {
    2764           25 :               if ((complain & tf_warning_or_error) == 0)
    2765            2 :                 return error_mark_node;
    2766           23 :               pedwarn (loc, OPT_Wc__23_extensions,
    2767              :                        "%<auto(x)%> only available with "
    2768              :                        "%<-std=c++23%> or %<-std=gnu++23%>");
    2769              :             }
    2770              :         }
    2771              :       else
    2772              :         {
    2773           15 :           if (complain & tf_error)
    2774           15 :             error_at (loc, "invalid use of %qT", anode);
    2775           15 :           return error_mark_node;
    2776              :         }
    2777       673135 :       type = do_auto_deduction (type, init, anode, complain,
    2778              :                                 adc_variable_type);
    2779       673135 :       if (type == error_mark_node)
    2780              :         return error_mark_node;
    2781              :     }
    2782              : 
    2783     77689412 :   if (processing_template_decl)
    2784              :     {
    2785     43568853 :       tree t;
    2786              : 
    2787              :       /* Diagnose this even in a template.  We could also try harder
    2788              :          to give all the usual errors when the type and args are
    2789              :          non-dependent...  */
    2790     43568853 :       if (TYPE_REF_P (type) && !parms)
    2791              :         {
    2792            3 :           if (complain & tf_error)
    2793            3 :             error_at (loc, "invalid value-initialization of reference type");
    2794            3 :           return error_mark_node;
    2795              :         }
    2796              : 
    2797     43568850 :       t = build_min (CAST_EXPR, type, parms);
    2798              :       /* We don't know if it will or will not have side effects.  */
    2799     43568850 :       TREE_SIDE_EFFECTS (t) = 1;
    2800     43568850 :       return convert_from_reference (t);
    2801              :     }
    2802              : 
    2803     34120559 :   if (! MAYBE_CLASS_TYPE_P (type))
    2804              :     {
    2805     29764628 :       if (parms == NULL_TREE)
    2806              :         {
    2807       779399 :           if (VOID_TYPE_P (type))
    2808         4325 :             return void_node;
    2809       775074 :           return build_value_init (cv_unqualified (type), complain);
    2810              :         }
    2811              : 
    2812              :       /* This must build a C cast.  */
    2813     28985229 :       parms = build_x_compound_expr_from_list (parms, ELK_FUNC_CAST, complain);
    2814     28985229 :       return cp_build_c_cast (loc, type, parms, complain);
    2815              :     }
    2816              : 
    2817              :   /* Prepare to evaluate as a call to a constructor.  If this expression
    2818              :      is actually used, for example,
    2819              : 
    2820              :      return X (arg1, arg2, ...);
    2821              : 
    2822              :      then the slot being initialized will be filled in.  */
    2823              : 
    2824      4355931 :   if (!complete_type_or_maybe_complain (type, NULL_TREE, complain))
    2825           18 :     return error_mark_node;
    2826      4355910 :   if (abstract_virtuals_error (ACU_CAST, type, complain))
    2827           21 :     return error_mark_node;
    2828              : 
    2829              :   /* [expr.type.conv]
    2830              : 
    2831              :      If the expression list is a single-expression, the type
    2832              :      conversion is equivalent (in definedness, and if defined in
    2833              :      meaning) to the corresponding cast expression.  */
    2834      4355889 :   if (parms && TREE_CHAIN (parms) == NULL_TREE)
    2835      2851064 :     return cp_build_c_cast (loc, type, TREE_VALUE (parms), complain);
    2836              : 
    2837              :   /* [expr.type.conv]
    2838              : 
    2839              :      The expression T(), where T is a simple-type-specifier for a
    2840              :      non-array complete object type or the (possibly cv-qualified)
    2841              :      void type, creates an rvalue of the specified type, which is
    2842              :      value-initialized.  */
    2843              : 
    2844      1504825 :   if (parms == NULL_TREE)
    2845              :     {
    2846      1019862 :       exp = build_value_init (type, complain);
    2847      1019862 :       exp = get_target_expr (exp, complain);
    2848      1019862 :       return exp;
    2849              :     }
    2850              : 
    2851              :   /* Call the constructor.  */
    2852       484963 :   releasing_vec parmvec;
    2853      1527563 :   for (; parms != NULL_TREE; parms = TREE_CHAIN (parms))
    2854      1042600 :     vec_safe_push (parmvec, TREE_VALUE (parms));
    2855       484963 :   exp = build_special_member_call (NULL_TREE, complete_ctor_identifier,
    2856              :                                    &parmvec, type, LOOKUP_NORMAL, complain);
    2857              : 
    2858       484963 :   if (exp == error_mark_node)
    2859              :     return error_mark_node;
    2860              : 
    2861       484917 :   return build_cplus_new (type, exp, complain);
    2862       484963 : }
    2863              : 
    2864              : tree
    2865     77732037 : build_functional_cast (location_t loc, tree exp, tree parms,
    2866              :                        tsubst_flags_t complain)
    2867              : {
    2868     77732037 :   tree result = build_functional_cast_1 (loc, exp, parms, complain);
    2869     77732034 :   protected_set_expr_location (result, loc);
    2870     77732034 :   return result;
    2871              : }
    2872              : 
    2873              : 
    2874              : /* Add new exception specifier SPEC, to the LIST we currently have.
    2875              :    If it's already in LIST then do nothing.
    2876              :    Moan if it's bad and we're allowed to. COMPLAIN < 0 means we
    2877              :    know what we're doing.  */
    2878              : 
    2879              : tree
    2880        15724 : add_exception_specifier (tree list, tree spec, tsubst_flags_t complain)
    2881              : {
    2882        15724 :   bool ok;
    2883        15724 :   tree core = spec;
    2884        15724 :   bool is_ptr;
    2885        15724 :   enum diagnostics::kind diag_type = diagnostics::kind::unspecified; /* none */
    2886              : 
    2887        15724 :   if (spec == error_mark_node)
    2888              :     return list;
    2889              : 
    2890        15749 :   gcc_assert (spec && (!list || TREE_VALUE (list)));
    2891              : 
    2892              :   /* [except.spec] 1, type in an exception specifier shall not be
    2893              :      incomplete, or pointer or ref to incomplete other than pointer
    2894              :      to cv void.  */
    2895        15710 :   is_ptr = TYPE_PTR_P (core);
    2896        15710 :   if (is_ptr || TYPE_REF_P (core))
    2897           19 :     core = TREE_TYPE (core);
    2898        15710 :   if (complain < 0)
    2899              :     ok = true;
    2900         1398 :   else if (VOID_TYPE_P (core))
    2901              :     ok = is_ptr;
    2902         1390 :   else if (TREE_CODE (core) == TEMPLATE_TYPE_PARM)
    2903              :     ok = true;
    2904         1380 :   else if (processing_template_decl)
    2905              :     ok = true;
    2906         1343 :   else if (!verify_type_context (input_location, TCTX_EXCEPTIONS, core,
    2907         1343 :                                  !(complain & tf_error)))
    2908            0 :     return error_mark_node;
    2909              :   else
    2910              :     {
    2911         1343 :       ok = true;
    2912              :       /* 15.4/1 says that types in an exception specifier must be complete,
    2913              :          but it seems more reasonable to only require this on definitions
    2914              :          and calls.  So just give a pedwarn at this point; we will give an
    2915              :          error later if we hit one of those two cases.  */
    2916         1343 :       if (!COMPLETE_TYPE_P (complete_type (core)))
    2917        15710 :         diag_type = diagnostics::kind::pedwarn; /* pedwarn */
    2918              :     }
    2919              : 
    2920        15710 :   if (ok)
    2921              :     {
    2922              :       tree probe;
    2923              : 
    2924        15749 :       for (probe = list; probe; probe = TREE_CHAIN (probe))
    2925           47 :         if (same_type_p (TREE_VALUE (probe), spec))
    2926              :           break;
    2927        15704 :       if (!probe)
    2928        15702 :         list = tree_cons (NULL_TREE, spec, list);
    2929              :     }
    2930              :   else
    2931              :     diag_type = diagnostics::kind::error; /* error */
    2932              : 
    2933        15704 :   if (diag_type != diagnostics::kind::unspecified
    2934           12 :       && (complain & tf_warning_or_error))
    2935           10 :     cxx_incomplete_type_diagnostic (NULL_TREE, core, diag_type);
    2936              : 
    2937              :   return list;
    2938              : }
    2939              : 
    2940              : /* Like nothrow_spec_p, but don't abort on deferred noexcept.  */
    2941              : 
    2942              : static bool
    2943      4687725 : nothrow_spec_p_uninst (const_tree spec)
    2944              : {
    2945      9375450 :   if (DEFERRED_NOEXCEPT_SPEC_P (spec))
    2946              :     return false;
    2947      4687723 :   return nothrow_spec_p (spec);
    2948              : }
    2949              : 
    2950              : /* Combine the two exceptions specifier lists LIST and ADD, and return
    2951              :    their union.  */
    2952              : 
    2953              : tree
    2954     12653059 : merge_exception_specifiers (tree list, tree add)
    2955              : {
    2956     12653059 :   tree noex, orig_list;
    2957              : 
    2958     12653059 :   if (list == error_mark_node || add == error_mark_node)
    2959              :     return error_mark_node;
    2960              : 
    2961              :   /* No exception-specifier or noexcept(false) are less strict than
    2962              :      anything else.  Prefer the newer variant (LIST).  */
    2963     12653059 :   if (!list || list == noexcept_false_spec)
    2964              :     return list;
    2965      4775262 :   else if (!add || add == noexcept_false_spec)
    2966              :     return add;
    2967              : 
    2968              :   /* noexcept(true) and throw() are stricter than anything else.
    2969              :      As above, prefer the more recent one (LIST).  */
    2970      4649005 :   if (nothrow_spec_p_uninst (add))
    2971              :     return list;
    2972              : 
    2973              :   /* Two implicit noexcept specs (e.g. on a destructor) are equivalent.  */
    2974        38722 :   if (UNEVALUATED_NOEXCEPT_SPEC_P (add)
    2975            2 :       && UNEVALUATED_NOEXCEPT_SPEC_P (list))
    2976              :     return list;
    2977              :   /* We should have instantiated other deferred noexcept specs by now.  */
    2978        38720 :   gcc_assert (!DEFERRED_NOEXCEPT_SPEC_P (add));
    2979              : 
    2980        38720 :   if (nothrow_spec_p_uninst (list))
    2981              :     return add;
    2982        38717 :   noex = TREE_PURPOSE (list);
    2983        38717 :   gcc_checking_assert (!TREE_PURPOSE (add)
    2984              :                        || errorcount || !flag_exceptions
    2985              :                        || cp_tree_equal (noex, TREE_PURPOSE (add)));
    2986              : 
    2987              :   /* Combine the dynamic-exception-specifiers, if any.  */
    2988        38717 :   orig_list = list;
    2989        77469 :   for (; add && TREE_VALUE (add); add = TREE_CHAIN (add))
    2990              :     {
    2991           40 :       tree spec = TREE_VALUE (add);
    2992              :       tree probe;
    2993              : 
    2994           74 :       for (probe = orig_list; probe && TREE_VALUE (probe);
    2995           12 :            probe = TREE_CHAIN (probe))
    2996           34 :         if (same_type_p (TREE_VALUE (probe), spec))
    2997              :           break;
    2998           28 :       if (!probe)
    2999              :         {
    3000            6 :           spec = build_tree_list (NULL_TREE, spec);
    3001            6 :           TREE_CHAIN (spec) = list;
    3002            6 :           list = spec;
    3003              :         }
    3004              :     }
    3005              : 
    3006              :   /* Keep the noexcept-specifier at the beginning of the list.  */
    3007        38717 :   if (noex != TREE_PURPOSE (list))
    3008            0 :     list = tree_cons (noex, TREE_VALUE (list), TREE_CHAIN (list));
    3009              : 
    3010              :   return list;
    3011              : }
    3012              : 
    3013              : /* Subroutine of build_call.  Ensure that each of the types in the
    3014              :    exception specification is complete.  Technically, 15.4/1 says that
    3015              :    they need to be complete when we see a declaration of the function,
    3016              :    but we should be able to get away with only requiring this when the
    3017              :    function is defined or called.  See also add_exception_specifier.  */
    3018              : 
    3019              : void
    3020    171737280 : require_complete_eh_spec_types (tree fntype, tree decl)
    3021              : {
    3022    171737280 :   tree raises;
    3023              :   /* Don't complain about calls to op new.  */
    3024    171737280 :   if (decl && DECL_ARTIFICIAL (decl))
    3025              :     return;
    3026    250190316 :   for (raises = TYPE_RAISES_EXCEPTIONS (fntype); raises;
    3027     90090590 :        raises = TREE_CHAIN (raises))
    3028              :     {
    3029     90090590 :       tree type = TREE_VALUE (raises);
    3030     90090590 :       if (type && !COMPLETE_TYPE_P (type))
    3031              :         {
    3032            1 :           if (decl)
    3033            1 :             error
    3034            1 :               ("call to function %qD which throws incomplete type %q#T",
    3035              :                decl, type);
    3036              :           else
    3037            0 :             error ("call to function which throws incomplete type %q#T",
    3038              :                    decl);
    3039              :         }
    3040              :     }
    3041              : }
    3042              : 
    3043              : /* Record that any TARGET_EXPR in T are going to be elided in
    3044              :    cp_gimplify_init_expr (or sooner).  */
    3045              : 
    3046              : void
    3047    176802346 : set_target_expr_eliding (tree t)
    3048              : {
    3049    179618969 :   if (!t)
    3050              :     return;
    3051    178815116 :   switch (TREE_CODE (t))
    3052              :     {
    3053     13614587 :     case TARGET_EXPR:
    3054     13614587 :       TARGET_EXPR_ELIDING_P (t) = true;
    3055     13614587 :       break;
    3056      1661942 :     case COMPOUND_EXPR:
    3057      1661942 :       set_target_expr_eliding (TREE_OPERAND (t, 1));
    3058      1661942 :       break;
    3059      1154681 :     case COND_EXPR:
    3060      1154681 :       set_target_expr_eliding (TREE_OPERAND (t, 1));
    3061      1154681 :       set_target_expr_eliding (TREE_OPERAND (t, 2));
    3062      1154681 :       break;
    3063              : 
    3064              :     default:
    3065              :       break;
    3066              :     }
    3067              : }
    3068              : 
    3069              : /* Call the above in the process of building an INIT_EXPR.  */
    3070              : 
    3071              : tree
    3072     66634174 : cp_build_init_expr (location_t loc, tree target, tree init)
    3073              : {
    3074     66634174 :   set_target_expr_eliding (init);
    3075     66634174 :   tree ie = build2_loc (loc, INIT_EXPR, TREE_TYPE (target),
    3076              :                         target, init);
    3077     66634174 :   TREE_SIDE_EFFECTS (ie) = true;
    3078     66634174 :   return ie;
    3079              : }
        

Generated by: LCOV version 2.4-beta

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