]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR pch/65550 (ICE (segfault) with pch)
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Jun 2015 11:56:39 +0000 (13:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Jun 2015 11:56:39 +0000 (13:56 +0200)
Backported from mainline
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: r224423

libcpp/ChangeLog
libcpp/files.c

index ad9defb9f6623151b0998e7b9d090bc1422ec5e4..e50c2fc8641aa7bb251fbb9fe454001e2bff7607 100644 (file)
@@ -1,3 +1,12 @@
+2015-06-12  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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.
+
 2014-12-19  Release Manager
 
        * GCC 4.8.4 released.
index ea91b02047da4c6989cdb8d1341fa008597ef3f4..f4b42564568d652563d5ce33454d560bfdf06683 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);