Blob Blame History Raw
diff -Nrup a/main.c b/main.c
--- a/main.c	2017-06-11 10:01:27.874528811 -0400
+++ b/main.c	2017-06-11 10:08:13.235058577 -0400
@@ -310,6 +310,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.  */
 
@@ -408,6 +413,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
   };
 
@@ -471,6 +478,8 @@ static const struct command_switch switc
       "warn-undefined-variables" },
     { CHAR_MAX+6, strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
     { CHAR_MAX+7, string, &sync_mutex, 1, 1, 0, 0, 0, "sync-mutex" },
+    { CHAR_MAX+8, flag, &warn_undefined_functions_flag, 1, 1, 0, 0, 0,
+      "warn-undefined-functions" },
     { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
   };
 
diff -Nrup a/makeint.h b/makeint.h
--- a/makeint.h	2017-06-11 10:01:27.875528807 -0400
+++ b/makeint.h	2017-06-11 10:09:13.231845428 -0400
@@ -647,7 +647,7 @@ extern int env_overrides, no_builtin_rul
 extern int print_version_flag, print_directory_flag, check_symlink_flag;
 extern int warn_undefined_variables_flag, trace_flag, posix_pedantic;
 extern int not_parallel, second_expansion, clock_skew_detected;
-extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
+extern int rebuilding_makefiles, one_shell, output_sync, verify_flag, warn_undefined_functions_flag;
 
 extern const char *default_shell;
 
diff -Nrup a/variable.h b/variable.h
--- a/variable.h	2016-05-21 16:22:32.000000000 -0400
+++ b/variable.h	2017-06-11 10:10:40.957533767 -0400
@@ -225,6 +225,15 @@ void undefine_variable_in_set (const cha
                                        (int)(l), (n));                  \
                               }while(0)
 
+/* Warn that NAME is an undefined function.  */
+
+#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,