[multiple changes]
2000-08-20 Zack Weinberg <zack@wolery.cumb.org> * cppinit.c (cpp_init): Set global flag when called. (cpp_reader_init): Bomb out if cpp_init hasn't been called. 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. * gcc.dg/cpp/pragma-1.c: New test. * gcc.dg/cpp/pragma-2.c: New test. From-SVN: r35825
This commit is contained in:
parent
53e687fabb
commit
3cb553b468
@ -1,3 +1,22 @@
|
||||
2000-08-20 Zack Weinberg <zack@wolery.cumb.org>
|
||||
|
||||
* cppinit.c (cpp_init): Set global flag when called.
|
||||
(cpp_reader_init): Bomb out if cpp_init hasn't been called.
|
||||
|
||||
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.
|
||||
|
||||
2000-08-20 Richard Henderson <rth@cygnus.com>
|
||||
|
||||
* config/ia64/ia64.c (emit_insn_group_barriers): Stop if ar.lc
|
||||
|
@ -398,21 +398,28 @@ merge_include_chains (pfile)
|
||||
CPP_OPTION (pfile, bracket_include) = brack;
|
||||
}
|
||||
|
||||
/* cpp_init initializes library global state. It might not need to do
|
||||
anything depending on the platform and compiler, so we have a static
|
||||
flag to make sure it gets called before cpp_reader_init. */
|
||||
|
||||
static int cpp_init_completed = 0;
|
||||
|
||||
void
|
||||
cpp_init (void)
|
||||
{
|
||||
#ifdef HOST_EBCDIC
|
||||
/* For non-ASCII hosts, the array needs to be sorted at runtime. */
|
||||
/* For non-ASCII hosts, the cl_options array needs to be sorted at
|
||||
runtime. */
|
||||
qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
|
||||
#endif
|
||||
|
||||
/* Set up the trigraph map for trigraph_ok, trigraph_replace and
|
||||
lex_line. */
|
||||
/* Set up the trigraph map and the IStable. These don't need to do
|
||||
anything if we were compiled with a compiler that supports C99
|
||||
designated initializers. */
|
||||
init_trigraph_map ();
|
||||
|
||||
/* Set up the IStable. This doesn't do anything if we were compiled
|
||||
with a compiler that supports C99 designated initializers. */
|
||||
init_IStable ();
|
||||
|
||||
cpp_init_completed = 1;
|
||||
}
|
||||
|
||||
/* Initialize a cpp_reader structure. */
|
||||
@ -434,6 +441,15 @@ cpp_reader_init (pfile)
|
||||
CPP_OPTION (pfile, pending) =
|
||||
(struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
|
||||
|
||||
/* If cpp_init hasn't been called, generate a fatal error (by hand)
|
||||
and call it here. */
|
||||
if (!cpp_init_completed)
|
||||
{
|
||||
fputs ("cpp_reader_init: internal error: cpp_init not called.\n", stderr);
|
||||
pfile->errors = CPP_FATAL_LIMIT;
|
||||
cpp_init ();
|
||||
}
|
||||
|
||||
_cpp_init_macros (pfile);
|
||||
_cpp_init_stacks (pfile);
|
||||
_cpp_init_includes (pfile);
|
||||
|
11
gcc/cpplex.c
11
gcc/cpplex.c
@ -299,7 +299,10 @@ cpp_printf VPARAMS ((cpp_reader *pfile, cpp_printer *print,
|
||||
|
||||
/* End the previous line of text. */
|
||||
if (pfile->need_newline)
|
||||
putc ('\n', print->outf);
|
||||
{
|
||||
putc ('\n', print->outf);
|
||||
print->lineno++;
|
||||
}
|
||||
pfile->need_newline = 0;
|
||||
|
||||
vfprintf (print->outf, fmt, ap);
|
||||
@ -363,14 +366,14 @@ cpp_scan_buffer (pfile, print)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
output_line_command (pfile, print, pfile->token_list.line);
|
||||
prev = 0;
|
||||
}
|
||||
|
||||
if (token->type != CPP_PLACEMARKER)
|
||||
|
@ -142,6 +142,7 @@ cb_ident (pfile, str, len)
|
||||
unsigned int len;
|
||||
{
|
||||
cpp_printf (pfile, &parse_out, "#ident \"%.*s\"\n", (int) len, str);
|
||||
parse_out.lineno++;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -156,6 +157,7 @@ cb_define (pfile, hash)
|
||||
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
|
||||
cpp_dump_definition (pfile, parse_out.outf, hash);
|
||||
putc ('\n', parse_out.outf);
|
||||
parse_out.lineno++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +167,10 @@ cb_undef (pfile, hash)
|
||||
cpp_hashnode *hash;
|
||||
{
|
||||
if (pfile->done_initializing)
|
||||
cpp_printf (pfile, &parse_out, "#undef %s\n", hash->name);
|
||||
{
|
||||
cpp_printf (pfile, &parse_out, "#undef %s\n", hash->name);
|
||||
parse_out.lineno++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -183,6 +188,7 @@ cb_include (pfile, dir, str, len, ab)
|
||||
l = '"', r = '"';
|
||||
|
||||
cpp_printf (pfile, &parse_out, "#%s %c%.*s%c\n", dir, l, (int) len, str, r);
|
||||
parse_out.lineno++;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -233,6 +239,7 @@ cb_def_pragma (pfile)
|
||||
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
|
||||
@ -278,6 +285,7 @@ dump_macros_helper (pfile, hp)
|
||||
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;
|
||||
|
@ -1,3 +1,8 @@
|
||||
Sun Aug 20 01:41:35 MSD 2000 Dennis Chernoivanov <cdi@sparc.spb.su>
|
||||
|
||||
* gcc.dg/cpp/pragma-1.c: New test.
|
||||
* gcc.dg/cpp/pragma-2.c: New test.
|
||||
|
||||
2000-08-18 Zack Weinberg <zack@wolery.cumb.org>
|
||||
|
||||
* gcc.dg/cpp/lexstrng.c: Don't include string.h.
|
||||
|
13
gcc/testsuite/gcc.dg/cpp/pragma-1.c
Normal file
13
gcc/testsuite/gcc.dg/cpp/pragma-1.c
Normal file
@ -0,0 +1,13 @@
|
||||
/* Verify that preprocessor does not insert redundant newlines
|
||||
after #pragma */
|
||||
/* { dg-do compile } */
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#pragma unknown
|
||||
{
|
||||
error;
|
||||
/* { dg-error "undeclared" "undeclared-variable message" { target *-*-* } { 9 } } */
|
||||
/* { dg-error "function it appears in" "reminder message" { target *-*-* } { 9 } } */
|
||||
}
|
||||
}
|
16
gcc/testsuite/gcc.dg/cpp/pragma-2.c
Normal file
16
gcc/testsuite/gcc.dg/cpp/pragma-2.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* Verify that preprocessor does not insert redundant newlines
|
||||
after #pragma, also check this for #include, #define and #undef */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-dD" } */
|
||||
#include <stdio.h>
|
||||
|
||||
#undef unknow_def
|
||||
|
||||
int main () {
|
||||
|
||||
#pragma unknown
|
||||
{}
|
||||
error;
|
||||
/* { dg-error "undeclared" "undeclared-variable message" { target *-*-* } { 13 } } */
|
||||
/* { dg-error "function it appears in" "reminder message" { target *-*-* } { 13 } } */
|
||||
}
|
Loading…
Reference in New Issue
Block a user