]> 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:08 +0000 (13:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Jun 2015 11:56:08 +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: r224422

libcpp/ChangeLog
libcpp/files.c

index 47dc9a962ac023e74e653319776f76e91fcfa1f7..137ccf2cc2cc41bbfa62708f2b6104e1d8b97087 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-11-28  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index 149f06df201b01a9f451fcb75970d093b341ee9a..f9834951c2f4a73330403cb6e7070ca75961e356 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);