llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Otherwise we have no scope to attach temporary variables created as part of the virtual base initializer to. --- Full diff: https://github.com/llvm/llvm-project/pull/237933.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+1) - (modified) clang/test/AST/ByteCode/virtual-bases.cpp (+9) ``````````diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 71f761f58aed28..dc59a12bbde811 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -7759,6 +7759,7 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) { return false; for (const auto *Init : Ctor->inits()) { + LocalScope<Emitter> VirtLocalScope(this); if (const Type *Base = Init->getBaseClass(); Base && Init->isBaseVirtual()) { const auto *BaseDecl = Base->getAsCXXRecordDecl(); diff --git a/clang/test/AST/ByteCode/virtual-bases.cpp b/clang/test/AST/ByteCode/virtual-bases.cpp index f8dabd43749a50..47e8bbd6a2daf8 100644 --- a/clang/test/AST/ByteCode/virtual-bases.cpp +++ b/clang/test/AST/ByteCode/virtual-bases.cpp @@ -486,3 +486,12 @@ namespace MostDerivedIsArrayElem { static_assert(d[8].n == 7); static_assert(d[8].k == 0); } + +namespace TemoprariesInVirtualBaseInitializer { + struct S {}; + struct C { + C(C &, S s = S()); + }; + struct D : virtual C {}; + void foo(D d) { D d2(d); }; +} `````````` </details> https://github.com/llvm/llvm-project/pull/237933 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
