summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-08-20 21:36:18 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-08-20 21:36:18 +0000
commitbad6bf53a0651af433617614f4967c4d0284dee2 (patch)
treed81b589e39b9cc29d2ac00a4c083ae74ae5241d1
parent49ebeab8b14af11693e4da237367c500e87d9f9e (diff)
downloadgcc-bad6bf53a0651af433617614f4967c4d0284dee2.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35825 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/cppinit.c28
-rw-r--r--gcc/cpplex.c11
-rw-r--r--gcc/cppmain.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pragma-1.c13
-rw-r--r--gcc/testsuite/gcc.dg/cpp/pragma-2.c16
7 files changed, 91 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d5467b5f7bf..1fd965ff843 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index c8a06e8afa2..f1ed54fd85f 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -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);
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 7ab850bfa22..7b07944c03b 100644
--- a/gcc/cpplex.c
+++ b/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)
diff --git a/gcc/cppmain.c b/gcc/cppmain.c
index 9dc431e12d5..3e570be3584 100644
--- a/gcc/cppmain.c
+++ b/gcc/cppmain.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2eb377aac59..5382c0add29 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/cpp/pragma-1.c b/gcc/testsuite/gcc.dg/cpp/pragma-1.c
new file mode 100644
index 00000000000..4b9295f781d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pragma-1.c
@@ -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 } } */
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/cpp/pragma-2.c b/gcc/testsuite/gcc.dg/cpp/pragma-2.c
new file mode 100644
index 00000000000..18d540fe9e8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/pragma-2.c
@@ -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 } } */
+}