From 5f2fc64498ac413143e989aa70ad46f3425fc6a0 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Wed, 22 Aug 2012 12:37:06 +0200 Subject: [PATCH] -Wimplicit-function-pointer, functions without bodies still have a global function variable and thus are function pointers, though this shouldn't really be used, thus -Wimplicit-function-pointer is on by default --- ir.c | 2 ++ main.c | 1 + warns.def | 1 + 3 files changed, 4 insertions(+) diff --git a/ir.c b/ir.c index 074ed7f..df2e32f 100644 --- a/ir.c +++ b/ir.c @@ -2599,6 +2599,8 @@ static bool gen_global_function_code(ir_builder *ir, ir_value *global) irfun = global->constval.vfunc; if (!irfun) { + irwarning(global->context, WARN_IMPLICIT_FUNCTION_POINTER, + "function `%s` has no body and in QC implicitly becomes a function-pointer", global->name); /* this was a function pointer, don't generate code for those */ return true; } diff --git a/main.c b/main.c index 64d6f03..13fa575 100644 --- a/main.c +++ b/main.c @@ -385,6 +385,7 @@ int main(int argc, char **argv) { options_set(opts_warn, WARN_USED_UNINITIALIZED, true); options_set(opts_warn, WARN_LOCAL_CONSTANTS, true); options_set(opts_warn, WARN_VOID_VARIABLES, true); + options_set(opts_warn, WARN_IMPLICIT_FUNCTION_POINTER, true); if (!options_parse(argc, argv)) { return usage(); diff --git a/warns.def b/warns.def index b8609a6..16a5f99 100644 --- a/warns.def +++ b/warns.def @@ -13,3 +13,4 @@ GMQCC_DEFINE_FLAG(TOO_FEW_PARAMETERS) GMQCC_DEFINE_FLAG(LOCAL_SHADOWS) GMQCC_DEFINE_FLAG(LOCAL_CONSTANTS) GMQCC_DEFINE_FLAG(VOID_VARIABLES) +GMQCC_DEFINE_FLAG(IMPLICIT_FUNCTION_POINTER) -- 2.39.2