From 7ff224faa88725fe59441e73c70dfa4eedd76345 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 02:39:49 +0330 Subject: o3: break and continue out of an o3 { } block call rt.o3_leave for each block they leave (the loop records the o3 depth it began at), so the depth returns to 0 and pending collections and drops run; spec 4.10.3, o3_break_continue_leave.zc --- .../8-runtime/o3_break_continue_leave.zc | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/conformance/8-runtime/o3_break_continue_leave.zc (limited to 'tests/conformance') diff --git a/tests/conformance/8-runtime/o3_break_continue_leave.zc b/tests/conformance/8-runtime/o3_break_continue_leave.zc new file mode 100644 index 0000000..8cd9647 --- /dev/null +++ b/tests/conformance/8-runtime/o3_break_continue_leave.zc @@ -0,0 +1,28 @@ +// expect: 0 0 3 0 dropped/ +// spec 4.10.3: break and continue out of an o3 { } block leave the region like its end or a return, so the o3 depth is back to 0 after the loop and a drop can run again +include rt; +fn main() { + int i = 0, n = 0; + while (i < 10) { + o3 { + if (i == 4) break; + i++; + } + } + rt.put_n(rt.o3_depth); rt.put_c(32); + i = 0; + while (i < 6) { + i++; + o3 { + if (i % 2 == 0) continue; + n++; + } + } + rt.put_n(rt.o3_depth); rt.put_c(32); rt.put_n(n); rt.put_c(32); + for (int k = 0; k < 3; k++) { o3 { if (k == 1) continue; if (k == 2) break; } } + rt.put_n(rt.o3_depth); rt.put_c(32); + { int* p = drop(heap(1), fn() { rt.put_s("dropped"); }); } + rt.put_c(10); + return 0; +} +// zc0: skip -- cgit v1.2.3