[vala/0.34] codegen: Don't append fixed-length of array fields in initializers
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.34] codegen: Don't append fixed-length of array fields in initializers
- Date: Mon, 16 Apr 2018 20:00:05 +0000 (UTC)
commit 26219fe5216873f65b3395f25fb2d4e72783a373
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Feb 15 18:07:36 2018 +0100
codegen: Don't append fixed-length of array fields in initializers
codegen/valaccodebasemodule.vala | 2 +-
tests/basic-types/arrays.vala | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index d8a6329..6df6714 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2518,7 +2518,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
clist.append (cexpr);
var array_type = field.variable_type as ArrayType;
- if (array_type != null && get_ccode_array_length (field) &&
!get_ccode_array_null_terminated (field)) {
+ if (array_type != null && !array_type.fixed_length &&
get_ccode_array_length (field) && !get_ccode_array_null_terminated (field)) {
for (int dim = 1; dim <= array_type.rank; dim++) {
clist.append (get_array_length_cvalue
(expr.target_value, dim));
}
diff --git a/tests/basic-types/arrays.vala b/tests/basic-types/arrays.vala
index fece749..0bb7048 100644
--- a/tests/basic-types/arrays.vala
+++ b/tests/basic-types/arrays.vala
@@ -191,6 +191,19 @@ void test_void_array () {
assert ((void*) null in a);
}
+struct Foo {
+ unowned string array[2];
+ int bar;
+}
+
+const Foo[] FOO_ARRAY_CONST = {
+ { { "foo", "bar" }, 42 },
+};
+
+void test_struct_array () {
+ assert (FOO_ARRAY_CONST[0].bar == 42);
+}
+
void main () {
test_integer_array ();
test_string_array ();
@@ -202,4 +215,5 @@ void main () {
test_delegate_array ();
test_generics_array ();
test_void_array ();
+ test_struct_array ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]