Blame SOURCES/make-4.2-warn_undefined_function.patch

f36cf9
diff -Nrup a/main.c b/main.c
f36cf9
--- a/main.c	2017-06-11 10:01:27.874528811 -0400
f36cf9
+++ b/main.c	2017-06-11 10:08:13.235058577 -0400
f36cf9
@@ -310,6 +310,11 @@ static int print_usage_flag = 0;
f36cf9
 
f36cf9
 int warn_undefined_variables_flag;
f36cf9
 
f36cf9
+/* If nonzero, we should print a warning message
f36cf9
+   for each attemtp to call an undefined user function.  */
f36cf9
+
f36cf9
+int warn_undefined_functions_flag;
f36cf9
+
f36cf9
 /* If nonzero, always build all targets, regardless of whether
f36cf9
    they appear out of date or not.  */
f36cf9
 
f36cf9
@@ -408,6 +413,8 @@ static const char *const usage[] =
f36cf9
                               Consider FILE to be infinitely new.\n"),
f36cf9
     N_("\
f36cf9
   --warn-undefined-variables  Warn when an undefined variable is referenced.\n"),
f36cf9
+    N_("\
f36cf9
+  --warn-undefined-functions  Warn when an undefined user function is called.\n"),
f36cf9
     NULL
f36cf9
   };
f36cf9
 
f36cf9
@@ -471,6 +478,8 @@ static const struct command_switch switc
f36cf9
       "warn-undefined-variables" },
f36cf9
     { CHAR_MAX+6, strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
f36cf9
     { CHAR_MAX+7, string, &sync_mutex, 1, 1, 0, 0, 0, "sync-mutex" },
f36cf9
+    { CHAR_MAX+8, flag, &warn_undefined_functions_flag, 1, 1, 0, 0, 0,
f36cf9
+      "warn-undefined-functions" },
f36cf9
     { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
f36cf9
   };
f36cf9
 
f36cf9
diff -Nrup a/makeint.h b/makeint.h
f36cf9
--- a/makeint.h	2017-06-11 10:01:27.875528807 -0400
f36cf9
+++ b/makeint.h	2017-06-11 10:09:13.231845428 -0400
f36cf9
@@ -647,7 +647,7 @@ extern int env_overrides, no_builtin_rul
f36cf9
 extern int print_version_flag, print_directory_flag, check_symlink_flag;
f36cf9
 extern int warn_undefined_variables_flag, trace_flag, posix_pedantic;
f36cf9
 extern int not_parallel, second_expansion, clock_skew_detected;
f36cf9
-extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
f36cf9
+extern int rebuilding_makefiles, one_shell, output_sync, verify_flag, warn_undefined_functions_flag;
f36cf9
 
f36cf9
 extern const char *default_shell;
f36cf9
 
f36cf9
diff -Nrup a/variable.h b/variable.h
f36cf9
--- a/variable.h	2016-05-21 16:22:32.000000000 -0400
f36cf9
+++ b/variable.h	2017-06-11 10:10:40.957533767 -0400
f36cf9
@@ -225,6 +225,15 @@ void undefine_variable_in_set (const cha
f36cf9
                                        (int)(l), (n));                  \
f36cf9
                               }while(0)
f36cf9
 
f36cf9
+/* Warn that NAME is an undefined function.  */
f36cf9
+
f36cf9
+#define warn_undefined_function(n,l) do{\
f36cf9
+                              if (warn_undefined_functions_flag) \
f36cf9
+                                error (reading_file, \
f36cf9
+                                       _("warning: undefined function `%.*s'"), \
f36cf9
+                                (int)(l), (n)); \
f36cf9
+                              }while(0)
f36cf9
+
f36cf9
 char **target_environment (struct file *file);
f36cf9
 
f36cf9
 struct pattern_var *create_pattern_var (const char *target,