summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2011-08-10 17:37:14 (GMT)
committerNorbert Thiebaud <nthiebaud@gmail.com>2011-08-10 17:37:14 (GMT)
commit42b4958acabe8645736c2d7614ebd55fbf95952d (patch)
tree8216c1de26cb982b9279f0650839091710764d8b
parentf9dc7f95ff0b87470189b3230c20de1efcdef1ab (diff)
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.
-rw-r--r--make-3.82-gbuild/function.c6
-rw-r--r--make-3.82-gbuild/main.c9
-rw-r--r--make-3.82-gbuild/make.h2
-rw-r--r--make-3.82-gbuild/variable.h7
4 files changed, 21 insertions, 3 deletions
diff --git a/make-3.82-gbuild/function.c b/make-3.82-gbuild/function.c
index e2f6c8c..ff0527f 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 c6989e3..2f545a7 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 60ade4c..f2ebb56 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 c215867..02713c1 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,