https://github.com/efriedma-quic updated 
https://github.com/llvm/llvm-project/pull/187618

>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 1/3] 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);

>From ffd53ee76641ae6fc7183998665e44959e1a4c63 Mon Sep 17 00:00:00 2001
From: Eli Friedman <[email protected]>
Date: Sat, 21 Mar 2026 17:33:39 -0700
Subject: [PATCH 2/3] Address review comment

---
 clang/lib/Sema/SemaInit.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 1a7828bca5044..6556b50afa30a 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4990,6 +4990,9 @@ 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.
+
+        // The call to AddReferenceBindingStep above converts the rvalue to an 
xvalue.
+        // Convert that xvalue to the incomplete array type.
         Sequence.AddQualificationConversionStep(cv1T1, clang::VK_XValue);
       }
       if (T1Quals.hasAddressSpace())

>From 081b516909f60dccc6fd41c88c46fcc315ab3e9b Mon Sep 17 00:00:00 2001
From: Eli Friedman <[email protected]>
Date: Sat, 21 Mar 2026 23:30:50 -0700
Subject: [PATCH 3/3] Fix formatting

---
 clang/lib/Sema/SemaInit.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 6556b50afa30a..a83c7857fa646 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4991,8 +4991,8 @@ static void TryReferenceListInitialization(Sema &S,
         // case the type of the prvalue is the type of x in the declaration U
         // x[] H, where H is the initializer list.
 
-        // The call to AddReferenceBindingStep above converts the rvalue to an 
xvalue.
-        // Convert that xvalue to the incomplete array type.
+        // The call to AddReferenceBindingStep above converts the rvalue to an
+        // xvalue. Convert that xvalue to the incomplete array type.
         Sequence.AddQualificationConversionStep(cv1T1, clang::VK_XValue);
       }
       if (T1Quals.hasAddressSpace())

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to