]> 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>
Wed, 28 Apr 2021 06:47:57 +0000 (08:47 +0200)
codegen/valagtypemodule.vala
tests/objects/destructors.vala

index ca9d63e7c5f2e891b774804a2cedc7d1ecc8f9a5..7ab1b2d84b729a41cede09e04d58bc69766bdd28 100644 (file)
@@ -1706,6 +1706,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 ();
@@ -1729,6 +1739,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 () {