This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Infinite loop with -include and -M
- From: Neil Booth <neil>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: gcc at gcc dot gnu dot org dot gcc-patches
- Date: Tue, 22 Apr 2003 20:51:36 +0100
- Subject: Re: Infinite loop with -include and -M
- References: <m37k9nfmke.fsf@whitebox.local>
Andreas Schwab wrote:-
> When preprocessing a file with -M (or any other option that sets
> flag_no_output) and there is a -include file the preprocessor enters
> an infinite loop in preprocess_file because pfile->buffer->prev never
> becomes NULL, and eventually the process runs out of memory.
>
> $ echo > included.c
> $ echo > included.h
> $ gcc -include included.h -M included.c
Thanks, fixed thus.
Neil.
* cpplex.c (_cpp_get_fresh_line): Pop the buffer if return_at_eof.
Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.228
diff -u -p -r1.228 cpplex.c
--- cpplex.c 22 Apr 2003 19:28:00 -0000 1.228
+++ cpplex.c 22 Apr 2003 19:49:45 -0000
@@ -714,14 +714,14 @@ _cpp_get_fresh_line (pfile)
"no newline at end of file");
}
+ if (!buffer->prev)
+ return false;
+
if (buffer->return_at_eof)
{
- buffer->return_at_eof = false;
+ _cpp_pop_buffer (pfile);
return false;
}
-
- if (!buffer->prev)
- return false;
_cpp_pop_buffer (pfile);
}