}
}
- if (!(m.return_type is VoidType) && !m.return_type.is_real_non_null_struct_type () && !m.coroutine) {
- var vardecl = new CCodeVariableDeclarator ("result", default_value_for_type (m.return_type, true));
- vardecl.init0 = true;
- ccode.add_declaration (get_ccode_name (m.return_type), vardecl);
- }
-
if (m is CreationMethod) {
if (in_gobject_creation_method) {
if (!m.coroutine) {
complete_async ();
}
- if (!(m.return_type is VoidType) && !m.return_type.is_real_non_null_struct_type () && !m.coroutine) {
- // add dummy return if exit block is known to be unreachable to silence C compiler
- if (m.return_block != null && m.return_block.get_predecessors ().size == 0) {
- ccode.add_return (new CCodeIdentifier ("result"));
- }
- }
-
if (m is CreationMethod) {
if (current_type_symbol is Class) {
creturn_type = new ObjectType (current_class);
cfile.add_function (ccode);
}
+ if (current_method_return && !(m.return_type is VoidType) && !m.return_type.is_real_non_null_struct_type () && !m.coroutine) {
+ var vardecl = new CCodeVariableDeclarator ("result", default_value_for_type (m.return_type, true));
+ vardecl.init0 = true;
+ ccode.add_declaration (get_ccode_name (m.return_type), vardecl);
+ }
+
pop_context ();
if ((m.is_abstract || m.is_virtual) && !m.coroutine &&
}
ccode.add_expression (ccheck);
+
+ current_method_return = true;
}
public override void visit_creation_method (CreationMethod m) {