[PATCH] Always pass an open file descriptor to c_common_read_pch
Zack Weinberg
zack@codesourcery.com
Tue Aug 19 16:30:00 GMT 2003
Ritzert@t-online.de writes:
> * c-pch.c (c_common_read_pch): Assert that an invalid file descriptor
> will never get here.
> * cppfiles.c (should_stack_file): Make sure that the file descriptor
> passed to read_pch is valid.
...
> !
> ! my_friendly_assert( fd != -1, 20030818 );
my_friendly_assert is not to be used in new code. Write
if (fd == -1)
abort ();
instead. Actually, I don't think this assertion is necessary; the
fatal error after fdopen fails is good enough.
> Index: cppfiles.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
> retrieving revision 1.186
> diff -u -3 -p -f -r1.186 cppfiles.c
> *** cppfiles.c 9 Aug 2003 22:14:07 -0000 1.186
> --- cppfiles.c 18 Aug 2003 19:39:42 -0000
> *************** should_stack_file (cpp_reader *pfile, _c
> *** 551,556 ****
> --- 551,563 ----
> /* Handle PCH files immediately; don't stack them. */
> if (include_pch_p (file))
> {
> + /* Make sure the file is open. */
> + if (file->fd == -1)
> + {
> + if (!pch_open_file (pfile, file))
> + return false;
> + }
> +
> pfile->cb.read_pch (pfile, file->path, file->fd,
> file->pchname);
> close (file->fd);
> file->fd = -1;
I don't think this is right either. Your test case does not involve
PCH; we should not be going through this code path at all.
zw
More information about the Gcc-patches
mailing list