This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Print -imacros and -include'd headers if print_deps
- To: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Subject: [PATCH] Print -imacros and -include'd headers if print_deps
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Tue, 23 Jan 2001 18:39:34 +0100
- Cc: gcc-patches at gcc dot gnu dot org
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
Hi!
Both egcs 1.1.2 and gcc-2.95.2 include files mentioned in -imacros and
-include during -M, -MM, -MD and -MMD among dependencies.
I think it would be good if cpplib and tradcpp kept this behaviour
(currently they print only includes invoked through #include
directives), e.g. Mozilla gets bitten on this.
Here is a patch to make that happen, ok to commit?
2001-01-23 Jakub Jelinek <jakub@redhat.com>
* cpphash.h (_cpp_read_file): Add 3rd argument.
* cppfiles.c (_cpp_read_file): If deps is true and -M*, add
-imacros or -include'd dependencies.
* cppinit.c (do_includes, cpp_start_read): Adjust callers.
* tradcpp.c (main): Add -imacros or -include'd dependencies
for -M*.
--- gcc/cppfiles.c.jj Wed Jan 17 13:35:52 2001
+++ gcc/cppfiles.c Tue Jan 23 19:17:53 2001
@@ -748,9 +748,10 @@ _cpp_compare_file_date (pfile, f)
/* Push an input buffer and load it up with the contents of FNAME.
If FNAME is "" or NULL, read standard input. */
int
-_cpp_read_file (pfile, fname)
+_cpp_read_file (pfile, fname, deps)
cpp_reader *pfile;
const char *fname;
+ int deps;
{
struct include_file *f;
@@ -764,6 +765,9 @@ _cpp_read_file (pfile, fname)
cpp_error_from_errno (pfile, fname);
return 0;
}
+
+ if (CPP_OPTION (pfile, print_deps) && deps)
+ deps_add_dep (pfile->deps, f->name);
stack_include_file (pfile, f);
return 1;
--- gcc/cpphash.h.jj Wed Jan 17 13:35:52 2001
+++ gcc/cpphash.h Tue Jan 23 19:16:10 2001
@@ -403,7 +403,7 @@ extern cpp_hashnode *_cpp_lookup_with_ha
extern void _cpp_fake_include PARAMS ((cpp_reader *, const char *));
extern void _cpp_never_reread PARAMS ((struct include_file *));
extern void _cpp_simplify_pathname PARAMS ((char *));
-extern int _cpp_read_file PARAMS ((cpp_reader *, const char *));
+extern int _cpp_read_file PARAMS ((cpp_reader *, const char *, int));
extern void _cpp_execute_include PARAMS ((cpp_reader *,
const cpp_token *, int, int));
extern int _cpp_compare_file_date PARAMS ((cpp_reader *,
--- gcc/cppinit.c.jj Mon Jan 22 13:58:05 2001
+++ gcc/cppinit.c Tue Jan 23 19:16:32 2001
@@ -861,7 +861,7 @@ do_includes (pfile, p, scan)
use the #include "" search path if cpp_read_file fails. */
if (CPP_OPTION (pfile, preprocessed))
cpp_error (pfile, "-include and -imacros cannot be used with -fpreprocessed");
- else if (_cpp_read_file (pfile, p->arg) && scan)
+ else if (_cpp_read_file (pfile, p->arg, 1) && scan)
cpp_scan_buffer_nooutput (pfile, 0);
q = p->next;
free (p);
@@ -921,7 +921,7 @@ cpp_start_read (pfile, fname)
/* Open the main input file. This must be done early, so we have a
buffer to stand on. */
- if (!_cpp_read_file (pfile, fname))
+ if (!_cpp_read_file (pfile, fname, 0))
return 0;
/* If already preprocessed, don't install __LINE__, etc., and ignore
--- gcc/tradcpp.c.jj Fri Jan 12 11:35:40 2001
+++ gcc/tradcpp.c Tue Jan 23 19:25:08 2001
@@ -848,6 +848,11 @@ main (argc, argv)
perror_with_name (pend[i].arg);
return FATAL_EXIT_CODE;
}
+
+ /* For -M, add this file to the dependencies. */
+ if (print_deps)
+ deps_add_dep (deps, pend[i].arg);
+
finclude (fd, pend[i].arg, &outbuf);
}
indepth--;
Jakub