aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/8-runtime/o3_break_continue_leave.zc
blob: 8cd9647f61d82c0b8ebb48689d78b51192e77fc6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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