https://github.com/arrowten updated https://github.com/llvm/llvm-project/pull/203715
>From 7efc304b4ebd52249ba3847ea77b27db6c6bc86b Mon Sep 17 00:00:00 2001 From: Ajay Wakodikar <[email protected]> Date: Sat, 13 Jun 2026 12:49:23 -0400 Subject: [PATCH] [Sema] Fix assertion in TreeTransform when rebuilding CXXParenListInitExpr --- clang/include/clang/AST/ExprCXX.h | 4 ++++ clang/lib/Sema/TreeTransform.h | 3 ++- .../instantiate-member-initializers.cpp | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 36e5f8940228e..28ab1b7aa6d52 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -5184,6 +5184,10 @@ class CXXParenListInitExpr final ArrayRef<Expr *> getInitExprs() const { return getTrailingObjects(NumExprs); } + MutableArrayRef<Expr *> getUserSpecifiedInitExprs() { + return getTrailingObjects(NumUserSpecifiedExprs); + } + ArrayRef<Expr *> getUserSpecifiedInitExprs() const { return getTrailingObjects(NumUserSpecifiedExprs); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 53107c827006d..8b61074d9db85 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -3412,7 +3412,8 @@ class TreeTransform { if (auto *PLE = dyn_cast<CXXParenListInitExpr>(Sub)) return getSema().BuildCXXTypeConstructExpr( - TInfo, LParenLoc, PLE->getInitExprs(), RParenLoc, ListInitialization); + TInfo, LParenLoc, PLE->getUserSpecifiedInitExprs(), RParenLoc, + ListInitialization); return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc, MultiExprArg(&Sub, 1), RParenLoc, diff --git a/clang/test/SemaTemplate/instantiate-member-initializers.cpp b/clang/test/SemaTemplate/instantiate-member-initializers.cpp index 63862063acdfe..813b0a375955a 100644 --- a/clang/test/SemaTemplate/instantiate-member-initializers.cpp +++ b/clang/test/SemaTemplate/instantiate-member-initializers.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -Wall -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wall -verify -std=c++23 %s template<typename T> struct A { A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}} @@ -41,3 +42,18 @@ template<typename T> struct Array { Array() : a() {} }; Array<int> s; + +namespace GH194986 { +#if __cplusplus >= 202302L + struct S {}; // expected-note 2{{candidate constructor}} + template <typename T> struct SS { T t1; T t2; }; + template <class T, class... Args> T C(Args... args) { return SS("foo"); } // expected-error {{no viable conversion}} + S s = C<S>(); // expected-note {{in instantiation of function template specialization 'GH194986::C<GH194986::S>'}} + + template <class T> struct SS2 { T t1, t2; }; + template <class> void C2() { + SS2("foo"); // expected-warning 2{{expression result unused}} + } + template void C2<int>(); // expected-note {{in instantiation of function template specialization 'GH194986::C2<int>'}} +#endif +}; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
