[vala/0.40] codegen: Assign GValue result of function calls to temp-var on copy_value
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] codegen: Assign GValue result of function calls to temp-var on copy_value
- Date: Mon, 5 Aug 2019 11:40:01 +0000 (UTC)
commit f37d10cf75cde30674a3d3b2d9f3000a884bbeab
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Jul 5 16:54:19 2019 +0200
codegen: Assign GValue result of function calls to temp-var on copy_value
Regression of a94a28141e1f222d1da7e72bea4cd2d1e5242f41
Fixes https://gitlab.gnome.org/GNOME/vala/issues/819
codegen/valaccodebasemodule.vala | 7 ++++++-
tests/Makefile.am | 1 +
tests/methods/varargs-gvalue.vala | 15 +++++++++++++++
3 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0a71fb1fc..1f78deb2b 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4334,6 +4334,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (type is ValueType && !type.nullable) {
// normal value type, no null check
+ // use temp-var for upcoming address-of operator
+ var temp_cvalue = create_temp_value (type, false, node);
+ store_value (temp_cvalue, value, node.source_reference);
+ cexpr = get_cvalue_ (temp_cvalue);
+
var temp_value = create_temp_value (type, true, node, true);
var ctemp = get_cvalue_ (temp_value);
@@ -4366,7 +4371,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_else ();
// g_value_init/copy must not be called for uninitialized values
- store_value (temp_value, value, node.source_reference);
+ store_value (temp_value, temp_cvalue, node.source_reference);
ccode.close ();
} else {
ccode.add_expression (copy_call);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 629931b9b..2860cc213 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -136,6 +136,7 @@ TESTS = \
methods/printf-invalid.test \
methods/printf-constructor.vala \
methods/printf-constructor-invalid.test \
+ methods/varargs-gvalue.vala \
methods/varargs-out.vala \
control-flow/assigned-local-variable.vala \
control-flow/break.vala \
diff --git a/tests/methods/varargs-gvalue.vala b/tests/methods/varargs-gvalue.vala
new file mode 100644
index 000000000..3160b2356
--- /dev/null
+++ b/tests/methods/varargs-gvalue.vala
@@ -0,0 +1,15 @@
+void foo (int first_arg, ...) {
+ var args = va_list ();
+ Value val = args.arg ();
+
+ assert (first_arg == 42);
+ assert (val.holds (typeof (string)));
+ assert (val.get_string () == "foo");
+}
+
+void main () {
+ Value val = Value (typeof (string));
+ val.set_string ("foo");
+
+ foo (42, val);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]