https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/216547

We need to handle the missing TargetLabel here, similarly to what we do in 
break statements.

>From 0df7cc8ca3ad349cbd5396070eb6cd9c53a39cd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Sun, 16 Aug 2026 09:23:08 +0200
Subject: [PATCH] [clang][bytecode] Fix assertion failure in in valid continue
 stmt

We need to handle the missing TargetLabel here, similarly to what we do
in break statements.
---
 clang/lib/AST/ByteCode/Compiler.cpp |  4 +++-
 clang/test/AST/ByteCode/cxx23.cpp   | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index bfb5df69b0e3a..a8e2cb4a3c076 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -7023,7 +7023,9 @@ bool Compiler<Emitter>::visitContinueStmt(const 
ContinueStmt *S) {
       }
     }
   }
-  assert(TargetLabel);
+
+  if (!TargetLabel)
+    return false;
 
   for (VariableScope<Emitter> *C = VarScope; C != ContinueScope;
        C = C->getParent()) {
diff --git a/clang/test/AST/ByteCode/cxx23.cpp 
b/clang/test/AST/ByteCode/cxx23.cpp
index 5607ec9b59cb5..17a4277205f86 100644
--- a/clang/test/AST/ByteCode/cxx23.cpp
+++ b/clang/test/AST/ByteCode/cxx23.cpp
@@ -650,6 +650,19 @@ namespace DynamicCast {
 }
 
 #if __cplusplus >= 202302L
+namespace BrokenContinueLabel {
+  constexpr int test() {
+  bar: {} // all-note {{here}}
+  bar: // all-error {{redefinition of label 'bar'}}
+    for (;;) {
+      continue bar; // all-error {{only supported in C2y}}
+    }
+    return 0;
+  }
+
+  static_assert(test(), ""); // all-error {{not an integral constant 
expression}}
+}
+
 namespace BrokenShuffleVector {
   typedef float __m128 __attribute__((__vector_size__(16)));
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to