This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][libcpp] Avoid ICEs with improper PCH usage
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 20 Sep 2009 15:22:11 +0200 (CEST)
- Subject: [PATCH][libcpp] Avoid ICEs with improper PCH usage
This patch deals with situations like in PR36606 which use PCH
in an invalid way and thus cause random ICEs. It should reduce
the usual noise in PCH bugreports.
Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?
Thanks,
Richard.
2009-09-20 Richard Guenther <rguenther@suse.de>
PR pch/36606
* files.c (pch_open_file): Disallow non-toplevel PCH inclusion.
Index: libcpp/files.c
===================================================================
*** libcpp/files.c (revision 151894)
--- libcpp/files.c (working copy)
*************** pch_open_file (cpp_reader *pfile, _cpp_f
*** 288,293 ****
--- 288,299 ----
if (file->name[0] == '\0' || !pfile->cb.valid_pch)
return false;
+ /* 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)
+ return false;
+
flen = strlen (path);
len = flen + sizeof (extension);
pchname = XNEWVEC (char, len);