[vala/wip/effectfree: 17/44] codegen: Use temporary variables when accessing a variable
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/effectfree: 17/44] codegen: Use temporary variables when accessing a variable
- Date: Wed, 6 Jul 2011 21:12:29 +0000 (UTC)
commit fa176ad5db5fc13291f4ba4c8418170a9593dd69
Author: Luca Bruno <lucabru src gnome org>
Date: Wed Jun 15 13:27:21 2011 +0200
codegen: Use temporary variables when accessing a variable
Fixes bugs 626038 and 572091.
codegen/valaccodememberaccessmodule.vala | 5 +++++
tests/Makefile.am | 2 ++
tests/objects/bug626038.vala | 8 ++++++++
tests/structs/bug572091.vala | 13 +++++++++++++
4 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 2b594db..f3ea02e 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -699,6 +699,11 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.delegate_target_destroy_notify_cvalue = new CCodeConstant ("NULL");
}
result.value_type.value_owned = false;
+
+ if (!(variable is Parameter && variable.name == "this") && !(array_type != null && array_type.inline_allocated)) {
+ result = (GLibValue) store_temp_value (result, variable);
+ }
+
return result;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b9beaae..ccf1fa8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -54,6 +54,7 @@ TESTS = \
structs/structs.vala \
structs/gvalue.vala \
structs/bug530605.vala \
+ structs/bug572091.vala \
structs/bug583603.vala \
structs/bug595587.vala \
structs/bug606202.vala \
@@ -91,6 +92,7 @@ TESTS = \
objects/bug613840.vala \
objects/bug620706.vala \
objects/bug624594.vala \
+ objects/bug626038.vala \
objects/bug628639.vala \
objects/bug642809.vala \
objects/bug643711.vala \
diff --git a/tests/objects/bug626038.vala b/tests/objects/bug626038.vala
new file mode 100644
index 0000000..3c1f875
--- /dev/null
+++ b/tests/objects/bug626038.vala
@@ -0,0 +1,8 @@
+class Foo {
+ public Foo foo;
+}
+
+void main () {
+ var foo = new Foo ();
+ foo.foo = (owned) foo;
+}
diff --git a/tests/structs/bug572091.vala b/tests/structs/bug572091.vala
new file mode 100644
index 0000000..5fa3788
--- /dev/null
+++ b/tests/structs/bug572091.vala
@@ -0,0 +1,13 @@
+struct Foo {
+ public int bar;
+}
+
+void baz (Foo foo) {
+ foo.bar = 2;
+}
+
+void main() {
+ var foo = Foo () { bar = 1 };
+ baz (foo);
+ assert (foo.bar == 1);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]