This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR65550, ICE on invalid PCH use
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 9 Apr 2015 15:03:38 +0200 (CEST)
- Subject: [PATCH] Fix PR65550, ICE on invalid PCH use
- Authentication-results: sourceware.org; auth=none
The following makes the checks whether the context allows a PCH file
(only the first include may be one, and not nested) more robust
thereby fixing PR65550.
Bootstrapped and tested on x86_64-unknown-linux-gnu - ok?
Thanks,
Richard.
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.
Index: libcpp/files.c
===================================================================
--- libcpp/files.c (revision 221942)
+++ libcpp/files.c (working copy)
@@ -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);