summaryrefslogtreecommitdiffstats
path: root/gcc/cppinit.c
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2000-11-28 21:13:35 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2000-11-28 21:13:35 +0000
commit9751c00e176f73ca4a921e9b9b15486d875da475 (patch)
treee48c58ce615d53fe8e02183447bad8c0843a2462 /gcc/cppinit.c
parentf23abae55e71b922f87e25034768ad92d2cefcff (diff)
downloadppe42-gcc-9751c00e176f73ca4a921e9b9b15486d875da475.tar.gz
ppe42-gcc-9751c00e176f73ca4a921e9b9b15486d875da475.zip
* c-lex.h (parse_in): Change parse_in to a cpp_reader *.
* c-decl.c (c_decode_option): Update to match. * c-lex.c (init_c_lex, yyparse): Update to match. * c-lang.c (lang_init_options): Use cpp_create_reader. * cppinit.c (cpp_init): Rename initialize. (cpp_reader_init): Rename cpp_create_reader. Create the reader. Initialize cpplib if appropriate. * cpplib.h (cpp_create_reader) New prototype. (cpp_init, cpp_reader_init): Delete prototypes. * cppmain.c (general_init, setup_callbacks): New functions. (main): Use them. * fix-header.c (scan_in): Change type to cpp_reader *. (read_scan_file): Update for new cpplib interface and scan_in type. * cp/decl.c (parse_in): Change to cpp_reader *. (lang_decode_option): Update. * cp/lex.c (lang_init_options): Use new cpplib interface. (init_cp_pragma, finish_parse, handle_pragma_implementation): Update. * cp/spew.c (read_token): Update. * objc/objc-act.c (lang_init_options): Update new cpplib interface. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37826 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r--gcc/cppinit.c68
1 files changed, 31 insertions, 37 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index daa8a87840d..39e1562c936 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -398,30 +398,6 @@ 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 ()
-{
-#ifdef HOST_EBCDIC
- /* 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 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 ();
- init_IStable ();
-
- cpp_init_completed = 1;
-}
-
/* Sets internal flags correctly for a given language, and defines
macros if necessary. */
static void
@@ -516,24 +492,40 @@ set_lang (pfile, lang)
}
}
+/* initialize initializes library global state. It might not need to
+ do anything depending on the platform and compiler. */
+
+static int initialized = 0;
+
+static void
+initialize ()
+{
+#ifdef HOST_EBCDIC
+ /* 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 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 ();
+ init_IStable ();
+
+ initialized = 1;
+}
+
/* Initialize a cpp_reader structure. */
-void
-cpp_reader_init (pfile, lang)
- cpp_reader *pfile;
+cpp_reader *
+cpp_create_reader (lang)
enum c_lang lang;
{
struct spec_nodes *s;
+ cpp_reader *pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
- memset ((char *) pfile, 0, sizeof (cpp_reader));
-
- /* 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 ();
- }
+ /* Initialise this instance of the library if it hasn't been already. */
+ if (! initialized)
+ initialize ();
CPP_OPTION (pfile, warn_import) = 1;
CPP_OPTION (pfile, discard_comments) = 1;
@@ -586,6 +578,8 @@ cpp_reader_init (pfile, lang)
s->n__CHAR_UNSIGNED__ = cpp_lookup (pfile, DSC("__CHAR_UNSIGNED__"));
s->n__VA_ARGS__ = cpp_lookup (pfile, DSC("__VA_ARGS__"));
s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC;
+
+ return pfile;
}
/* Free resources used by PFILE.
OpenPOWER on IntegriCloud