[PATCH] cpp0 misbehavior
Dennis I. Chernoivanov
cdi@home.ru
Sun Aug 20 07:31:00 GMT 2000
Bootstrapped. Tested. Two tests (that should go into gcc.dg) are in
attachment.
--cdi
ChangeLog:
Sun Aug 20 01:41:35 MSD 2000 Dennis Chernoivanov <cdi@sparc.spb.su>
* cpplex.c (cpp_scan_buffer): Move `output_line_command' just
before `process_directive' so that newlines won't be missed
for directives.
(cpp_printf): Increment `print->lineno' when newline is emitted.
* cppmain.c (cb_ident): Likewise.
(cb_define): Likewise.
(cb_undef): Likewise.
(cb_include): Likewise.
(cb_def_pragma): Likewise.
(dump_macros_helper): Likewise.
Index: gcc/cpplex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplex.c,v
retrieving revision 1.87
diff -c -3 -p -r1.87 cpplex.c
*** cpplex.c 2000/08/09 19:41:12 1.87
--- cpplex.c 2000/08/20 14:03:56
*************** cpp_printf VPARAMS ((cpp_reader *pfile,
*** 328,334 ****
/* End the previous line of text. */
if (pfile->need_newline)
! putc ('\n', print->outf);
pfile->need_newline = 0;
vfprintf (print->outf, fmt, ap);
--- 328,337 ----
/* End the previous line of text. */
if (pfile->need_newline)
! {
! putc ('\n', print->outf);
! print->lineno++;
! }
pfile->need_newline = 0;
vfprintf (print->outf, fmt, ap);
*************** cpp_scan_buffer (pfile, print)
*** 392,405 ****
if (token->flags & BOL)
{
if (token->type == CPP_HASH && pfile->token_list.directive)
{
process_directive (pfile, token);
continue;
}
-
- output_line_command (pfile, print, pfile->token_list.line);
- prev = 0;
}
if (token->type != CPP_PLACEMARKER)
--- 395,408 ----
if (token->flags & BOL)
{
+ output_line_command (pfile, print, pfile->token_list.line);
+ prev = 0;
+
if (token->type == CPP_HASH && pfile->token_list.directive)
{
process_directive (pfile, token);
continue;
}
}
if (token->type != CPP_PLACEMARKER)
Index: gcc/cppmain.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppmain.c,v
retrieving revision 1.33
diff -c -3 -p -r1.33 cppmain.c
*** cppmain.c 2000/08/09 19:41:12 1.33
--- cppmain.c 2000/08/20 14:03:57
*************** cb_ident (pfile, str, len)
*** 141,146 ****
--- 141,147 ----
unsigned int len;
{
cpp_printf (pfile, &parse_out, "#ident \"%.*s\"\n", (int) len, str);
+ parse_out.lineno++;
}
static void
*************** cb_define (pfile, hash)
*** 155,160 ****
--- 156,162 ----
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
cpp_dump_definition (pfile, parse_out.outf, hash);
putc ('\n', parse_out.outf);
+ parse_out.lineno++;
}
}
*************** cb_undef (pfile, hash)
*** 164,170 ****
cpp_hashnode *hash;
{
if (pfile->done_initializing)
! cpp_printf (pfile, &parse_out, "#undef %s\n", hash->name);
}
static void
--- 166,175 ----
cpp_hashnode *hash;
{
if (pfile->done_initializing)
! {
! cpp_printf (pfile, &parse_out, "#undef %s\n", hash->name);
! parse_out.lineno++;
! }
}
static void
*************** cb_include (pfile, dir, str, len, ab)
*** 182,187 ****
--- 187,193 ----
l = '"', r = '"';
cpp_printf (pfile, &parse_out, "#%s %c%.*s%c\n", dir, l, (int) len, str, r);
+ parse_out.lineno++;
}
static void
*************** cb_def_pragma (pfile)
*** 232,237 ****
--- 238,244 ----
cpp_output_list (pfile, parse_out.outf, &pfile->token_list,
pfile->first_directive_token + 2);
putc ('\n', parse_out.outf);
+ parse_out.lineno++;
}
static void
*************** dump_macros_helper (pfile, hp)
*** 277,282 ****
--- 284,290 ----
cpp_printf (pfile, &parse_out, "#define %s", hp->name);
cpp_dump_definition (pfile, parse_out.outf, hp);
putc ('\n', parse_out.outf);
+ parse_out.lineno++;
}
return 1;
More information about the Gcc-patches
mailing list