* main.c (die): Close output_context AND make_sync.
authorPaul Smith <psmith@gnu.org>
Sat, 11 Jan 2014 21:10:02 +0000 (16:10 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 12 Jan 2014 15:54:29 +0000 (10:54 -0500)
die() can be invoked inside a separate output_context, if the
$(error ...) function is expanded as part of a recipe.

main.c
tests/scripts/features/output-sync

diff --git a/main.c b/main.c
index fa0498f6643876368d08494b5a0b67f7015f1013..27d3a6eba955d4972123a249a3cf31f5e314b6aa 100644 (file)
--- a/main.c
+++ b/main.c
@@ -3406,9 +3406,14 @@ die (int status)
 
       if (output_context)
         {
-          assert (output_context == &make_sync);
+          /* die() might be called in a recipe output context due to an
+             $(error ...) function.  */
+          output_close (output_context);
+
+          if (output_context != &make_sync)
+            output_close (&make_sync);
+
           OUTPUT_UNSET ();
-          output_close (&make_sync);
         }
 
       output_close (NULL);
index 75d7e81defa2b80f7e1ef18e49667104ac0f6413..a7534cb7aaf03881fe7016b62c76cf01a766378c 100644 (file)
@@ -330,5 +330,12 @@ t1: ; -\@\$(MAKE) -f $m1
 
 rmfiles($m1);
 
+# Test $(error ...) functions in recipes
+
+run_make_test(q!
+foo: $(OBJS) ; echo $(or $(filter %.o,$^),$(error fail))
+!,
+              '-O', "#MAKEFILE#:2: *** fail.  Stop.\n", 512);
+
 # This tells the test driver that the perl test script executed properly.
 1;