[vala/staging] 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/staging] vala: Inline-allocated array can't be instantiated with creation expression
- Date: Sat, 21 Mar 2020 16:10:30 +0000 (UTC)
commit 09e0e526dd7e0191e46a1aa8d3bead393d33e268
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 036aff1f5..c19df41e4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -83,6 +83,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 abeca56dd..fdf738267 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -316,9 +316,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 25eec89f4..c7201d02e 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -117,9 +117,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 2d6f7188b..64e16325b 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -161,9 +161,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]