[SV 66273] Double-colon targets must not be intermediate

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.
This commit is contained in:
Dmitry Goncharov 2024-10-01 22:27:25 -04:00 committed by Paul Smith
parent 93704dd565
commit aa8626ce09
3 changed files with 16 additions and 5 deletions

View 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;

View 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)
{

View 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;