From: Rico Tzschichholz Date: Sat, 23 Feb 2019 19:19:31 +0000 (+0100) Subject: codegen: Only emit declaration of *_register_type if needed X-Git-Tag: 0.43.92~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d7b6a1e59dc330b2bdcf0ff8ff38a85adda8edc;p=thirdparty%2Fvala.git codegen: Only emit declaration of *_register_type if needed This allows to add a test case for ModuleInit with -Werror=redundant-decls --- diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 4adf1f4b3..bc7a3b2a1 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -289,10 +289,13 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } // Add function prototypes for required register-type-calls which are likely external - var register_func = new CCodeFunction ("%s_register_type".printf (get_ccode_lower_case_name (type_symbol, null)), "GType"); - register_func.add_parameter (new CCodeParameter ("module", "GTypeModule *")); - register_func.is_declaration = true; - cfile.add_function_declaration (register_func); + if (type_symbol.source_reference.file != cfile.file) { + // TODO Duplicated source with TypeRegisterFunction.init_from_type() + var register_func = new CCodeFunction ("%s_register_type".printf (get_ccode_lower_case_name (type_symbol, null)), "GType"); + register_func.add_parameter (new CCodeParameter ("module", "GTypeModule *")); + register_func.is_declaration = true; + cfile.add_function_declaration (register_func); + } var register_call = new CCodeFunctionCall (new CCodeIdentifier ("%s_register_type".printf (get_ccode_lower_case_name (type_symbol, null)))); register_call.add_argument (new CCodeIdentifier (module_init_param_name));