2009-09-22 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Sep 2009 08:37:31 +0000 (08:37 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 22 Sep 2009 08:37:31 +0000 (08:37 +0000)
PR pch/38987
* files.c (pch_open_file): Disallow non-toplevel PCH inclusion.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151970 138bc75d-0d04-0410-961f-82ee72b054a4

libcpp/ChangeLog
libcpp/files.c

index 6b257d2..eff8cd4 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-22  Richard Guenther  <rguenther@suse.de>
+
+       PR pch/38987
+       * files.c (pch_open_file): Disallow non-toplevel PCH inclusion.
+
 2009-09-18  Chris Demetriou  <cgd@google.com>
 
        PR preprocessor/28435:
index 96ba7e8..ecf9d6c 100644 (file)
@@ -288,6 +288,12 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch)
   if (file->name[0] == '\0' || !pfile->cb.valid_pch)
     return false;
 
+  /* If the file is not included as first include from either the toplevel
+     file or the command-line it is not a valid use of PCH.  */
+  if (pfile->all_files
+      && pfile->all_files->next_file)
+    return false;
+
   flen = strlen (path);
   len = flen + sizeof (extension);
   pchname = XNEWVEC (char, len);