This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]