aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-15 02:39:49 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-15 02:40:51 +0330
commit7ff224faa88725fe59441e73c70dfa4eedd76345 (patch)
tree2c8af51b9fc3ea3efe45e43ac0c8ab38ab709fe8 /tests/conformance
parentrt: memreport marks a leaked value whose drop never ran with (drop); spec 4.1... (diff)
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
Diffstat (limited to 'tests/conformance')
-rw-r--r--tests/conformance/8-runtime/o3_break_continue_leave.zc28
1 files changed, 28 insertions, 0 deletions
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