Commit 42e2194b by Richard Kenner

(no_record_file): New variable.

(main): Set it for -imacros and -include files.
(do_endif): Don't call record_control_macro for -include or -imacros files or
files included from -imacros.

From-SVN: r6708
parent df716623
...@@ -467,6 +467,11 @@ int traditional; ...@@ -467,6 +467,11 @@ int traditional;
static int no_output; static int no_output;
/* Nonzero means this file was included with a -imacros or -include
command line and should not be recorded as an include file. */
static int no_record_file;
/* Nonzero means that we have finished processing the command line options. /* Nonzero means that we have finished processing the command line options.
This flag is used to decide whether or not to issue certain errors This flag is used to decide whether or not to issue certain errors
and/or warnings. */ and/or warnings. */
...@@ -1802,7 +1807,7 @@ main (argc, argv) ...@@ -1802,7 +1807,7 @@ main (argc, argv)
Much like #including them, but with no_output set Much like #including them, but with no_output set
so that only their macro definitions matter. */ so that only their macro definitions matter. */
no_output++; no_output++; no_record_file++;
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
if (pend_files[i]) { if (pend_files[i]) {
int fd = open (pend_files[i], O_RDONLY, 0666); int fd = open (pend_files[i], O_RDONLY, 0666);
...@@ -1812,7 +1817,7 @@ main (argc, argv) ...@@ -1812,7 +1817,7 @@ main (argc, argv)
} }
finclude (fd, pend_files[i], &outbuf, 0, NULL_PTR); finclude (fd, pend_files[i], &outbuf, 0, NULL_PTR);
} }
no_output--; no_output--; no_record_file--;
/* Copy the entire contents of the main input file into /* Copy the entire contents of the main input file into
the stacked input buffer previously allocated for it. */ the stacked input buffer previously allocated for it. */
...@@ -2002,6 +2007,7 @@ main (argc, argv) ...@@ -2002,6 +2007,7 @@ main (argc, argv)
/* Scan the -include files before the main input. */ /* Scan the -include files before the main input. */
no_record_file++;
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
if (pend_includes[i]) { if (pend_includes[i]) {
int fd = open (pend_includes[i], O_RDONLY, 0666); int fd = open (pend_includes[i], O_RDONLY, 0666);
...@@ -2011,6 +2017,7 @@ main (argc, argv) ...@@ -2011,6 +2017,7 @@ main (argc, argv)
} }
finclude (fd, pend_includes[i], &outbuf, 0, NULL_PTR); finclude (fd, pend_includes[i], &outbuf, 0, NULL_PTR);
} }
no_record_file--;
/* Scan the input, processing macros and directives. */ /* Scan the input, processing macros and directives. */
...@@ -7055,8 +7062,13 @@ do_endif (buf, limit, op, keyword) ...@@ -7055,8 +7062,13 @@ do_endif (buf, limit, op, keyword)
/* If we get here, this #endif ends a #ifndef /* If we get here, this #endif ends a #ifndef
that contains all of the file (aside from whitespace). that contains all of the file (aside from whitespace).
Arrange not to include the file again Arrange not to include the file again
if the macro that was tested is defined. */ if the macro that was tested is defined.
if (indepth != 0)
Do not do this for the top-level file in a -include or any
file in a -imacros. */
if (indepth != 0
&& ! (indepth == 1 && no_record_file)
&& ! (no_record_file && no_output))
record_control_macro (ip->fname, temp->control_macro); record_control_macro (ip->fname, temp->control_macro);
fail: ; fail: ;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment