cpplib: what is a system header? [HEAD]
Neil Booth
neil@daikokuya.demon.co.uk
Mon Feb 19 11:18:00 GMT 2001
Zack Weinberg wrote:-
> In 3.0, it's much too late to be changing semantics except to fix
> bugs. I think the lack of transitive warning suppression counts as a
> bug; we should change that. But people do depend on the existing -MM,
> so let's not change that at all. Let's do the transitivity bit for
> everything except dependencies, leave dependencies alone, and rename
> system_include_depth to angle_bracket_depth or something to eliminate
> the existing confusion.
OK this leaves dependencies alone, does transitivity for normal headers,
and has bootstrapped and made check x86 Linux.
If it survives a week or so in Head, I'll consider applying it to the branch,
although I tend to think we needn't bother. I'd never intended applying
any of this to the branch.
Unified systemheaderness is a simple patch after this.
> On the mainline, we can experiment with making -MM use the same
> definition of system headers as everything else. Then Russ and other
> people can try it out and report if it really does break stuff. It
> might be wisest to wait until after 3.0 is _released_.
Yes, let's unify it after release.
Neil.
* cppfiles.c (stack_include_file): Generate dependencies
here, and manage include_count here too.
(PRINT_THIS_DEP): Delete.
(_cpp_execute_include): Do not generate dependencies here,
apart from the case of a missing header. Do not manage
include_count.
(_cpp_read_file): Leave dependency generation to
stack_include_file.
Index: cppfiles.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
retrieving revision 1.102
diff -u -p -r1.102 cppfiles.c
--- cppfiles.c 2001/02/16 07:41:08 1.102
+++ cppfiles.c 2001/02/19 19:10:32
@@ -268,7 +268,21 @@ stack_include_file (pfile, inc)
{
size_t len = 0;
cpp_buffer *fp;
+ int sysp, deps_sysp;
+ /* We'll try removing deps_sysp after the release of 3.0. */
+ deps_sysp = pfile->system_include_depth != 0;
+ sysp = ((pfile->buffer && pfile->buffer->sysp)
+ || (inc->foundhere && inc->foundhere->sysp));
+
+ /* For -M, add the file to the dependencies on its first inclusion. */
+ if (CPP_OPTION (pfile, print_deps) > deps_sysp && !inc->include_count)
+ deps_add_dep (pfile->deps, inc->name);
+
+ /* We don't want multiple include guard advice for the main file. */
+ if (pfile->buffer)
+ inc->include_count++;
+
/* Not in cache? */
if (! inc->buffer)
read_include_file (pfile, inc);
@@ -280,8 +294,7 @@ stack_include_file (pfile, inc)
fp = cpp_push_buffer (pfile, inc->buffer, len, BUF_FILE, inc->name);
fp->inc = inc;
fp->inc->refcnt++;
- if (inc->foundhere)
- fp->sysp = inc->foundhere->sysp;
+ fp->sysp = sysp;
/* The ->actual_dir field is only used when ignore_srcdir is not in effect;
see do_include */
@@ -566,7 +579,6 @@ report_missing_guard (n, b)
return 0;
}
-#define PRINT_THIS_DEP(p, b) (CPP_PRINT_DEPS(p) > (b||p->system_include_depth))
void
_cpp_execute_include (pfile, header, no_reinclude, include_next)
cpp_reader *pfile;
@@ -579,6 +591,7 @@ _cpp_execute_include (pfile, header, no_
unsigned int angle_brackets = header->type == CPP_HEADER_NAME;
struct include_file *inc;
char *fname;
+ int print_dep;
/* Help protect #include or similar from recursion. */
if (pfile->buffer_stack_depth >= CPP_STACK_MAX)
@@ -636,20 +649,13 @@ _cpp_execute_include (pfile, header, no_
}
inc = find_include_file (pfile, fname, search_start);
-
if (inc)
{
- /* For -M, add the file to the dependencies on its first inclusion. */
- if (!inc->include_count && PRINT_THIS_DEP (pfile, angle_brackets))
- deps_add_dep (pfile->deps, inc->name);
- inc->include_count++;
-
- /* Actually process the file. */
- stack_include_file (pfile, inc);
-
if (angle_brackets)
pfile->system_include_depth++;
+ stack_include_file (pfile, inc);
+
if (! DO_NOT_REREAD (inc))
{
if (no_reinclude)
@@ -668,8 +674,10 @@ _cpp_execute_include (pfile, header, no_
return;
}
- if (CPP_OPTION (pfile, print_deps_missing_files)
- && PRINT_THIS_DEP (pfile, angle_brackets))
+ /* We will try making the RHS pfile->buffer->sysp after 3.0. */
+ print_dep = CPP_PRINT_DEPS(pfile) > (angle_brackets
+ || pfile->system_include_depth);
+ if (CPP_OPTION (pfile, print_deps_missing_files) && print_dep)
{
if (!angle_brackets || IS_ABSOLUTE_PATHNAME (fname))
deps_add_dep (pfile->deps, fname);
@@ -704,8 +712,7 @@ _cpp_execute_include (pfile, header, no_
can't produce correct output, because there may be
dependencies we need inside the missing file, and we don't
know what directory this missing file exists in. */
- else if (CPP_PRINT_DEPS (pfile)
- && ! PRINT_THIS_DEP (pfile, angle_brackets))
+ else if (CPP_PRINT_DEPS (pfile) && ! print_dep)
cpp_warning (pfile, "No include path in which to find %s", fname);
else
cpp_error_from_errno (pfile, fname);
@@ -766,9 +773,6 @@ _cpp_read_file (pfile, fname)
cpp_error_from_errno (pfile, fname);
return 0;
}
-
- if (CPP_OPTION (pfile, print_deps))
- deps_add_dep (pfile->deps, f->name);
stack_include_file (pfile, f);
return 1;
More information about the Gcc-patches
mailing list