public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR65550, ICE on invalid PCH use
@ 2015-04-09 13:03 Richard Biener
  2015-04-09 13:19 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2015-04-09 13:03 UTC (permalink / raw)
  To: gcc-patches


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix PR65550, ICE on invalid PCH use
  2015-04-09 13:03 [PATCH] Fix PR65550, ICE on invalid PCH use Richard Biener
@ 2015-04-09 13:19 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2015-04-09 13:19 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Thu, Apr 09, 2015 at 03:03:38PM +0200, Richard Biener wrote:
> 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.

Ok.  If it wouldn't be too hard to add a testcase, it would be appreciated,
but if it isn't that easy, just commit it as is (or add testcase
later).

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-09 13:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-09 13:03 [PATCH] Fix PR65550, ICE on invalid PCH use Richard Biener
2015-04-09 13:19 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).