[vala] codegen: Fix emission of constant array length



commit e7f987ab5da3bf618776572755570323d57bd9de
Author: Simon Werbeck <simon werbeck gmail com>
Date:   Thu Sep 22 21:22:25 2016 +0200

    codegen: Fix emission of constant array length
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756376

 codegen/valaccodememberaccessmodule.vala |    2 +-
 tests/Makefile.am                        |    1 +
 tests/basic-types/bug756376.vala         |   12 ++++++++++++
 3 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 4f846b6..af6fc65 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -674,7 +674,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                if (array_type != null) {
                        if (array_type.fixed_length) {
                                result.array_length_cvalues = null;
-                               result.append_array_length_cvalue (new CCodeConstant 
(array_type.length.to_string ()));
+                               result.append_array_length_cvalue (get_ccodenode (array_type.length));
                                result.lvalue = false;
                        } else if (get_ccode_array_null_terminated (variable)) {
                                requires_array_length = true;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8ff0f3d..941e018 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,6 +40,7 @@ TESTS = \
        basic-types/bug686336.vala \
        basic-types/bug729907.vala \
        basic-types/bug731017.vala \
+       basic-types/bug756376.vala \
        basic-types/bug761307.vala \
        basic-types/bug771626.test \
        namespaces.vala \
diff --git a/tests/basic-types/bug756376.vala b/tests/basic-types/bug756376.vala
new file mode 100644
index 0000000..c7139b8
--- /dev/null
+++ b/tests/basic-types/bug756376.vala
@@ -0,0 +1,12 @@
+namespace Foo {
+       const int BAR = 5;
+}
+
+void bar (int[] a) {
+}
+
+void main () {
+       int arr[Foo.BAR];
+
+       bar (arr);
+}


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