This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: more pch questions


>You're saying that execution reaches the fail: label in 
>cpp_valid_state.  Execution can't fall through to there, there are only 
>three places that have 'goto fail' in that routine, and each one has a 
>call to cpp_error right before it, switched on by 'warn_invalid_pch'.

Yes.

>So, if -Winvalid-pch says nothing, then there's something very wrong, 
>maybe a codegen problem in the stage1 compiler.

No.

-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?

Since the generated pch file is invalid, I'll try to fix this as well.

-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;
  	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]