[vala] Always set value_owned to false for pointers



commit 258045766f78ee1cff94c75f508ba683ebc47e7f
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed May 25 11:44:33 2011 +0200

    Always set value_owned to false for pointers
    
    Fixes bug 650993.

 tests/Makefile.am                |    1 +
 tests/basic-types/bug650993.vala |    7 +++++++
 vala/valaparser.vala             |    4 ++++
 3 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 013585e..422571e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -25,6 +25,7 @@ TESTS = \
 	basic-types/bug596637.vala \
 	basic-types/bug596785.vala \
 	basic-types/bug632322.vala \
+	basic-types/bug650993.vala \
 	namespaces.vala \
 	methods/lambda.vala \
 	methods/closures.vala \
diff --git a/tests/basic-types/bug650993.vala b/tests/basic-types/bug650993.vala
new file mode 100644
index 0000000..db47e9d
--- /dev/null
+++ b/tests/basic-types/bug650993.vala
@@ -0,0 +1,7 @@
+void *test () {
+	return null;
+}
+
+void main () {
+	unowned int[] o = (int[]) test();
+}
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 991b008..ad97da8 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -489,6 +489,10 @@ public class Vala.Parser : CodeVisitor {
 			}
 		}
 
+		if (type is PointerType) {
+			value_owned = false;
+		}
+
 		type.is_dynamic = is_dynamic;
 		type.value_owned = value_owned;
 		return type;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]