[vala/0.12] codegen: Guard pointer indirection of lengths when returning arrays
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.12] codegen: Guard pointer indirection of lengths when returning arrays
- Date: Sun, 29 May 2011 11:22:13 +0000 (UTC)
commit 6f7b4f9f1fc06af1649895893baaf2650542d5b1
Author: Luca Bruno <lucabru src gnome org>
Date: Tue May 24 23:47:45 2011 +0200
codegen: Guard pointer indirection of lengths when returning arrays
Fixes bug 638415.
codegen/valaccodebasemodule.vala | 2 ++
tests/Makefile.am | 1 +
tests/delegates/bug638415.vala | 12 ++++++++++++
3 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index d130235..3e14c7c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -3374,11 +3374,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
for (int dim = 1; dim <= array_type.rank; dim++) {
var len_l = get_result_cexpression (get_array_length_cname ("result", dim));
+ ccode.open_if (len_l);
if (!is_in_coroutine ()) {
len_l = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, len_l);
}
var len_r = get_array_length_cexpression (stmt.return_expression, dim);
ccode.add_assignment (len_l, len_r);
+ ccode.close ();
}
set_cvalue (stmt.return_expression, get_variable_cexpression (return_expr_decl.name));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0d6e165..4eb2251 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -56,6 +56,7 @@ TESTS = \
delegates/delegates.vala \
delegates/bug595610.vala \
delegates/bug595639.vala \
+ delegates/bug638415.vala \
delegates/bug639751.vala \
objects/classes.vala \
objects/fields.vala \
diff --git a/tests/delegates/bug638415.vala b/tests/delegates/bug638415.vala
new file mode 100644
index 0000000..2e98842
--- /dev/null
+++ b/tests/delegates/bug638415.vala
@@ -0,0 +1,12 @@
+[CCode (array_length = false)]
+public delegate string[] Deleg ();
+
+string[] foo () {
+ return new string[0];
+}
+
+void main () {
+ Deleg bar = foo;
+ bar ();
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]