+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
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. */
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);
/* 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);
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)
unsigned int len;
{
cpp_printf (pfile, &parse_out, "#ident \"%.*s\"\n", (int) len, str);
+ parse_out.lineno++;
}
static void
|| CPP_OPTION (pfile, dump_macros) == dump_definitions)
cpp_dump_definition (pfile, parse_out.outf, hash);
putc ('\n', parse_out.outf);
+ parse_out.lineno++;
}
}
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
l = '"', r = '"';
cpp_printf (pfile, &parse_out, "#%s %c%.*s%c\n", dir, l, (int) len, str, r);
+ parse_out.lineno++;
}
static void
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
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;
+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.
--- /dev/null
+/* 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 } } */
+ }
+}
--- /dev/null
+/* 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 } } */
+}