Commit 049b9b39 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Fix casting of length for "ref" array parameters

parent bd9158e4
......@@ -365,7 +365,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression? array_length_expr = null;
if (get_ccode_array_length_type (param) != null) {
array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), get_ccode_array_length_type (param));
string length_ctype = get_ccode_array_length_type (param);
if (unary.operator == UnaryOperator.REF) {
length_ctype = "%s*".printf (length_ctype);
}
array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), length_ctype);
} else {
array_length_expr = get_array_length_cexpression (arg, dim);
}
......
......@@ -86,6 +86,7 @@ TESTS = \
methods/bug620673.vala \
methods/bug622570.vala \
methods/bug626783.vala \
methods/bug634753.vala \
methods/bug639054.vala \
methods/bug642350.vala \
methods/bug642885.vala \
......
void foo ([CCode (array_length_type = "gsize")] ref uint8[] a) {
assert (a.length == 32);
}
void main () {
uint8[] a = new uint8[32];
foo (ref a);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment