diff options
author | Congcong Cai <congcongcai0907@163.com> | 2023-09-30 05:50:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-30 05:50:38 +0800 |
commit | d89d3a6a0eb3e5f9ad35cd8b64a7237ed227f10b (patch) | |
tree | fd6c48673b9ee02c89f39f9f640249de51992fc2 /clang/lib/Sema/SemaInit.cpp | |
parent | a54f31fabd55ab111484b1e094e3d2c6b29c4715 (diff) | |
download | llvm-d89d3a6a0eb3e5f9ad35cd8b64a7237ed227f10b.zip llvm-d89d3a6a0eb3e5f9ad35cd8b64a7237ed227f10b.tar.gz llvm-d89d3a6a0eb3e5f9ad35cd8b64a7237ed227f10b.tar.bz2 |
[Sema] add cast from IncompleteArrayType to ConstantArrayType in TryReferenceListInitialization (#65918)
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()) |