Fixed Savannah bugs #13216 and #13218.
authorBoris Kolpackov <boris@kolpackov.net>
Tue, 31 May 2005 20:54:30 +0000 (20:54 +0000)
committerBoris Kolpackov <boris@kolpackov.net>
Tue, 31 May 2005 20:54:30 +0000 (20:54 +0000)
ChangeLog
implicit.c
job.c
tests/ChangeLog
tests/scripts/features/include
tests/scripts/features/patternrules

index 5bd7bea5611cefc6275d10f197ea3985b6fcd2dd..318cbd76558232de0676fb27039fd45ff61f501d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-05-31  Boris Kolpackov  <boris@kolpackov.net>
+
+       * job.c (reap_children): Don't die of the command failed but
+       the dontcare flag is set. Fixes Savannah bug #13216.
+
+       * implicit.c (pattern_search): When creating a target from
+       an implicit rule match, lookup pattern target and set precious
+       flag in a newly created target. Fixes Savannah bug #13218.
+
 2005-05-13  Paul D. Smith  <psmith@gnu.org>
 
        Implement "if... else if... endif" syntax.
index 67f0559d7454c8cf41197b78fbb66ecf1ffb8789..cae4c40ca423e5d88e1cfaea52478426dac124cf 100644 (file)
@@ -899,6 +899,13 @@ pattern_search (struct file *file, int archive,
   file->cmds = rule->cmds;
   file->is_target = 1;
 
+  /* Set precious flag. */
+  {
+    struct file *f = lookup_file (rule->targets[matches[foundrule]]);
+    if (f && f->precious)
+      file->precious = 1;
+  }
+
   /* If this rule builds other targets, too, put the others into FILE's
      `also_make' member.  */
 
@@ -906,6 +913,7 @@ pattern_search (struct file *file, int archive,
     for (i = 0; rule->targets[i] != 0; ++i)
       if (i != matches[foundrule])
        {
+         struct file *f;
          struct dep *new = (struct dep *) xmalloc (sizeof (struct dep));
          /* GKM FIMXE: handle '|' here too */
          new->ignore_mtime = 0;
@@ -920,6 +928,12 @@ pattern_search (struct file *file, int archive,
                 rule->lens[i] - (rule->suffixes[i] - rule->targets[i]) + 1);
          new->file = enter_file (new->name);
          new->next = file->also_make;
+         
+         /* Set precious flag. */
+         f = lookup_file (rule->targets[i]);
+         if (f && f->precious)
+            new->file->precious = 1;
+         
          file->also_make = new;
        }
 
diff --git a/job.c b/job.c
index fbd78a0c741966f25a14fc7e322e483871b5a154..83494450c17358821491228cb132260bd77afeb6 100644 (file)
--- a/job.c
+++ b/job.c
@@ -470,6 +470,7 @@ reap_children (int block, int err)
       register struct child *lastc, *c;
       int child_failed;
       int any_remote, any_local;
+      int dontcare;
 
       if (err && block)
        {
@@ -686,12 +687,17 @@ reap_children (int block, int err)
       if (c->good_stdin)
         good_stdin_used = 0;
 
+      dontcare = c->file->dontcare;
+
       if (child_failed && !c->noerror && !ignore_errors_flag)
         {
           /* The commands failed.  Write an error message,
              delete non-precious targets, and abort.  */
           static int delete_on_error = -1;
-          child_error (c->file->name, exit_code, exit_sig, coredump, 0);
+
+          if (!dontcare)
+            child_error (c->file->name, exit_code, exit_sig, coredump, 0);
+
           c->file->update_status = 2;
           if (delete_on_error == -1)
             {
@@ -791,7 +797,7 @@ reap_children (int block, int err)
 
       /* If the job failed, and the -k flag was not given, die,
          unless we are already in the process of dying.  */
-      if (!err && child_failed && !keep_going_flag &&
+      if (!err && child_failed && !dontcare && !keep_going_flag &&
           /* fatal_error_signal will die with the right signal.  */
           !handling_fatal_signal)
         die (2);
index 914a67f98b89698ed13d666505989ca403169f4a..b33269c2f132ba19455cf23e32f5bf856cfed8a1 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-31  Boris Kolpackov  <boris@kolpackov.net>
+
+       * scripts/features/include: Add a test for Savannah bug #13216.
+       * scripts/features/patternrules: Add a test for Savannah bug #13218.
+
 2005-05-13  Paul D. Smith  <psmith@gnu.org>
 
        * scripts/features/conditionals: Add tests for the new if... else
index f48cbd3f421ce8f18ad1bf820934226261ae96d4..26ee1bdb2f2ffbc7644c002e4b1467e5d6ec4161 100644 (file)
@@ -78,6 +78,7 @@ hello: ; @echo hello
    "hello\n"
   );
 
+
 # Test inheritance of dontcare flag when rebuilding makefiles.
 #
 run_make_test('
@@ -90,3 +91,20 @@ foo: bar; @:
 ', '', '');
 
 1;
+
+
+# Make sure that we don't die when the command fails but we dontcare.
+# (Savannah bug #13216).
+#
+run_make_test('
+.PHONY: all
+all:; @:
+
+-include foo
+
+foo: bar; @:
+
+bar:; @false
+', '', '');
+
+1;
index ee29c4e7f14cbd0bc69deb9daf7b93ab90a5551f..0e2f2812a8d9cfc2640ea6e65a537c9765d7471c 100644 (file)
@@ -95,5 +95,25 @@ $dir/foo.o");
 
 unlink("$dir/foo.c");
 
+
+# TEST #4: make sure precious flag is set properly for targets
+#          that are built via implicit rules (Savannah bug #13218).
+#
+run_make_test('
+.DELETE_ON_ERROR:
+
+.PRECIOUS: %.bar
+
+%.bar:; @touch $@ && false
+
+$(dir)/foo.bar:
+
+',
+"dir=$dir",
+"make: *** [$dir/foo.bar] Error 1",
+512);
+
+unlink("$dir/foo.bar");
+
 # This tells the test driver that the perl test script executed properly.
 1;