@@ -246,6 +246,7 @@ void StandardConversionSequence::setAsIdentityConversion() {
246
246
BindsToRvalue = false;
247
247
BindsImplicitObjectArgumentWithoutRefQualifier = false;
248
248
ObjCLifetimeConversionBinding = false;
249
+ FromBracedInitList = false;
249
250
CopyConstructor = nullptr;
250
251
}
251
252
@@ -1692,12 +1693,14 @@ TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
1692
1693
// has a single element of type cv U, where U is X or a class derived
1693
1694
// from X, the implicit conversion sequence has Exact Match rank if U is
1694
1695
// X, or Conversion rank if U is derived from X.
1696
+ bool FromListInit = false;
1695
1697
if (const auto *InitList = dyn_cast<InitListExpr>(From);
1696
1698
InitList && InitList->getNumInits() == 1 &&
1697
1699
!S.isInitListConstructor(Constructor)) {
1698
1700
const Expr *SingleInit = InitList->getInit(0);
1699
1701
FromType = SingleInit->getType();
1700
1702
FromLoc = SingleInit->getBeginLoc();
1703
+ FromListInit = true;
1701
1704
} else {
1702
1705
FromType = From->getType();
1703
1706
FromLoc = From->getBeginLoc();
@@ -1715,6 +1718,7 @@ TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
1715
1718
ICS.Standard.setAsIdentityConversion();
1716
1719
ICS.Standard.setFromType(FromType);
1717
1720
ICS.Standard.setAllToTypes(ToType);
1721
+ ICS.Standard.FromBracedInitList = FromListInit;
1718
1722
ICS.Standard.CopyConstructor = Constructor;
1719
1723
ICS.Standard.FoundCopyConstructor = Found;
1720
1724
if (ToCanon != FromCanon)
@@ -4062,6 +4066,7 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
4062
4066
if (isa<InitListExpr>(From)) {
4063
4067
// Initializer lists don't have conversions as such.
4064
4068
User.Before.setAsIdentityConversion();
4069
+ User.Before.FromBracedInitList = true;
4065
4070
} else {
4066
4071
if (Best->Conversions[0].isEllipsis())
4067
4072
User.EllipsisConversion = true;
@@ -5276,6 +5281,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
5276
5281
ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false;
5277
5282
ICS.Standard.ObjCLifetimeConversionBinding =
5278
5283
(RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5284
+ ICS.Standard.FromBracedInitList = false;
5279
5285
ICS.Standard.CopyConstructor = nullptr;
5280
5286
ICS.Standard.DeprecatedStringLiteralToCharPtr = false;
5281
5287
};
@@ -5474,6 +5480,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
5474
5480
ICS.UserDefined.After.BindsToRvalue = !LValRefType;
5475
5481
ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier = false;
5476
5482
ICS.UserDefined.After.ObjCLifetimeConversionBinding = false;
5483
+ ICS.UserDefined.After.FromBracedInitList = false;
5477
5484
}
5478
5485
5479
5486
return ICS;
@@ -5760,6 +5767,8 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
5760
5767
SCS.BindsToFunctionLvalue = false;
5761
5768
SCS.BindsImplicitObjectArgumentWithoutRefQualifier = false;
5762
5769
SCS.ObjCLifetimeConversionBinding = false;
5770
+ SCS.FromBracedInitList = false;
5771
+
5763
5772
} else
5764
5773
Result.setBad(BadConversionSequence::lvalue_ref_to_rvalue,
5765
5774
From, ToType);
@@ -5777,10 +5786,13 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
5777
5786
// single integer.
5778
5787
unsigned NumInits = From->getNumInits();
5779
5788
if (NumInits == 1 && !isa<InitListExpr>(From->getInit(0)) &&
5780
- !isa<EmbedExpr>(From->getInit(0)))
5789
+ !isa<EmbedExpr>(From->getInit(0))) {
5781
5790
Result = TryCopyInitialization(
5782
5791
S, From->getInit(0), ToType, SuppressUserConversions,
5783
5792
InOverloadResolution, AllowObjCWritebackConversion);
5793
+ if (Result.isStandard())
5794
+ Result.Standard.FromBracedInitList = true;
5795
+ }
5784
5796
// - if the initializer list has no elements, the implicit conversion
5785
5797
// sequence is the identity conversion.
5786
5798
else if (NumInits == 0) {
@@ -5993,6 +6005,7 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
5993
6005
ICS.Standard.IsLvalueReference = Method->getRefQualifier() != RQ_RValue;
5994
6006
ICS.Standard.BindsToFunctionLvalue = false;
5995
6007
ICS.Standard.BindsToRvalue = FromClassification.isRValue();
6008
+ ICS.Standard.FromBracedInitList = false;
5996
6009
ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier
5997
6010
= (Method->getRefQualifier() == RQ_None);
5998
6011
return ICS;
0 commit comments