This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: more pch questions
Benjamin Kosnik <bkoz at redhat dot com> writes:
> -Winvalid-pch says nothing because in _cpp_begin_message,
>
> switch (level)
> {
> case DL_WARNING:
> case DL_PEDWARN:
> if (CPP_IN_SYSTEM_HEADER (pfile)
> && ! CPP_OPTION (pfile, warn_system_headers))
> return 0;
>
> returns zero, because the pch in question includes files marked as
> system headers (C++ <string>) and I didn't specify
>
> -Winvalid-pch -Wsystem-headers
>
> When I do, I get:
>
> In file included from test_pch.cc:1:
> /mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/string:45:20:
> warning:
> /mnt/hd/bld/gcc/i686-pc-linux-gnu/libstdc++-v3/include/stdc++.h.gch: not
> used because `_CPP_STRING' is defined
>
> Perhaps a better way of getting this message would be to use DL_WARNING_SYSHDR,
> not DL_WARNING in cpp_valid_state. See attached patch. There are other,
> perhaps unrelated problems with pch files and system headers (see
> other/9471).
>
> I'm still not quite sure what the error message, when I can see it,
> means. Any insights? Why does _CPP_STRING being defined matter?
It means that somewhere in the header you've precompiled, _CPP_STRING
is used; and that you're defining _CPP_STRING on the command line (or
before the PCH is included) when you're using the PCH but not when
generating it. This changes the meaning of the PCH in a way that can't be
easily handled, so to ensure correct compilation, the PCH isn't used.
> Since the generated pch file is invalid, I'll try to fix this as well.
This patch is OK, please commit it.
> -benjamin
>
> 2003-03-11 Benjamin Kosnik <bkoz at redhat dot com>
>
> * cpppch.c (cpp_valid_state): Use DL_WARNING_SYSHDR, not
> DL_WARNING so that errors in system includes are shown.
>
> Index: cpppch.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/cpppch.c,v
> retrieving revision 1.2
> diff -c -p -r1.2 cpppch.c
> *** cpppch.c 10 Jan 2003 02:21:59 -0000 1.2
> --- cpppch.c 12 Mar 2003 04:50:47 -0000
> *************** cpp_valid_state (r, name, fd)
> *** 417,423 ****
> || h->flags & NODE_POISONED)
> {
> if (CPP_OPTION (r, warn_invalid_pch))
> ! cpp_error (r, DL_WARNING,
> "%s: not used because `%.*s' not defined",
> name, m.name_length, namebuf);
> goto fail;
> --- 417,423 ----
> || h->flags & NODE_POISONED)
> {
> if (CPP_OPTION (r, warn_invalid_pch))
> ! cpp_error (r, DL_WARNING_SYSHDR,
> "%s: not used because `%.*s' not defined",
> name, m.name_length, namebuf);
> goto fail;
> *************** cpp_valid_state (r, name, fd)
> *** 429,435 ****
> || memcmp (namebuf, newdefn, m.definition_length) != 0)
> {
> if (CPP_OPTION (r, warn_invalid_pch))
> ! cpp_error (r, DL_WARNING,
> "%s: not used because `%.*s' defined as `%s' not `%.*s'",
> name, m.name_length, namebuf, newdefn + m.name_length,
> m.definition_length - m.name_length,
> --- 429,435 ----
> || memcmp (namebuf, newdefn, m.definition_length) != 0)
> {
> if (CPP_OPTION (r, warn_invalid_pch))
> ! cpp_error (r, DL_WARNING_SYSHDR,
> "%s: not used because `%.*s' defined as `%s' not `%.*s'",
> name, m.name_length, namebuf, newdefn + m.name_length,
> m.definition_length - m.name_length,
> *************** cpp_valid_state (r, name, fd)
> *** 454,460 ****
> || h->flags & NODE_POISONED)
> {
> if (CPP_OPTION (r, warn_invalid_pch))
> ! cpp_error (r, DL_WARNING, "%s: not used because `%s' is defined",
> name, undeftab + i);
> goto fail;
> }
> --- 454,461 ----
> || h->flags & NODE_POISONED)
> {
> if (CPP_OPTION (r, warn_invalid_pch))
> ! cpp_error (r, DL_WARNING_SYSHDR,
> ! "%s: not used because `%s' is defined",
> name, undeftab + i);
> goto fail;
> }
>
--
- Geoffrey Keating <geoffk at geoffk dot org>