aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/06-goto.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/06-goto.c')
-rw-r--r--test/06-goto.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/06-goto.c b/test/06-goto.c
new file mode 100644
index 0000000..075467c
--- /dev/null
+++ b/test/06-goto.c
@@ -0,0 +1,32 @@
+/* EXPECT:
+7 -> 14
+-3 -> 0
+0 -> 0
+2 -> 4
+*/
+int crz(int x) {
+/* x <<= 1; while (x < 0) ++x; return x; */
+ goto e;
+a:
+ return x;
+j:
+ ++x;
+ goto q;
+b:
+ if (x < 0)
+ goto j;
+ goto a;
+q:
+ goto b;
+e:
+ x <<= 1;
+ goto b;
+}
+
+int printf(const char *, ...);
+int main(int n) {
+ n = 7, printf("%d -> %d\n", n, crz(n));
+ n = -3, printf("%d -> %d\n", n, crz(n));
+ n = 0, printf("%d -> %d\n", n, crz(n));
+ n = 2, printf("%d -> %d\n", n, crz(n));
+}