From: Simon Werbeck Date: Thu, 22 Sep 2016 19:22:25 +0000 (+0200) Subject: codegen: Fix emission of constant array length X-Git-Tag: 0.35.1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7f987ab5da3bf618776572755570323d57bd9de;p=thirdparty%2Fvala.git codegen: Fix emission of constant array length https://bugzilla.gnome.org/show_bug.cgi?id=756376 --- diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala index 4f846b653..af6fc65aa 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 8ff0f3da3..941e0184b 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 000000000..c7139b894 --- /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); +}