]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 62650] Show correct warning when combining targets
authorDmitry Goncharov <dgoncharov@users.sf.net>
Sun, 19 Jun 2022 17:44:09 +0000 (13:44 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 9 Jul 2022 14:44:00 +0000 (10:44 -0400)
* src/file.c (rehash_file): Fix warning message.
(rehash_file): Fix comment to match the behavior.
* tests/scripts/features/se_explicit: Fix test.
* tests/scripts/features/mult_rules: Add a new test.

src/file.c
tests/scripts/features/mult_rules
tests/scripts/features/se_explicit

index 6862397ac4c8867a96ea72a811bf14c6e9c9918c..ab46c4a18dda68b43b3ebf92f0a87e15f13c1a98 100644 (file)
@@ -273,14 +273,14 @@ rehash_file (struct file *from_file, const char *to_hname)
         {
           size_t l = strlen (from_file->name);
           /* We have two sets of commands.  We will go with the
-             one given in the rule explicitly mentioning this name,
+             one given in the rule found through directory search,
              but give a message to let the user know what's going on.  */
           if (to_file->cmds->fileinfo.filenm != 0)
             error (&from_file->cmds->fileinfo,
                    l + strlen (to_file->cmds->fileinfo.filenm) + INTSTR_LENGTH,
                    _("Recipe was specified for file '%s' at %s:%lu,"),
-                   from_file->name, to_file->cmds->fileinfo.filenm,
-                   to_file->cmds->fileinfo.lineno);
+                   from_file->name, from_file->cmds->fileinfo.filenm,
+                   from_file->cmds->fileinfo.lineno);
           else
             error (&from_file->cmds->fileinfo, l,
                    _("Recipe for file '%s' was found by implicit rule search,"),
@@ -291,7 +291,7 @@ rehash_file (struct file *from_file, const char *to_hname)
                  from_file->name, to_hname);
           error (&from_file->cmds->fileinfo, l,
                  _("Recipe for '%s' will be ignored in favor of the one for '%s'."),
-                 to_hname, from_file->name);
+                 from_file->name, to_hname);
         }
     }
 
index e706e17d102117a0692cc34be9ad0c860ecd4e4c..bddd501c6a0b14ca28ddffd6e88168ad3b718bce 100644 (file)
@@ -69,10 +69,20 @@ $answer = "EXTRA EXTRA\n";
 
 unlink("defs.h","test.h","config.h","extra.h");
 
-1;
-
-
-
-
-
+# sv 62650.
+# Test the message that make prints when a file found by directory search
+# is preferred over the local one.
+run_make_test(q!
+vpath hello.c src
+all: hello.c; $(info $@ from $^)
+hello.c: ; $(info 1 $@)
+src/hello.c: ; $(info 2 $@)
+!, '',
+    "#MAKEFILE#:4: Recipe was specified for file 'hello.c' at #MAKEFILE#:4,
+#MAKEFILE#:4: but 'hello.c' is now considered the same file as 'src/hello.c'.
+#MAKEFILE#:4: Recipe for 'hello.c' will be ignored in favor of the one for 'src/hello.c'.
+2 src/hello.c
+all from src/hello.c
+#MAKE#: 'all' is up to date.\n");
 
+1;
index d097e1a88c063536ea564d3390b1a85982bbd43c..354182747c3ab36810dd1643370ea5d70dcee4ee 100644 (file)
@@ -185,9 +185,9 @@ foo: $$@.o ;
 # Not creating libcat.a here prevents segfault,
 libcat.a: ; @touch $@
 !,
-              '', q!#MAKEFILE#:16: Recipe was specified for file '-lcat' at #MAKEFILE#:19,
+              '', q!#MAKEFILE#:16: Recipe was specified for file '-lcat' at #MAKEFILE#:16,
 #MAKEFILE#:16: but '-lcat' is now considered the same file as 'libcat.a'.
-#MAKEFILE#:16: Recipe for 'libcat.a' will be ignored in favor of the one for '-lcat'.!);
+#MAKEFILE#:16: Recipe for '-lcat' will be ignored in favor of the one for 'libcat.a'.!);
 unlink('libcat.a');
 
 # SV 28456 : Don't reset $$< for default recipes