diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-04-24 09:11:27 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-04-28 08:47:57 +0200 |
commit | 3399db491d83c3466853b33de4c2e219ea0326b4 (patch) | |
tree | 435779c7ff58ed9ae265c8c0519cf633174d323b | |
parent | 927bbda59a315ff2549268c29fbe57c280991964 (diff) | |
download | vala-3399db491d83c3466853b33de4c2e219ea0326b4.tar.gz |
codegen: Add missing "_return" label and "_inner_error*_" declaration in dtors
-rw-r--r-- | codegen/valagtypemodule.vala | 20 | ||||
-rw-r--r-- | tests/objects/destructors.vala | 8 |
2 files changed, 28 insertions, 0 deletions
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index ca9d63e7c..7ab1b2d84 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -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 (); diff --git a/tests/objects/destructors.vala b/tests/objects/destructors.vala index 7a99f83fd..3745b3cca 100644 --- a/tests/objects/destructors.vala +++ b/tests/objects/destructors.vala @@ -34,6 +34,14 @@ class Manam : Object { } assert_not_reached (); } + + class ~Manam () { + bool b = true; + if (b) { + return; + } + assert_not_reached (); + } } void main () { |