]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix emission of constant array length
authorSimon Werbeck <simon.werbeck@gmail.com>
Thu, 22 Sep 2016 19:22:25 +0000 (21:22 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 5 Oct 2016 06:20:11 +0000 (08:20 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=756376

codegen/valaccodememberaccessmodule.vala
tests/Makefile.am
tests/basic-types/bug756376.vala [new file with mode: 0644]

index 4f846b6536d1055937cb9c5c9d122464482b22b8..af6fc65aab892349e5dfb0facdf648d4ebc01856 100644 (file)
@@ -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;
index 8ff0f3da33cd663ebb9e3a1ec4f5bb639c5452b6..941e0184b8d49c056fc288927c57926a4e1b3644 100644 (file)
@@ -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 (file)
index 0000000..c7139b8
--- /dev/null
@@ -0,0 +1,12 @@
+namespace Foo {
+       const int BAR = 5;
+}
+
+void bar (int[] a) {
+}
+
+void main () {
+       int arr[Foo.BAR];
+
+       bar (arr);
+}