[vala/0.40] vala: Inline-allocated array can't be instantiated with creation expression
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] vala: Inline-allocated array can't be instantiated with creation expression
- Date: Tue, 24 Mar 2020 09:47:46 +0000 (UTC)
commit 79b35d7e93bb7f4abd119d51dbea16a9288665d7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Mar 21 17:09:30 2020 +0100
vala: Inline-allocated array can't be instantiated with creation expression
This generalizes 0554ed7ad9cefe0f56e53dc00be88488dfa788bf
Fixes https://gitlab.gnome.org/GNOME/vala/issues/926
tests/Makefile.am | 1 +
tests/arrays/inline-local-instantiation.test | 5 +++++
vala/valaassignment.vala | 4 ++--
vala/valafield.vala | 4 ++--
vala/valalocalvariable.vala | 4 ++--
5 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 91ed789e1..75e00fa97 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -72,6 +72,7 @@ TESTS = \
arrays/fixed-length-non-const.test \
arrays/fixed-length-resize-invalid.test \
arrays/inline-field.test \
+ arrays/inline-local-instantiation.test \
arrays/inline-local-variable.test \
arrays/inline-parameter.test \
arrays/inline-struct-field.test \
diff --git a/tests/arrays/inline-local-instantiation.test b/tests/arrays/inline-local-instantiation.test
new file mode 100644
index 000000000..329b81926
--- /dev/null
+++ b/tests/arrays/inline-local-instantiation.test
@@ -0,0 +1,5 @@
+Invalid Code
+
+void main () {
+ int foo[] = new int[1];
+}
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 38f63ea1f..0d9bf0973 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -377,9 +377,9 @@ public class Vala.Assignment : Expression {
} else if (ma.symbol_reference is Variable) {
unowned Variable variable = (Variable) ma.symbol_reference;
unowned ArrayType? variable_array_type = variable.variable_type as ArrayType;
- if (variable_array_type != null && variable_array_type.fixed_length
+ if (variable_array_type != null && variable_array_type.inline_allocated
&& right is ArrayCreationExpression && ((ArrayCreationExpression)
right).initializer_list == null) {
- Report.warning (source_reference, "Arrays with fixed length don't
require an explicit instantiation");
+ Report.warning (source_reference, "Inline allocated arrays don't
require an explicit instantiation");
((Block) parent_node.parent_node).replace_statement ((Statement)
parent_node, new EmptyStatement (source_reference));
return true;
}
diff --git a/vala/valafield.vala b/vala/valafield.vala
index 7bf66b78a..163fb011c 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -122,9 +122,9 @@ public class Vala.Field : Variable, Lockable {
}
unowned ArrayType? variable_array_type = variable_type as ArrayType;
- if (variable_array_type != null && variable_array_type.fixed_length
+ if (variable_array_type != null && variable_array_type.inline_allocated
&& initializer is ArrayCreationExpression && ((ArrayCreationExpression)
initializer).initializer_list == null) {
- Report.warning (source_reference, "Arrays with fixed length don't require an explicit
instantiation");
+ Report.warning (source_reference, "Inline allocated arrays don't require an explicit
instantiation");
initializer = null;
}
diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala
index 6762c8ce1..4bf103757 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -140,9 +140,9 @@ public class Vala.LocalVariable : Variable {
}
unowned ArrayType? variable_array_type = variable_type as ArrayType;
- if (variable_array_type != null && variable_array_type.fixed_length
+ if (variable_array_type != null && variable_array_type.inline_allocated
&& initializer is ArrayCreationExpression && ((ArrayCreationExpression)
initializer).initializer_list == null) {
- Report.warning (source_reference, "Arrays with fixed length don't require an explicit
instantiation");
+ Report.warning (source_reference, "Inline allocated arrays don't require an explicit
instantiation");
initializer = null;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]