[vala/wip/effectfree: 12/39] 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: 12/39] codegen: Use temporary variables when accessing a variable
- Date: Fri, 1 Jul 2011 07:50:44 +0000 (UTC)
commit 323c31021682ee533fc4d2daeb63cabbe58f5fab
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 443992f..c00ec8b 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -698,6 +698,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 9819401..c1764a2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,6 +52,7 @@ TESTS = \
structs/structs.vala \
structs/gvalue.vala \
structs/bug530605.vala \
+ structs/bug572091.vala \
structs/bug583603.vala \
structs/bug595587.vala \
structs/bug606202.vala \
@@ -88,6 +89,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]