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



commit 9bcc2b4509b5408e5ca394b98f7b596e5e528a3b
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 e9e51e742..4a5f028ba 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1519,6 +1519,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 9121cf04e..51cc7e85f 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]