[clang] [clang][bytecode] Add a missing fallthrough() call (PR #194537)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 27 21:47:02 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/194537
When the local variable is enabled but we don't emit any dtor instructions, we need to fallthrough to the `EndLabel`.
>From e777fbb173ef1d8b54a3a4e3a8f68d2308b6d081 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Tue, 28 Apr 2026 06:42:56 +0200
Subject: [PATCH] asdf
---
clang/lib/AST/ByteCode/Compiler.h | 1 +
clang/test/AST/ByteCode/records.cpp | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
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