@@ -4200,7 +4200,7 @@ static OverloadingResult ResolveConstructorOverload(
42004200// / \param IsListInit Is this list-initialization?
42014201// / \param IsInitListCopy Is this non-list-initialization resulting from a
42024202// / list-initialization from {x} where x is the same
4203- // / aggregate type as the entity?
4203+ // / type as the entity?
42044204static void TryConstructorInitialization (Sema &S,
42054205 const InitializedEntity &Entity,
42064206 const InitializationKind &Kind,
@@ -4230,14 +4230,6 @@ static void TryConstructorInitialization(Sema &S,
42304230 Entity.getKind () !=
42314231 InitializedEntity::EK_LambdaToBlockConversionBlockElement);
42324232
4233- bool CopyElisionPossible = false ;
4234- auto ElideConstructor = [&] {
4235- // Convert qualifications if necessary.
4236- Sequence.AddQualificationConversionStep (DestType, VK_PRValue);
4237- if (ILE)
4238- Sequence.RewrapReferenceInitList (DestType, ILE);
4239- };
4240-
42414233 // C++17 [dcl.init]p17:
42424234 // - If the initializer expression is a prvalue and the cv-unqualified
42434235 // version of the source type is the same class as the class of the
@@ -4250,17 +4242,11 @@ static void TryConstructorInitialization(Sema &S,
42504242 if (S.getLangOpts ().CPlusPlus17 && !RequireActualConstructor &&
42514243 UnwrappedArgs.size () == 1 && UnwrappedArgs[0 ]->isPRValue () &&
42524244 S.Context .hasSameUnqualifiedType (UnwrappedArgs[0 ]->getType (), DestType)) {
4253- if (ILE && !DestType->isAggregateType ()) {
4254- // CWG2311: T{ prvalue_of_type_T } is not eligible for copy elision
4255- // Make this an elision if this won't call an initializer-list
4256- // constructor. (Always on an aggregate type or check constructors first.)
4257- assert (!IsInitListCopy &&
4258- " IsInitListCopy only possible with aggregate types" );
4259- CopyElisionPossible = true ;
4260- } else {
4261- ElideConstructor ();
4262- return ;
4263- }
4245+ // Convert qualifications if necessary.
4246+ Sequence.AddQualificationConversionStep (DestType, VK_PRValue);
4247+ if (ILE)
4248+ Sequence.RewrapReferenceInitList (DestType, ILE);
4249+ return ;
42644250 }
42654251
42664252 const RecordType *DestRecordType = DestType->getAs <RecordType>();
@@ -4305,12 +4291,6 @@ static void TryConstructorInitialization(Sema &S,
43054291 S, Kind.getLocation (), Args, CandidateSet, DestType, Ctors, Best,
43064292 CopyInitialization, AllowExplicit,
43074293 /* OnlyListConstructors=*/ true , IsListInit, RequireActualConstructor);
4308-
4309- if (CopyElisionPossible && Result == OR_No_Viable_Function) {
4310- // No initializer list candidate
4311- ElideConstructor ();
4312- return ;
4313- }
43144294 }
43154295
43164296 // C++11 [over.match.list]p1:
@@ -4592,9 +4572,9 @@ static void TryListInitialization(Sema &S,
45924572 return ;
45934573 }
45944574
4595- // C++11 [dcl.init.list]p3, per DR1467 and DR2137 :
4596- // - If T is an aggregate class and the initializer list has a single element
4597- // of type cv U, where U is T or a class derived from T, the object is
4575+ // C++11 [dcl.init.list]p3, per DR1467:
4576+ // - If T is a class type and the initializer list has a single element of
4577+ // type cv U, where U is T or a class derived from T, the object is
45984578 // initialized from that element (by copy-initialization for
45994579 // copy-list-initialization, or by direct-initialization for
46004580 // direct-list-initialization).
@@ -4605,7 +4585,7 @@ static void TryListInitialization(Sema &S,
46054585 // - Otherwise, if T is an aggregate, [...] (continue below).
46064586 if (S.getLangOpts ().CPlusPlus11 && InitList->getNumInits () == 1 &&
46074587 !IsDesignatedInit) {
4608- if (DestType->isRecordType () && DestType-> isAggregateType () ) {
4588+ if (DestType->isRecordType ()) {
46094589 QualType InitType = InitList->getInit (0 )->getType ();
46104590 if (S.Context .hasSameUnqualifiedType (InitType, DestType) ||
46114591 S.IsDerivedFrom (InitList->getBeginLoc (), InitType, DestType)) {
0 commit comments