[vala/staging] codegen: Explicitly include header for length-type of arrays



commit fffba4519f94cf3a01b574390f8a748767b9094c
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Feb 1 16:29:59 2020 +0100

    codegen: Explicitly include header for length-type of arrays

 codegen/valaccodebasemodule.vala      | 3 +++
 tests/Makefile.am                     | 1 +
 tests/arrays/length-type-include.vala | 3 +++
 3 files changed, 7 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 31ac415d9..ee1c4fbb1 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1553,6 +1553,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                } else if (type is ArrayType) {
                        var array_type = (ArrayType) type;
                        generate_type_declaration (array_type.element_type, decl_space);
+                       if (array_type.length_type != null) {
+                               generate_type_declaration (array_type.length_type, decl_space);
+                       }
                } else if (type is ErrorType) {
                        var error_type = (ErrorType) type;
                        if (error_type.error_domain != null) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 14e855071..7166e74e0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -83,6 +83,7 @@ TESTS = \
        arrays/inline-parameter.test \
        arrays/inline-struct-field.test \
        arrays/length-inline-assignment.vala \
+       arrays/length-type-include.vala \
        arrays/struct-field-length-cname.vala \
        arrays/incompatible-integer-elements.test \
        arrays/slice-invalid-start.test \
diff --git a/tests/arrays/length-type-include.vala b/tests/arrays/length-type-include.vala
new file mode 100644
index 000000000..63e2ad2dd
--- /dev/null
+++ b/tests/arrays/length-type-include.vala
@@ -0,0 +1,3 @@
+void main () {
+       unowned void*[] foo = null;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]