[clang] [Clang] Disallow `break`/`continue` in loop conditions (PR #198436)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 20 07:00:15 PDT 2026


================
@@ -636,6 +622,16 @@ class Scope {
   /// is an ancestor of the other.
   bool Contains(const Scope& rhs) const { return Depth < rhs.Depth; }
 
+  /// Mark that we're entering the body of a loop (for, while, do).
+  void EnterLoopBody(LabelDecl *PrecedingLabel);
+
+  /// Mark that we're entering the body of a switch statement.
+  void EnterSwitchBody(LabelDecl *PrecedingLabel);
+
+  /// Mark that we're leaving the body of a loop; this is only needed for do
+  /// loops where the condition follows the loop body.
+  void LeaveLoopBody();
----------------
Sirraide wrote:

I mean, we could call it `DisallowBreakContinue` because that’s what it actually does if you prefer that

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


More information about the cfe-commits mailing list