llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Eli Friedman (efriedma-quic)
<details>
<summary>Changes</summary>
This affects constructs like `int f(int (&&x)[]); int z = f({1});`.
A temporary logically can't have incomplete type: if we don't know the type, we
can't materialize it. Rearrange the casts to make more sense.
I'm not sure this has any practical effects at the moment due to the way we use
skipRValueSubobjectAdjustments; we usually end up ignoring the type of the
MaterializeTemporaryExpr.
---
Full diff: https://github.com/llvm/llvm-project/pull/187618.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaInit.cpp (+3-3)
``````````diff
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ede2b9beef49b..1a7828bca5044 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<IncompleteArrayType>(T1->getUnqualifiedDesugaredType()) &&
DestType->isRValueReferenceType()) {
@@ -4988,10 +4990,8 @@ 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);
+ Sequence.AddQualificationConversionStep(cv1T1, clang::VK_XValue);
}
- Sequence.AddReferenceBindingStep(cv1T1IgnoreAS,
- /*BindingTemporary=*/true);
if (T1Quals.hasAddressSpace())
Sequence.AddQualificationConversionStep(
cv1T1, DestType->isRValueReferenceType() ? VK_XValue : VK_LValue);
``````````
</details>
https://github.com/llvm/llvm-project/pull/187618
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits