https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/164789
Fixes https://github.com/llvm/llvm-project/issues/152901 >From f0a9067aeb93229e10796952b12aab0cc2a1a807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Thu, 23 Oct 2025 12:05:32 +0200 Subject: [PATCH] [clang][bytecode] Fix initializing primitive fields via initlist Fixes https://github.com/llvm/llvm-project/issues/152901 --- clang/lib/AST/ByteCode/Compiler.cpp | 1 - clang/test/AST/ByteCode/records.cpp | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 6b989276e6d7d..c1fbe17bc0d66 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -1842,7 +1842,6 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits, const Expr *Init, PrimType T, bool Activate = false) -> bool { InitStackScope<Emitter> ISS(this, isa<CXXDefaultInitExpr>(Init)); - InitLinkScope<Emitter> ILS(this, InitLink::Field(FieldToInit->Offset)); if (!this->visit(Init)) return false; diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp index 48cf81182c1de..868ca8c74a2f9 100644 --- a/clang/test/AST/ByteCode/records.cpp +++ b/clang/test/AST/ByteCode/records.cpp @@ -1840,3 +1840,11 @@ namespace DiamondDowncast { constexpr Middle2 &fail = (Middle2&)top1; // both-error {{must be initialized by a constant expression}} \ // both-note {{cannot cast object of dynamic type 'const Bottom' to type 'Middle2'}} } + +namespace PrimitiveInitializedByInitList { + constexpr struct { + int a; + int b{this->a}; + } c{ 17 }; + static_assert(c.b == 17); +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
