This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH for preprocessor/14103: [3.4/3.5 Regression] ICEs on "gcc-E -imacros foo.h baz.c"
- From: Per Bothner <per at bothner dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Feb 2004 14:26:37 -0800
- Subject: Re: PATCH for preprocessor/14103: [3.4/3.5 Regression] ICEs on "gcc-E -imacros foo.h baz.c"
- References: <40311D39.8000800@bothner.com>
I checked the patch into mainline.
I also checked in the attached simplified patch into the 3.4 branch.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
2004-02-18 Per Bothner <per@bothner.com>
* cpphash.h (struct cpp_buffer): Restore return_at_eof field. This
partly reverts my 2003-10-01 change, because we're back to logically
including <command line> inside the main line.
* cpplex.c (_cpp_get_fresh_line): Check return_at_eof field.
* cppmacro.c (cpp_scan_nooutput): Set return_at_eof of current buffer.
Fixes PR preprocessor/14103.
Index: cpphash.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpphash.h,v
retrieving revision 1.203.4.2
diff -u -p -r1.203.4.2 cpphash.h
--- cpphash.h 7 Feb 2004 14:33:09 -0000 1.203.4.2
+++ cpphash.h 17 Feb 2004 07:22:51 -0000
@@ -303,9 +303,10 @@ struct cpp_buffer
buffers. */
unsigned char from_stage3;
- /* Nonzero means that the directory to start searching for ""
- include files has been calculated and stored in "dir" below. */
- unsigned char search_cached;
+ /* At EOF, a buffer is automatically popped. If RETURN_AT_EOF is
+ true, a CPP_EOF token is then returned. Otherwise, the next
+ token from the enclosing buffer is returned. */
+ unsigned int return_at_eof : 1;
/* The directory of the this buffer's file. Its NAME member is not
allocated, so we don't need to worry about freeing it. */
Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.250
diff -u -p -r1.250 cpplex.c
--- cpplex.c 1 Nov 2003 22:56:51 -0000 1.250
+++ cpplex.c 17 Feb 2004 07:22:52 -0000
@@ -744,6 +744,8 @@ _cpp_lex_token (cpp_reader *pfile)
bool
_cpp_get_fresh_line (cpp_reader *pfile)
{
+ int return_at_eof;
+
/* We can't get a new line until we leave the current directive. */
if (pfile->state.in_directive)
return false;
@@ -776,9 +778,10 @@ _cpp_get_fresh_line (cpp_reader *pfile)
CPP_BUF_COLUMN (buffer, buffer->cur),
"no newline at end of file");
}
-
+
+ return_at_eof = buffer->return_at_eof;
_cpp_pop_buffer (pfile);
- if (pfile->buffer == NULL)
+ if (pfile->buffer == NULL || return_at_eof)
return false;
}
}
Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.141
diff -u -p -r1.141 cppmacro.c
--- cppmacro.c 1 Nov 2003 22:56:52 -0000 1.141
+++ cppmacro.c 17 Feb 2004 07:22:52 -0000
@@ -1136,6 +1136,10 @@ cpp_sys_macro_p (cpp_reader *pfile)
void
cpp_scan_nooutput (cpp_reader *pfile)
{
+ /* Request a CPP_EOF token at the end of this file, rather than
+ transparently continuing with the including file. */
+ pfile->buffer->return_at_eof = true;
+
if (CPP_OPTION (pfile, traditional))
while (_cpp_read_logical_line_trad (pfile))
;