diff options
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index cb57a2d..de576cc 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -18,6 +18,7 @@ #include "clang/AST/TypeLoc.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/Specifiers.h" #include "clang/Basic/TargetInfo.h" #include "clang/Sema/Designator.h" #include "clang/Sema/EnterExpressionEvaluationContext.h" @@ -4528,6 +4529,17 @@ static void TryReferenceListInitialization(Sema &S, if (Sequence) { if (DestType->isRValueReferenceType() || (T1Quals.hasConst() && !T1Quals.hasVolatile())) { + if (S.getLangOpts().CPlusPlus20 && + isa<IncompleteArrayType>(T1->getUnqualifiedDesugaredType()) && + DestType->isRValueReferenceType()) { + // C++20 [dcl.init.list]p3.10: + // List-initialization of an object or reference of type T is defined as + // follows: + // ..., 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); + } Sequence.AddReferenceBindingStep(cv1T1IgnoreAS, /*BindingTemporary=*/true); if (T1Quals.hasAddressSpace()) |