@@ -4200,7 +4200,7 @@ static OverloadingResult ResolveConstructorOverload(
4200
4200
/// \param IsListInit Is this list-initialization?
4201
4201
/// \param IsInitListCopy Is this non-list-initialization resulting from a
4202
4202
/// list-initialization from {x} where x is the same
4203
- /// aggregate type as the entity?
4203
+ /// type as the entity?
4204
4204
static void TryConstructorInitialization(Sema &S,
4205
4205
const InitializedEntity &Entity,
4206
4206
const InitializationKind &Kind,
@@ -4230,14 +4230,6 @@ static void TryConstructorInitialization(Sema &S,
4230
4230
Entity.getKind() !=
4231
4231
InitializedEntity::EK_LambdaToBlockConversionBlockElement);
4232
4232
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
-
4241
4233
// C++17 [dcl.init]p17:
4242
4234
// - If the initializer expression is a prvalue and the cv-unqualified
4243
4235
// version of the source type is the same class as the class of the
@@ -4250,17 +4242,11 @@ static void TryConstructorInitialization(Sema &S,
4250
4242
if (S.getLangOpts().CPlusPlus17 && !RequireActualConstructor &&
4251
4243
UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isPRValue() &&
4252
4244
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;
4264
4250
}
4265
4251
4266
4252
const RecordType *DestRecordType = DestType->getAs<RecordType>();
@@ -4305,12 +4291,6 @@ static void TryConstructorInitialization(Sema &S,
4305
4291
S, Kind.getLocation(), Args, CandidateSet, DestType, Ctors, Best,
4306
4292
CopyInitialization, AllowExplicit,
4307
4293
/*OnlyListConstructors=*/true, IsListInit, RequireActualConstructor);
4308
-
4309
- if (CopyElisionPossible && Result == OR_No_Viable_Function) {
4310
- // No initializer list candidate
4311
- ElideConstructor();
4312
- return;
4313
- }
4314
4294
}
4315
4295
4316
4296
// C++11 [over.match.list]p1:
@@ -4592,9 +4572,9 @@ static void TryListInitialization(Sema &S,
4592
4572
return;
4593
4573
}
4594
4574
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
4598
4578
// initialized from that element (by copy-initialization for
4599
4579
// copy-list-initialization, or by direct-initialization for
4600
4580
// direct-list-initialization).
@@ -4605,7 +4585,7 @@ static void TryListInitialization(Sema &S,
4605
4585
// - Otherwise, if T is an aggregate, [...] (continue below).
4606
4586
if (S.getLangOpts().CPlusPlus11 && InitList->getNumInits() == 1 &&
4607
4587
!IsDesignatedInit) {
4608
- if (DestType->isRecordType() && DestType->isAggregateType() ) {
4588
+ if (DestType->isRecordType()) {
4609
4589
QualType InitType = InitList->getInit(0)->getType();
4610
4590
if (S.Context.hasSameUnqualifiedType(InitType, DestType) ||
4611
4591
S.IsDerivedFrom(InitList->getBeginLoc(), InitType, DestType)) {
0 commit comments