[clang] 4c092f6 - [clang][bytecode] Add a missing fallthrough() call (#194537)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 27 22:50:48 PDT 2026
Author: Timm Baeder
Date: 2026-04-28T07:50:43+02:00
New Revision: 4c092f6efb8bb25cafb336ca0787659b34906886
URL: https://github.com/llvm/llvm-project/commit/4c092f6efb8bb25cafb336ca0787659b34906886
DIFF: https://github.com/llvm/llvm-project/commit/4c092f6efb8bb25cafb336ca0787659b34906886.diff
LOG: [clang][bytecode] Add a missing fallthrough() call (#194537)
When the local variable is enabled but we don't emit any dtor
instructions, we need to fallthrough to the `EndLabel`.
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.h
clang/test/AST/ByteCode/records.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h
index a80f19e07e70a..ce5db0d544169 100644
--- a/clang/lib/AST/ByteCode/Compiler.h
+++ b/clang/lib/AST/ByteCode/Compiler.h
@@ -629,6 +629,7 @@ template <class Emitter> class LocalScope : public VariableScope<Emitter> {
if (!this->Ctx->emitDestructionPop(Local.Desc, Local.Desc->getLoc()))
return false;
+ this->Ctx->fallthrough(EndLabel);
this->Ctx->emitLabel(EndLabel);
} else {
if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp
index bb2e0821fc8f8..6008fc1a85f91 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -466,7 +466,14 @@ namespace ConditionalInit {
static_assert(getS(true).a == 12, "");
static_assert(getS(false).a == 13, "");
-};
+
+ struct T {
+ virtual ~T() = default;
+ };
+ struct D : T {};
+ void foo() { const T &t = true ? (const T)(D()) : D(); }
+}
+
namespace DeclRefs {
struct A{ int m; const int &f = m; };
More information about the cfe-commits
mailing list