diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -4423,6 +4423,15 @@ if (T1Quals.hasAddressSpace()) Sequence.AddQualificationConversionStep( cv1T1, DestType->isRValueReferenceType() ? VK_XValue : VK_LValue); + else if (S.getLangOpts().CPlusPlus20 && + isa(T1->getUnqualifiedDesugaredType()) && + DestType->isRValueReferenceType()) { + // [dcl.init.list] p3.10 + // 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, VK_XValue); + } } else Sequence.SetFailed( InitializationSequence::FK_NonConstLValueReferenceBindingToTemporary); diff --git a/clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp b/clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp --- a/clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp +++ b/clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp @@ -23,4 +23,13 @@ return r2; } + +// CHECK-LABEL: @_ZN3One3fooEi +// CHECK-NEXT: entry: +// CHECK-NEXT: ret void +void foo(int a) { + auto f = [](int(&&)[]) {}; + f({a}); +} + } // namespace One