diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index ede2b9beef49b..a83c7857fa646 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -4979,6 +4979,8 @@ static void TryReferenceListInitialization(Sema &S, if (Sequence) { if (DestType->isRValueReferenceType() || (T1Quals.hasConst() && !T1Quals.hasVolatile())) { + Sequence.AddReferenceBindingStep(cv1T1IgnoreAS, + /*BindingTemporary=*/true); if (S.getLangOpts().CPlusPlus20 && isa(T1->getUnqualifiedDesugaredType()) && DestType->isRValueReferenceType()) { @@ -4988,10 +4990,11 @@ static void TryReferenceListInitialization(Sema &S, // ..., unless T is “reference to array of unknown bound of U”, in which // case the type of the prvalue is the type of x in the declaration U // x[] H, where H is the initializer list. - Sequence.AddQualificationConversionStep(cv1T1, clang::VK_PRValue); + + // The call to AddReferenceBindingStep above converts the rvalue to an + // xvalue. Convert that xvalue to the incomplete array type. + Sequence.AddQualificationConversionStep(cv1T1, clang::VK_XValue); } - Sequence.AddReferenceBindingStep(cv1T1IgnoreAS, - /*BindingTemporary=*/true); if (T1Quals.hasAddressSpace()) Sequence.AddQualificationConversionStep( cv1T1, DestType->isRValueReferenceType() ? VK_XValue : VK_LValue);