re PR pch/65550 (ICE (segfault) with pch)
authorRichard Biener <rguenther@suse.de>
Thu, 9 Apr 2015 13:37:53 +0000 (13:37 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 9 Apr 2015 13:37:53 +0000 (13:37 +0000)
2015-04-09  Richard Biener  <rguenther@suse.de>

PR pch/65550
* files.c (pch_open_file): Allow main and pre-included files
when trying to open a PCH.

From-SVN: r221949

libcpp/ChangeLog
libcpp/files.c

index 2ad145f8cc8e805381276d992525e6d551d3eec3..7f6603d0842289ecbe700335dca21da82e2a88d9 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-09  Richard Biener  <rguenther@suse.de>
+
+       PR pch/65550
+       * files.c (pch_open_file): Allow main and pre-included files
+       when trying to open a PCH.
+
 2015-04-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR preprocessor/61977
index a995071ad066e748170e89b453abfce449599810..2f491224c6fcb6f07d6d750996ec7a75a9c80ca4 100644 (file)
@@ -291,11 +291,13 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch)
 
   /* 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
-      && !(pfile->all_files->implicit_preinclude
-          || pfile->all_files->next_file->implicit_preinclude))
-    return false;
+  for (_cpp_file *f = pfile->all_files; f; f = f->next_file)
+    if (f->implicit_preinclude)
+      continue;
+    else if (f->main_file)
+      break;
+    else
+      return false;
 
   flen = strlen (path);
   len = flen + sizeof (extension);