diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-02-17 17:43:24 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-02-17 17:54:29 +0100 |
commit | a0bb129e5a2e8580eb272d9a68ba054e7b170dba (patch) | |
tree | 1c442691b9f429c500dad1e2a4b5878535b9ac00 /tests | |
parent | 8eef5ff1b22e4585ab90efc50618de7184646352 (diff) | |
download | vala-a0bb129e5a2e8580eb272d9a68ba054e7b170dba.tar.gz |
codegen: Don't initialize stack-allocated array with local-constant length
Fixes https://gitlab.gnome.org/GNOME/vala/issues/910
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/arrays/fixed-length-init0-not-allowed.vala | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 8079e335a..f683d18c7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -75,6 +75,7 @@ TESTS = \ arrays/cast-silent-invalid.test \ arrays/class-field-length-cname.vala \ arrays/expression-bracket.test \ + arrays/fixed-length-init0-not-allowed.vala \ arrays/field-global-length-cname.vala \ arrays/fixed-length-concat-invalid.test \ arrays/fixed-length-non-const.test \ diff --git a/tests/arrays/fixed-length-init0-not-allowed.vala b/tests/arrays/fixed-length-init0-not-allowed.vala new file mode 100644 index 000000000..932f011b3 --- /dev/null +++ b/tests/arrays/fixed-length-init0-not-allowed.vala @@ -0,0 +1,13 @@ +void main () { + const int FOO = 4; + + char bar[FOO] = { 'f', 'o', 'o', '\0' }; + assert ((string) bar == "foo"); + + char baz[FOO]; + baz[0] = 'f'; + baz[1] = 'o'; + baz[2] = 'o'; + baz[3] = '\0'; + assert ((string) baz == "foo"); +} |