From: Jakub Jelinek Date: Fri, 12 Jun 2015 11:56:39 +0000 (+0200) Subject: backport: re PR pch/65550 (ICE (segfault) with pch) X-Git-Tag: releases/gcc-4.8.5~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=074d34fe4fd7fa466f2f7665b24c66744dc0f387;p=thirdparty%2Fgcc.git backport: re PR pch/65550 (ICE (segfault) with pch) Backported from mainline 2015-04-09 Richard Biener PR pch/65550 * files.c (pch_open_file): Allow main and pre-included files when trying to open a PCH. From-SVN: r224423 --- diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index ad9defb9f662..e50c2fc8641a 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,12 @@ +2015-06-12 Jakub Jelinek + + Backported from mainline + 2015-04-09 Richard Biener + + 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. diff --git a/libcpp/files.c b/libcpp/files.c index ea91b02047da..f4b42564568d 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -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);