From: Dmitry Goncharov Date: Wed, 2 Oct 2024 02:27:25 +0000 (-0400) Subject: [SV 66273] Double-colon targets must not be intermediate X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=aa8626ce09317151f59490ebd5673afdedb3e1f2;p=thirdparty%2Fmake.git [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. --- diff --git a/src/file.c b/src/file.c index 6056bb56..6f816c8a 100644 --- a/src/file.c +++ b/src/file.c @@ -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; diff --git a/src/read.c b/src/read.c index f9b0dd75..2e30ce17 100644 --- a/src/read.c +++ b/src/read.c @@ -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) { diff --git a/tests/scripts/features/patternrules b/tests/scripts/features/patternrules index 24d9cfc0..158a3ff2 100644 --- a/tests/scripts/features/patternrules +++ b/tests/scripts/features/patternrules @@ -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;