From 368d6583bf9ee11f5d036ced10e8a8efe04adec8 Mon Sep 17 00:00:00 2001 From: Florian Brosch Date: Wed, 17 Sep 2014 00:17:01 +0200 Subject: [PATCH] vala: Do not allow += for arrays with fixed length --- tests/Makefile.am | 1 + tests/arrays/fixed-length-concat-invalid.test | 6 ++++++ vala/valabinaryexpression.vala | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 tests/arrays/fixed-length-concat-invalid.test diff --git a/tests/Makefile.am b/tests/Makefile.am index 028064545..ee3f8af25 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -73,6 +73,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 5e9b7be42..32d5012b5 100644 --- a/vala/valabinaryexpression.vala +++ b/vala/valabinaryexpression.vala @@ -343,6 +343,10 @@ public class Vala.BinaryExpression : Expression { var 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"); -- 2.47.2