This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix preprocessor/7150
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jason R Thorpe <thorpej at wasabisystems dot com>
- Date: Sat, 29 Jun 2002 15:35:57 +0100
- Subject: Fix preprocessor/7150
This is another bug introduced by the integrated traditional
preprocessor. cpp_scan_nooutput() had not been updated to
handle the traditional case.
Jason, this should fix the segfault that occurred for you
in cpp_paste_tokens(). It tends to happen if you use
-imacros or -dM or something that scans code without
outputting it.
I'm doing a make check on this; I'll apply it once it suceeds.
Neil.
PR preprocessor/7150
* cppmain.c (scan_translation_unit_trad): Simplify.
* cpplib.c (cpp_scan_nooutput): Handle traditional case.
Index: cppmain.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmain.c,v
retrieving revision 1.100
diff -u -p -r1.100 cppmain.c
--- cppmain.c 19 Jun 2002 05:40:08 -0000 1.100
+++ cppmain.c 29 Jun 2002 13:51:47 -0000
@@ -228,13 +228,9 @@ static void
scan_translation_unit_trad (pfile)
cpp_reader *pfile;
{
- for (;;)
+ while (_cpp_read_logical_line_trad (pfile))
{
- size_t len;
-
- if (!_cpp_read_logical_line_trad (pfile))
- break;
- len = pfile->out.cur - pfile->out.base;
+ size_t len = pfile->out.cur - pfile->out.base;
maybe_print_line (print.map, pfile->out.first_line);
fwrite (pfile->out.base, 1, len, print.outf);
print.printed = 1;
Index: cppmacro.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppmacro.c,v
retrieving revision 1.115
diff -u -p -r1.115 cppmacro.c
--- cppmacro.c 19 Jun 2002 05:40:06 -0000 1.115
+++ cppmacro.c 29 Jun 2002 13:51:48 -0000
@@ -1136,8 +1136,12 @@ cpp_scan_nooutput (pfile)
transparently continuing with the including file. */
pfile->buffer->return_at_eof = true;
- while (cpp_get_token (pfile)->type != CPP_EOF)
- ;
+ if (CPP_OPTION (pfile, traditional))
+ while (_cpp_read_logical_line_trad (pfile))
+ ;
+ else
+ while (cpp_get_token (pfile)->type != CPP_EOF)
+ ;
}
/* Step back one (or more) tokens. Can only step mack more than 1 if