Hi!

Bootstrapped/regtested on 4.8 and 4.9 branches on x86_64-linux and
i686-linux, ok for 4.8/4.9?

2015-06-12  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2015-04-09  Richard Biener  <rguent...@suse.de>

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

--- libcpp/files.c      (revision 221948)
+++ libcpp/files.c      (revision 221949)
@@ -291,11 +291,13 @@ pch_open_file (cpp_reader *pfile, _cpp_f
 
   /* 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);

        Jakub

Reply via email to