]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use detroy_value() for delete statement
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 12 Jul 2021 05:43:32 +0000 (07:43 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 22 Jul 2021 08:59:40 +0000 (10:59 +0200)
It is required to deal with special free functions here.

Fixes https://gitlab.gnome.org/GNOME/vala/issues/1201

codegen/valaccodebasemodule.vala
tests/pointers/delete.vala

index eea30654cfd09fff823dfec58f40312ec48fd8bb..0e14461ab0f6169a4ff16af9b64efbf93b9d4fd7 100644 (file)
@@ -4257,9 +4257,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) {
index f19dd859fe8774f1aa238db8ade29a493e628e49..56565b4bac8d3090909d14c84776dcbd19fb938b 100644 (file)
@@ -13,4 +13,9 @@ void main () {
                Bar* bar = new Bar ();
                delete bar;
        }
+       {
+               StringBuilder* foo = new StringBuilder ();
+               foo->append ("foo");
+               delete foo;
+       }
 }