https://github.com/IvyXu420 updated https://github.com/llvm/llvm-project/pull/228340
>From e18bacfeed81a1cf3cd085a88e34ee359079c54d Mon Sep 17 00:00:00 2001 From: Ivy Xu <[email protected]> Date: Fri, 2 Oct 2026 03:38:40 +0800 Subject: [PATCH 1/3] Fix clang rejecting valid `void{}` when template is used --- clang/lib/Sema/SemaExprCXX.cpp | 2 +- clang/test/CXX/drs/cwg23xx.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 1bf6430665ddf..1ed58fcf20af0 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1647,7 +1647,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, return CXXFunctionalCastExpr::Create( Context, Ty.getUnqualifiedType(), VK_PRValue, TInfo, CK_ToVoid, Exprs[0], /*Path=*/nullptr, CurFPFeatureOverrides(), - Exprs[0]->getBeginLoc(), Exprs[0]->getEndLoc()); + SourceLocation(), Exprs[0]->getEndLoc()); } } else if (RequireCompleteType(TyBeginLoc, ElemTy, diag::err_invalid_incomplete_type_use, diff --git a/clang/test/CXX/drs/cwg23xx.cpp b/clang/test/CXX/drs/cwg23xx.cpp index cfd78465c0dbe..c81fe223a596c 100644 --- a/clang/test/CXX/drs/cwg23xx.cpp +++ b/clang/test/CXX/drs/cwg23xx.cpp @@ -240,6 +240,10 @@ namespace cwg2351 { // cwg2351: 20 template void i<void>(); template const void i<const void>(); + template <class T> + void f(T) { void{}; } + void g() { f(1); } + static_assert((void({}), true), ""); // since-cxx11-error@-1 {{cannot initialize non-class type 'void' with a parenthesized initializer list}} #else >From 71dd64f2aa5951756198f7ad7a99bd1ab851be3a Mon Sep 17 00:00:00 2001 From: Ivy Xu <[email protected]> Date: Fri, 2 Oct 2026 14:25:05 +0800 Subject: [PATCH 2/3] Add release note --- clang/docs/ReleaseNotes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index d22874d4130ee..04ded7c5b6a2e 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -801,6 +801,9 @@ features cannot lower the translation-unit ABI level; take effect, causing them to be dropped from llvm.used and omitted from the object file. (#GH226572) +- Fixed rejection of non-dependent `void{}` during template instantiation, + which previously rebuilt the expression as `void({})`. (#GH226485, #GH181448) + #### Bug Fixes to AST Handling - Fixed a non-deterministic ordering of unused local typedefs that made >From ed5657d9a4fcb2dadbbc190d6ca7e4277fcfc5ff Mon Sep 17 00:00:00 2001 From: Ivy Xu <[email protected]> Date: Fri, 2 Oct 2026 15:20:06 +0800 Subject: [PATCH 3/3] fix the format --- clang/lib/Sema/SemaExprCXX.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 1ed58fcf20af0..bb08c3bf1a0e4 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1646,8 +1646,8 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, cast<InitListExpr>(Exprs[0])->getNumInits() == 0) { return CXXFunctionalCastExpr::Create( Context, Ty.getUnqualifiedType(), VK_PRValue, TInfo, CK_ToVoid, - Exprs[0], /*Path=*/nullptr, CurFPFeatureOverrides(), - SourceLocation(), Exprs[0]->getEndLoc()); + Exprs[0], /*Path=*/nullptr, CurFPFeatureOverrides(), SourceLocation(), + Exprs[0]->getEndLoc()); } } else if (RequireCompleteType(TyBeginLoc, ElemTy, diag::err_invalid_incomplete_type_use, _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
