diff options
Diffstat (limited to 'tests/errors')
| -rw-r--r-- | tests/errors/uninit_branch.zc | 10 | ||||
| -rw-r--r-- | tests/errors/uninit_loop.zc | 11 | ||||
| -rw-r--r-- | tests/errors/uninit_partial_array.zc | 10 | ||||
| -rw-r--r-- | tests/errors/uninit_partial_struct.zc | 12 | ||||
| -rw-r--r-- | tests/errors/uninit_read.zc | 9 |
5 files changed, 52 insertions, 0 deletions
diff --git a/tests/errors/uninit_branch.zc b/tests/errors/uninit_branch.zc new file mode 100644 index 0000000..e4d253b --- /dev/null +++ b/tests/errors/uninit_branch.zc @@ -0,0 +1,10 @@ +namespace; +include rt; + +// expect: x: used before it is initialized +fn main() { + int x; + if (rt.get_c()) x = 1; + rt.put_n(x); + return 0; +} diff --git a/tests/errors/uninit_loop.zc b/tests/errors/uninit_loop.zc new file mode 100644 index 0000000..d345296 --- /dev/null +++ b/tests/errors/uninit_loop.zc @@ -0,0 +1,11 @@ +namespace; +include rt; + +// expect: x: used before it is initialized +fn main() { + int x; + int n = 0; + while (n) { x = 1; n = 0; } + rt.put_n(x); + return 0; +} diff --git a/tests/errors/uninit_partial_array.zc b/tests/errors/uninit_partial_array.zc new file mode 100644 index 0000000..d30310f --- /dev/null +++ b/tests/errors/uninit_partial_array.zc @@ -0,0 +1,10 @@ +namespace; +include rt; + +// expect: a: used before it is initialized +fn main() { + int[4] a; + a[0] = 1; + rt.put_n(a[1]); + return 0; +} diff --git a/tests/errors/uninit_partial_struct.zc b/tests/errors/uninit_partial_struct.zc new file mode 100644 index 0000000..7b65481 --- /dev/null +++ b/tests/errors/uninit_partial_struct.zc @@ -0,0 +1,12 @@ +namespace; +include rt; + +struct point { int x; int y; } + +// expect: p: used before it is initialized +fn main() { + point p; + p.x = 1; + rt.put_n(p.y); + return 0; +} diff --git a/tests/errors/uninit_read.zc b/tests/errors/uninit_read.zc new file mode 100644 index 0000000..3a18a95 --- /dev/null +++ b/tests/errors/uninit_read.zc @@ -0,0 +1,9 @@ +namespace; +include rt; + +// expect: x: used before it is initialized +fn main() { + int x; + rt.put_n(x); + return 0; +} |
