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



commit 7fcad9df769d2b88335fa2f8537e12bcce36be71
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 08e69eccc..007e71c0b 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4303,9 +4303,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]