From 42b4958acabe8645736c2d7614ebd55fbf95952d Mon Sep 17 00:00:00 2001 From: Norbert Thiebaud Date: Wed, 10 Aug 2011 12:37:14 -0500 Subject: support for the options --warn-undefined-functions --warn-undefined-variables do warn in case of attempt to call an undefined user function, but there can be a lot of legitimate undefined variables, so the useful warnings get lost in the crowd on the other hand calling an undefined user function is rarely legitimate and can easily be silenced. this patch add the support for a new options --warn-undefined-functions that produce a warning when $(call is invoked on an undefined variable. --- make-3.82-gbuild/function.c | 6 ++++-- make-3.82-gbuild/main.c | 9 +++++++++ make-3.82-gbuild/make.h | 2 +- make-3.82-gbuild/variable.h | 7 +++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/make-3.82-gbuild/function.c b/make-3.82-gbuild/function.c index e2f6c8c9..ff0527f6 100644 --- a/make-3.82-gbuild/function.c +++ b/make-3.82-gbuild/function.c @@ -2333,8 +2333,10 @@ func_call (char *o, char **argv, const char *funcname UNUSED) v = lookup_variable (fname, flen); if (v == 0) - warn_undefined (fname, flen); - + { + warn_undefined (fname, flen); + warn_undefined_function (fname, flen); + } if (v == 0 || *v->value == '\0') return o; diff --git a/make-3.82-gbuild/main.c b/make-3.82-gbuild/main.c index c6989e31..2f545a7e 100644 --- a/make-3.82-gbuild/main.c +++ b/make-3.82-gbuild/main.c @@ -275,6 +275,11 @@ static int print_usage_flag = 0; int warn_undefined_variables_flag; +/* If nonzero, we should print a warning message + for each attemtp to call an undefined user function. */ + +int warn_undefined_functions_flag; + /* If nonzero, always build all targets, regardless of whether they appear out of date or not. */ @@ -368,6 +373,8 @@ static const char *const usage[] = Consider FILE to be infinitely new.\n"), N_("\ --warn-undefined-variables Warn when an undefined variable is referenced.\n"), + N_("\ + --warn-undefined-functions Warn when an undefined user function is called.\n"), NULL }; @@ -424,6 +431,8 @@ static const struct command_switch switches[] = { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0, "warn-undefined-variables" }, { CHAR_MAX+6, string, &eval_strings, 1, 0, 0, 0, 0, "eval" }, + { CHAR_MAX+7, flag, &warn_undefined_functions_flag, 1, 1, 0, 0, 0, + "warn-undefined-functions" }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; diff --git a/make-3.82-gbuild/make.h b/make-3.82-gbuild/make.h index 60ade4c1..f2ebb56f 100644 --- a/make-3.82-gbuild/make.h +++ b/make-3.82-gbuild/make.h @@ -513,7 +513,7 @@ extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag; extern int print_version_flag, print_directory_flag, check_symlink_flag; extern int warn_undefined_variables_flag, posix_pedantic, not_parallel; extern int second_expansion, clock_skew_detected, rebuilding_makefiles; -extern int one_shell; +extern int one_shell, warn_undefined_functions_flag; /* can we run commands via 'sh -c xxx' or must we use batch files? */ extern int batch_mode_shell; diff --git a/make-3.82-gbuild/variable.h b/make-3.82-gbuild/variable.h index c2158672..02713c1f 100644 --- a/make-3.82-gbuild/variable.h +++ b/make-3.82-gbuild/variable.h @@ -220,6 +220,13 @@ void undefine_variable_in_set (const char *name, unsigned int length, (int)(l), (n)); \ }while(0) +#define warn_undefined_function(n,l) do{\ + if (warn_undefined_functions_flag) \ + error (reading_file, \ + _("warning: undefined function `%.*s'"), \ + (int)(l), (n)); \ + }while(0) + char **target_environment (struct file *file); struct pattern_var *create_pattern_var (const char *target, -- cgit v1.2.3