[vala/0.46] vala: Do not allow += for arrays with fixed length
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] vala: Do not allow += for arrays with fixed length
- Date: Wed, 30 Oct 2019 07:45:29 +0000 (UTC)
commit eb9672b74138205d05bb55f6dbaa80adb4adb66b
Author: Florian Brosch <flo brosch gmail com>
Date: Wed Sep 17 00:17:01 2014 +0200
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(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ea81bf8bb..79ce4a758 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 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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]