]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 66273] Double-colon targets must not be intermediate
authorDmitry Goncharov <dgoncharov@users.sf.net>
Wed, 2 Oct 2024 02:27:25 +0000 (22:27 -0400)
committerPaul Smith <psmith@gnu.org>
Wed, 2 Oct 2024 02:27:25 +0000 (22:27 -0400)
An explicitly mentioned double-colon target cannot be intermediate.

* src/read.c (record_files): Set file->is_explicit in the case of an
explicitly mentioned file built by a double colon rule.
* src/file.c (print_file): Have print_file print whether a file is
explicitly mentioned.
* tests/scripts/features/patternrules: Add tests.

src/file.c
src/read.c
tests/scripts/features/patternrules

index 6056bb5689a645eb48bdef837efe8c031a0a7d38..6f816c8adf04ad8ebf12237d0e96bf4a11908855 100644 (file)
@@ -1129,6 +1129,9 @@ print_file (const void *item)
     puts (_("#  File is a prerequisite of .NOTINTERMEDIATE."));
   if (f->secondary)
     puts (_("#  File is secondary (prerequisite of .SECONDARY)."));
+  if (f->is_explicit)
+    puts (_("#  File is explicitly mentioned."));
+
   if (f->also_make != 0)
     {
       const struct dep *d;
index f9b0dd7549dc9c224305071d8fa998b0dbad43ca..2e30ce176fceb593da919eb9efa8d3d07d2d39e8 100644 (file)
@@ -2176,11 +2176,6 @@ record_files (struct nameseq *filenames, int are_also_makes,
               free_dep_chain (f->deps);
               f->deps = 0;
             }
-          /* This file is explicitly mentioned as a target.  There is no need
-             to set is_explicit in the case of double colon below, because an
-             implicit double colon rule only applies when the prerequisite
-             exists. A prerequisite which exists is not intermediate anyway. */
-          f->is_explicit = 1;
         }
       else
         {
@@ -2205,6 +2200,8 @@ record_files (struct nameseq *filenames, int are_also_makes,
 
           f->cmds = cmds;
         }
+      /* This file is explicitly mentioned as a target.  */
+      f->is_explicit = 1;
 
       if (are_also_makes)
         {
index 24d9cfc04a16441c22ed5674d09c2241a9ac30e7..158a3ff2aa535defd64520a470be5719bf708b25 100644 (file)
@@ -693,5 +693,16 @@ chmod(0754, 'b');
 unlink('b/hello.q');
 rmdir('b');
 
+# SV 66273. An explicitly mentioned prerequisite is not intermediate, even in
+# the case of double colon.
+unlink('hello.q', 'hello.x');
+run_make_test(q!
+all: hello.x
+%.x: %.q; $(info $@ from $<)
+hello.q::; touch $@
+!,
+              '', "touch hello.q\nhello.x from hello.q\n");
+unlink('hello.q');
+
 # This tells the test driver that the perl test script executed properly.
 1;