From: Juerg Billeter Date: Mon, 7 Apr 2008 18:19:21 +0000 (+0000) Subject: reset takes_ownership and transfers_ownership for base types of pointer X-Git-Tag: VALA_0_2_0~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad39cd50b83c47cc10e4fa0b7da90cd25dffd475;p=platform%2Fupstream%2Fvala.git reset takes_ownership and transfers_ownership for base types of pointer 2008-04-07 Juerg Billeter * vala/valasymbolresolver.vala: reset takes_ownership and transfers_ownership for base types of pointer types * tests/pointers.vala: test element access for methods returning pointers svn path=/trunk/; revision=1178 --- diff --git a/ChangeLog b/ChangeLog index 6eff74b..5e7b1c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-04-07 Jürg Billeter + * vala/valasymbolresolver.vala: reset takes_ownership and + transfers_ownership for base types of pointer types + + * tests/pointers.vala: test element access for methods returning + pointers + +2008-04-07 Jürg Billeter + * vala/valasemanticanalyzer.vala: don't compare base_method and base_interface_method in visit_class as this might not be set yet in other classes; available methods will already be checked in diff --git a/tests/pointers.vala b/tests/pointers.vala index 3b1e49d..2225487 100644 --- a/tests/pointers.vala +++ b/tests/pointers.vala @@ -14,6 +14,7 @@ struct SimpleStruct { delete st; test_pointers_element_access (); + test_pointers_return_value (); } static void test_pointers_element_access () { @@ -22,5 +23,16 @@ struct SimpleStruct { assert (array[0] == 23); delete array; } + + const int[] array = { 42 }; + + static int* return_pointer () { + return array; + } + + static void test_pointers_return_value () { + int i = return_pointer ()[0]; + assert (i == 42); + } } diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala index 34566ad..6be4fa2 100644 --- a/vala/valasymbolresolver.vala +++ b/vala/valasymbolresolver.vala @@ -276,7 +276,13 @@ public class Vala.SymbolResolver : CodeVisitor { } for (int pointer_level = unresolved_type.pointer_level; pointer_level > 0; pointer_level--) { - type = new PointerType (type); + var base_type = type; + base_type.takes_ownership = false; + base_type.transfers_ownership = false; + base_type.is_ref = false; + base_type.is_out = false; + + type = new PointerType (base_type); } if (!type.is_reference_type_or_type_parameter ()) {