[vala] Fix cast from non-array to array type
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Fix cast from non-array to array type
- Date: Mon, 10 Aug 2009 18:52:43 +0000 (UTC)
commit 6df5b8acde1ea4bfa28fe2b3768ff480d3d7aa66
Author: Jürg Billeter <j bitron ch>
Date: Mon Aug 10 20:51:10 2009 +0200
Fix cast from non-array to array type
Fixes bug 590785.
codegen/valaccodearraymodule.vala | 8 ++++++--
codegen/valaccodebasemodule.vala | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 515c491..4520974 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -163,7 +163,9 @@ internal class Vala.CCodeArrayModule : CCodeMethodCallModule {
return (CCodeExpression) get_ccodenode (length_expr);
} else if (array_expr is MethodCall || array_expr is CastExpression) {
Gee.List<CCodeExpression> size = array_expr.get_array_sizes ();
- return size[dim - 1];
+ if (size.size >= dim) {
+ return size[dim - 1];
+ }
} else if (array_expr.symbol_reference != null) {
if (array_expr.symbol_reference is FormalParameter) {
var param = (FormalParameter) array_expr.symbol_reference;
@@ -276,7 +278,9 @@ internal class Vala.CCodeArrayModule : CCodeMethodCallModule {
var prop = (Property) array_expr.symbol_reference;
if (!prop.no_array_length) {
Gee.List<CCodeExpression> size = array_expr.get_array_sizes ();
- return size[dim - 1];
+ if (size.size >= dim) {
+ return size[dim - 1];
+ }
}
}
} else if (array_expr is NullLiteral) {
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 21506b1..6005a64 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3444,7 +3444,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
// retain array length
var array_type = expr.type_reference as ArrayType;
- if (array_type != null) {
+ if (array_type != null && expr.inner.value_type is ArrayType) {
for (int dim = 1; dim <= array_type.rank; dim++) {
expr.append_array_size (get_array_length_cexpression (expr.inner, dim));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]