From: Florian Brosch Date: Tue, 16 Sep 2014 22:17:01 +0000 (+0200) Subject: vala: Do not allow += for arrays with fixed length X-Git-Tag: 0.47.1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d3290e44c1acba6b18584f4c52d40765883b581;p=thirdparty%2Fvala.git vala: Do not allow += for arrays with fixed length --- diff --git a/tests/Makefile.am b/tests/Makefile.am index a80d7a27a..775110cbb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -74,6 +74,7 @@ TESTS = \ arrays/class-field-length-cname.vala \ arrays/expression-bracket.test \ arrays/field-global-length-cname.vala \ + arrays/fixed-length-concat-invalid.test \ arrays/fixed-length-non-const.test \ arrays/struct-field-length-cname.vala \ arrays/incompatible-integer-elements.test \ diff --git a/tests/arrays/fixed-length-concat-invalid.test b/tests/arrays/fixed-length-concat-invalid.test new file mode 100644 index 000000000..99f24a34b --- /dev/null +++ b/tests/arrays/fixed-length-concat-invalid.test @@ -0,0 +1,6 @@ +Invalid Code + +void main () { + int foo[2] = { 23, 42 }; + foo += 4711; +} diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala index f9b66e377..4f1f642f5 100644 --- a/vala/valabinaryexpression.vala +++ b/vala/valabinaryexpression.vala @@ -346,6 +346,10 @@ public class Vala.BinaryExpression : Expression { unowned ArrayType array_type = (ArrayType) left.value_type; + if (array_type.inline_allocated) { + error = true; + Report.error (source_reference, "Array concatenation not supported for fixed length arrays"); + } if (right.value_type == null || !right.value_type.compatible (array_type.element_type)) { error = true; Report.error (source_reference, "Incompatible operand");