]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add missing "_return" label and "_inner_error*_" declaration in dtors
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 24 Apr 2021 07:11:27 +0000 (09:11 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 24 Apr 2021 07:14:54 +0000 (09:14 +0200)
codegen/valagtypemodule.vala
tests/objects/destructors.vala

index 138201008fa0a5ce12be0b76f524373ee0cb2501..6ec1f6b6d9a6ba0a31a52b507a77c07bed83ef4c 100644 (file)
@@ -1703,6 +1703,16 @@ public class Vala.GTypeModule : GErrorModule {
 
                if (cl.static_destructor != null) {
                        cl.static_destructor.body.emit (this);
+
+                       if (current_method_inner_error) {
+                               ccode.add_declaration ("GError*", new CCodeVariableDeclarator.zero ("_inner_error%d_".printf (current_inner_error_id), new CCodeConstant ("NULL")));
+                       }
+
+                       if (current_method_return) {
+                               // support return statements in destructors
+                               ccode.add_label ("_return");
+                               ccode.add_statement (new CCodeEmptyStatement ());
+                       }
                }
 
                pop_context ();
@@ -1726,6 +1736,16 @@ public class Vala.GTypeModule : GErrorModule {
 
                if (cl.class_destructor != null) {
                        cl.class_destructor.body.emit (this);
+
+                       if (current_method_inner_error) {
+                               ccode.add_declaration ("GError*", new CCodeVariableDeclarator.zero ("_inner_error%d_".printf (current_inner_error_id), new CCodeConstant ("NULL")));
+                       }
+
+                       if (current_method_return) {
+                               // support return statements in destructors
+                               ccode.add_label ("_return");
+                               ccode.add_statement (new CCodeEmptyStatement ());
+                       }
                }
 
                pop_context ();
index 7a99f83fd1746da076bc8dfbde78ed367e5f0445..3745b3ccad1be67559856fb1be23710097afaa41 100644 (file)
@@ -34,6 +34,14 @@ class Manam : Object {
                }
                assert_not_reached ();
        }
+
+       class ~Manam () {
+               bool b = true;
+               if (b) {
+                       return;
+               }
+               assert_not_reached ();
+       }
 }
 
 void main () {