Commit 609ee9d5 authored by Jürg Billeter's avatar Jürg Billeter

Fix crash with unsupported use of multi-dimensional array length

Fixes bug 604589.
parent 52d84048
......@@ -411,6 +411,8 @@ internal class Vala.CCodeArrayModule : CCodeMethodCallModule {
if (lit != null && memberaccess != null) {
int dim = lit.value.to_int ();
expr.ccodenode = head.get_array_length_cexpression (memberaccess.inner, dim + 1);
} else {
Report.error (expr.source_reference, "only integer literals supported as index");
}
} else if (container_type == string_type.data_type) {
// should be moved to a different module
......
......@@ -102,6 +102,9 @@ internal class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
expr.ccodenode = new CCodeIdentifier (m.get_cname ());
}
} else if (expr.symbol_reference is ArrayLengthField) {
if (expr.value_type is ArrayType && !(expr.parent_node is ElementAccess)) {
Report.error (expr.source_reference, "unsupported use of length field of multi-dimensional array");
}
expr.ccodenode = head.get_array_length_cexpression (expr.inner, 1);
} else if (expr.symbol_reference is Field) {
var f = (Field) expr.symbol_reference;
......
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