[vala/0.50] codegen: Use detroy_value() for delete statement



commit 3184c48f1e5132edf6ff6015f81b4a57df88d1c8
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 eea30654c..0e14461ab 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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) {
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]