llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

Happens in error cases.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+3-1) 
- (modified) clang/test/AST/ByteCode/invalid.cpp (+13) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index a0138c402e143..58871fe79b36d 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6036,7 +6036,9 @@ bool Compiler<Emitter>::visitBreakStmt(const BreakStmt 
*S) {
     }
   }
 
-  assert(TargetLabel);
+  // Faulty break statement (e.g. label redefined or named loops disabled).
+  if (!TargetLabel)
+    return false;
 
   for (VariableScope<Emitter> *C = this->VarScope; C != BreakScope;
        C = C->getParent()) {
diff --git a/clang/test/AST/ByteCode/invalid.cpp 
b/clang/test/AST/ByteCode/invalid.cpp
index c8298fa2c2b9b..f7d11a9be3f8e 100644
--- a/clang/test/AST/ByteCode/invalid.cpp
+++ b/clang/test/AST/ByteCode/invalid.cpp
@@ -151,3 +151,16 @@ namespace NullRecord {
   };
   S2 s = S2();
 }
+
+namespace NamedLoops {
+  constexpr int foo() {
+  bar: // both-note {{previous definition is here}} \
+       // both-warning {{use of this statement in a constexpr function is a 
C++23 extension}}
+    return 0;
+
+  bar: // both-error {{redefinition of label 'bar'}}
+    do {
+      break bar; // both-error {{named 'break' is only supported in C2y}}
+    } while (0);
+  }
+}

``````````

</details>


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

Reply via email to