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: PCH not being used, but I can't tell why


On Mon, Aug 18, 2003 at 12:52:05PM -0700, Geoff Keating wrote:
> The flag should not be 'reset'.  It should be set, once, correctly, in
> pch_open_file and not in validate_pch,

Ehhhhhh

> probably by having validate_pch
> return the flag value as it applies to this particular file and having
> pch_open_file combine the results for all the files it looks at in any
> particular call.

Okay... this works for me (your patch to cpppch.c is included):



Index: cppfiles.c
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/gcc/cppfiles.c,v
retrieving revision 1.186
diff -u -p -r1.186 cppfiles.c
--- cppfiles.c	9 Aug 2003 22:14:07 -0000	1.186
+++ cppfiles.c	20 Aug 2003 01:05:32 -0000
@@ -273,6 +273,9 @@ pch_open_file (cpp_reader *pfile, _cpp_f
 	  while ((d = readdir (pchdir)) != NULL)
 	    {
 	      dlen = strlen (d->d_name) + 1;
+	      if ((strcmp (d->d_name, ".") == 0)
+		  || (strcmp (d->d_name, "..") == 0))
+		continue;
 	      if (dlen + plen > len)
 		{
 		  len += dlen + 64;
@@ -285,6 +288,7 @@ pch_open_file (cpp_reader *pfile, _cpp_f
 	    }
 	  closedir (pchdir);
 	}
+      file->pch |= valid;
     }
 
   if (valid)
@@ -1184,14 +1188,14 @@ static bool
 validate_pch (cpp_reader *pfile, _cpp_file *file, const char *pchname)
 {
   const char *saved_path = file->path;
+  bool valid = false;
 
   file->path = pchname;
   if (open_file (file))
     {
-      if ((file->pch & 2) == 0)
-	file->pch = pfile->cb.valid_pch (pfile, pchname, file->fd);
+      valid = 1 & pfile->cb.valid_pch (pfile, pchname, file->fd);
 
-      if (!include_pch_p (file))
+      if (!valid)
 	{
 	  close (file->fd);
 	  file->fd = -1;
@@ -1203,12 +1207,10 @@ validate_pch (cpp_reader *pfile, _cpp_fi
 	  for (i = 1; i < pfile->line_maps.depth; i++)
 	    putc ('.', stderr);
 	  fprintf (stderr, "%c %s\n",
-		   include_pch_p (file) ? '!' : 'x', pchname);
+		   valid ? '!' : 'x', pchname);
 	}
     }
-  else
-    file->pch = 2;
 
   file->path = saved_path;
-  return include_pch_p (file);
+  return valid;
 }
Index: cpppch.c
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/gcc/cpppch.c,v
retrieving revision 1.10
diff -u -p -r1.10 cpppch.c
--- cpppch.c	13 Jul 2003 17:34:18 -0000	1.10
+++ cpppch.c	11 Aug 2003 19:18:27 -0000
@@ -509,7 +509,13 @@ cpp_valid_state (cpp_reader *r, const ch
       else if (cmp > 0)
  	++i;
       else
+      {
+	if (CPP_OPTION (r, warn_invalid_pch))
+	  cpp_error (r, DL_WARNING_SYSHDR,
+		     "%s: not used because `%s' is defined",
+		     name, first);
 	goto fail;
+      }
     }
    
   free(nl.defs);


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