https://github.com/efriedma-quic created
https://github.com/llvm/llvm-project/pull/187618
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.
>From d6ad756f2478fbe978995b000468bc7e28dcfb8b Mon Sep 17 00:00:00 2001
From: Eli Friedman <[email protected]>
Date: Thu, 19 Mar 2026 17:59:23 -0700
Subject: [PATCH] Fix type of the MaterializeTemporaryExpr with incomplete
array type.
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.
---
clang/lib/Sema/SemaInit.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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);
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits