[clang] [clang][bytecode] Add a missing fallthrough() call (PR #194537)

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 21:47:35 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

When the local variable is enabled but we don't emit any dtor instructions, we need to fallthrough to the `EndLabel`.

---
Full diff: https://github.com/llvm/llvm-project/pull/194537.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.h (+1) 
- (modified) clang/test/AST/ByteCode/records.cpp (+8-1) 


``````````diff
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; };
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/194537


More information about the cfe-commits mailing list