aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2000-08-20 21:36:18 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-08-20 21:36:18 +0000
commit3cb553b4684a17ca436be66895be0aeaee83644f (patch)
treed81b589e39b9cc29d2ac00a4c083ae74ae5241d1 /gcc/cppinit.c
parent53e687fabb8208f715fd30172c48430eef4e2255 (diff)
downloadgcc-3cb553b4684a17ca436be66895be0aeaee83644f.zip
gcc-3cb553b4684a17ca436be66895be0aeaee83644f.tar.gz
gcc-3cb553b4684a17ca436be66895be0aeaee83644f.tar.bz2
[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
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index c8a06e8..f1ed54f 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);