[vala/staging] codegen: Add missing "_return" label and "_inner_error*_" declaration in dtors
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Add missing "_return" label and "_inner_error*_" declaration in dtors
- Date: Sat, 24 Apr 2021 07:16:02 +0000 (UTC)
commit f6be4cbd7f901683a1e6f4f4a0070b1e87dcce65
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Apr 24 09:11:27 2021 +0200
codegen: Add missing "_return" label and "_inner_error*_" declaration in dtors
codegen/valagtypemodule.vala | 20 ++++++++++++++++++++
tests/objects/destructors.vala | 8 ++++++++
2 files changed, 28 insertions(+)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 138201008..6ec1f6b6d 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -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 ();
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 () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]