[vala/staging] codegen: Use detroy_value() for delete statement
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Use detroy_value() for delete statement
- Date: Mon, 12 Jul 2021 05:54:12 +0000 (UTC)
commit 48ff64658b7a1107586d9f9634bc3e6d2f43b196
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Jul 12 07:43:32 2021 +0200
codegen: Use detroy_value() for delete statement
It is required to deal with special free functions here.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1201
codegen/valaccodebasemodule.vala | 4 +---
tests/pointers/delete.vala | 5 +++++
2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4b120dec9..43f89e80c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4358,9 +4358,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
type = pointer_type.base_type;
}
- var ccall = new CCodeFunctionCall (get_destroy_func_expression (type));
- ccall.add_argument (get_cvalue (stmt.expression));
- ccode.add_expression (ccall);
+ ccode.add_expression (destroy_value (new GLibValue (type, get_cvalue (stmt.expression))));
}
static bool is_compact_class_destructor_call (Expression expr) {
diff --git a/tests/pointers/delete.vala b/tests/pointers/delete.vala
index f19dd859f..56565b4ba 100644
--- a/tests/pointers/delete.vala
+++ b/tests/pointers/delete.vala
@@ -13,4 +13,9 @@ void main () {
Bar* bar = new Bar ();
delete bar;
}
+ {
+ StringBuilder* foo = new StringBuilder ();
+ foo->append ("foo");
+ delete foo;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]