c-common.c: Include c-lex.h.

* c-common.c: Include c-lex.h.
	(c_common_lang_init): Change prototype.  Call init_c_lex and
	init_pragma from here.
	* c-common.h (c_common_lang_init): Change prototype.
	* c-decl.c (init_decl_processing): Rename.  Call c_parse_init.
	* c-lang.c (c_init): Change prototype.  Update.
	(c_init_options): Update.
	* c-lex.c (cpp_filename): Remove.
	(init_c_lex): Update.  Read the main file, and get the original
	file name.
	(yyparse): Finish the command line options.
	* c-parse.in (c_parse_init): Call init_reswords here.
	(init_parse): Remove.
	* c-tree.h (c_init_decl_processing): New.
	* cpphash.c (_cpp_init_hashtable): After initializing the hash
	table, populate it.
	* cppinit.c (read_original_filename, cpp_finish_options): New.
	(cpp_create_reader): New prototype. Defer hash table initialization.
	(cpp_start_read): Rename cpp_read_main_file.  Initialize the
	hash table.  Get the original filename.
	* cpplib.h (cpp_create_reader): Update.
	(cpp_start_read): Remove.
	(cpp_read_main_file, cpp_finish_options): New.
	* cppmain.c (main, do_preprocessing): Update.
	* langhooks.h (struct langhooks): Update init prototype.
	* toplev.c (general_init, parse_options_and_default_flags,
	process_options, lang_indpendent_init, lang_dependent_init,
	init_asm_output): New; perform the bulk of initialization.
	(compile_file): Move most of initialization to above functions.
	(debug_hooks): Initialize statically.
	(set_Wunused): Relocate.
	(toplev_main): Move most of initialization to other init functions.
	Have a clear logic flow.
	* tree.h (init_parse, init_decl_processing): Remove.
ada:
	* misc.c (gnat_init): Change prototype.  Include the
	functionality of the old init_parse and init_decl_processing.
	(gnat_init_decl_processing): New prototype.
	(init_parse): Remove.
	* utils.c (init_decl_processing): Rename gnat_init_decl_processing.
cp:	* cp-tree.h (init_reswords, cxx_init_decl_processing): New.
	(cxx_init): Update prototype.
	* decl.c (init_decl_processing): Rename.  Move null node init
	to its creation time.
	* lex.c (cxx_init_options): Update.
	(cxx_init): Combine with old init_parse; also call
	cxx_init_decl_processing.
f:	* com.c (ffecom_init_decl_processing): Renamed from
	init_decl_processing.
	(init_parse): Move contents to ffe_init.
	(ffe_init): Update prototype.
java:	* decl.c (init_decl_processing): Rename java_init_decl_processing.
	* java-tree.h: New prototype.
	* lang.c (java_init): Update prototype.  Combine with old init_parse.
objc:	* objc-act.c (objc_init): Update prototype, combine with old
	init_parse.
	(objc_init_options): Update.

From-SVN: r47046
This commit is contained in:
Neil Booth 2001-11-15 10:01:10 +00:00 committed by Neil Booth
parent 87bc7fa6aa
commit f5e99456f1
30 changed files with 1050 additions and 835 deletions

View File

@ -1,3 +1,45 @@
2001-11-15 Neil Booth <neil@daikokuya.demon.co.uk>
* c-common.c: Include c-lex.h.
(c_common_lang_init): Change prototype. Call init_c_lex and
init_pragma from here.
* c-common.h (c_common_lang_init): Change prototype.
* c-decl.c (init_decl_processing): Rename. Call c_parse_init.
* c-lang.c (c_init): Change prototype. Update.
(c_init_options): Update.
* c-lex.c (cpp_filename): Remove.
(init_c_lex): Update. Read the main file, and get the original
file name.
(yyparse): Finish the command line options.
* c-parse.in (c_parse_init): Call init_reswords here.
(init_parse): Remove.
* c-tree.h (c_init_decl_processing): New.
* cpphash.c (_cpp_init_hashtable): After initializing the hash
table, populate it.
* cppinit.c (read_original_filename, cpp_finish_options): New.
(cpp_create_reader): New prototype. Defer hash table initialization.
(cpp_start_read): Rename cpp_read_main_file. Initialize the
hash table. Get the original filename.
* cpplib.h (cpp_create_reader): Update.
(cpp_start_read): Remove.
(cpp_read_main_file, cpp_finish_options): New.
* cppmain.c (main, do_preprocessing): Update.
* langhooks.h (struct langhooks): Update init prototype.
* toplev.c (general_init, parse_options_and_default_flags,
process_options, lang_indpendent_init, lang_dependent_init,
init_asm_output): New; perform the bulk of initialization.
(compile_file): Move most of initialization to above functions.
(debug_hooks): Initialize statically.
(set_Wunused): Relocate.
(toplev_main): Move most of initialization to other init functions.
Have a clear logic flow.
* tree.h (init_parse, init_decl_processing): Remove.
objc:
* objc-act.c (objc_init): Update prototype, combine with old
init_parse.
(objc_init_options): Update.
2001-11-15 Andreas Jaeger <aj@suse.de>
* cfgrtl.c (purge_all_dead_edges): Use int as argument for

View File

@ -1,3 +1,11 @@
2001-11-15 Neil Booth <neil@daikokuya.demon.co.uk>
* misc.c (gnat_init): Change prototype. Include the
functionality of the old init_parse and init_decl_processing.
(gnat_init_decl_processing): New prototype.
(init_parse): Remove.
* utils.c (init_decl_processing): Rename gnat_init_decl_processing.
2001-11-09 Neil Booth <neil@daikokuya.demon.co.uk>
* misc.c (gnat_print_decl, gnat_print_type): Renamed.

View File

@ -6,7 +6,7 @@
* *
* C Implementation File *
* *
* $Revision: 1.10 $
* $Revision: 1.11 $
* *
* Copyright (C) 1992-2001 Free Software Foundation, Inc. *
* *
@ -109,12 +109,13 @@ const char *gnat_tree_code_name[] = {
};
#undef DEFTREECODE
static void gnat_init PARAMS ((void));
static const char *gnat_init PARAMS ((const char *));
static void gnat_init_options PARAMS ((void));
static int gnat_decode_option PARAMS ((int, char **));
static HOST_WIDE_INT gnat_get_alias_set PARAMS ((tree));
static void gnat_print_decl PARAMS ((FILE *, tree, int));
static void gnat_print_type PARAMS ((FILE *, tree, int));
extern void gnat_init_decl_processing PARAMS ((void));
/* Structure giving our language-specific hooks. */
@ -342,11 +343,38 @@ internal_error_function (msgid, ap)
/* Perform all the initialization steps that are language-specific. */
void
gnat_init ()
static const char *
gnat_init (filename)
const char *filename;
{
/* Performs whatever initialization steps needed by the language-dependent
lexical analyzer.
Define the additional tree codes here. This isn't the best place to put
it, but it's where g++ does it. */
lang_expand_expr = gnat_expand_expr;
lang_expand_constant = gnat_expand_constant;
memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
(char *) gnat_tree_code_type,
((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
* sizeof (char *)));
memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
(char *) gnat_tree_code_length,
((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
* sizeof (int)));
memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
(char *) gnat_tree_code_name,
((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
* sizeof (char *)));
gnat_init_decl_processing ();
/* Add the input filename as the last argument. */
gnat_argv [gnat_argc] = (char *) input_filename;
gnat_argv [gnat_argc] = (char *) filename;
gnat_argc++;
gnat_argv [gnat_argc] = 0;
@ -365,6 +393,8 @@ gnat_init ()
#if defined(MIPS_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO)
dwarf2out_set_demangle_name_func (convert_ada_name_to_qualified_name);
#endif
return filename;
}
/* If DECL has a cleanup, build and return that cleanup here.
@ -849,37 +879,6 @@ insert_code_for (gnat_node)
}
}
/* Performs whatever initialization steps needed by the language-dependent
lexical analyzer.
Define the additional tree codes here. This isn't the best place to put
it, but it's where g++ does it. */
const char *
init_parse (filename)
const char *filename;
{
lang_expand_expr = gnat_expand_expr;
lang_expand_constant = gnat_expand_constant;
memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
(char *) gnat_tree_code_type,
((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
* sizeof (char *)));
memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
(char *) gnat_tree_code_length,
((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
* sizeof (int)));
memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
(char *) gnat_tree_code_name,
((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
* sizeof (char *)));
return filename;
}
void
finish_parse ()
{

View File

@ -6,7 +6,7 @@
* *
* C Implementation File *
* *
* $Revision: 1.2 $
* $Revision: 1.3 $
* *
* Copyright (C) 1992-2001, Free Software Foundation, Inc. *
* *
@ -478,7 +478,7 @@ pushdecl (decl)
front end has been run. */
void
init_decl_processing ()
gnat_init_decl_processing ()
{
lineno = 0;

View File

@ -32,6 +32,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "c-common.h"
#include "tm_p.h"
#include "obstack.h"
#include "c-lex.h"
#include "cpplib.h"
#include "target.h"
cpp_reader *parse_in; /* Declared in c-lex.h. */
@ -3809,9 +3810,14 @@ static bool c_attrs_initialized = false;
static void c_init_attributes PARAMS ((void));
/* Do the parts of lang_init common to C and C++. */
void
c_common_lang_init ()
const char *
c_common_lang_init (filename)
const char *filename;
{
filename = init_c_lex (filename);
init_pragma ();
/* If still "unspecified", make it match -fbounded-pointers. */
if (flag_bounds_check < 0)
flag_bounds_check = flag_bounded_pointers;
@ -3831,6 +3837,8 @@ c_common_lang_init ()
if (!c_attrs_initialized)
c_init_attributes ();
return filename;
}
static void

View File

@ -540,7 +540,7 @@ extern void c_common_nodes_and_builtins PARAMS ((void));
extern tree build_va_arg PARAMS ((tree, tree));
extern void c_common_lang_init PARAMS ((void));
extern const char *c_common_lang_init PARAMS ((const char *));
extern HOST_WIDE_INT c_common_get_alias_set PARAMS ((tree));
extern bool c_promoting_integer_type_p PARAMS ((tree));
extern int self_promoting_args_p PARAMS ((tree));

View File

@ -2977,11 +2977,14 @@ mark_binding_level (arg)
Make definitions for built-in primitive functions. */
void
init_decl_processing ()
c_init_decl_processing ()
{
tree endlink;
tree ptr_ftype_void, ptr_ftype_ptr;
/* Adds some ggc roots, and reserved words for c-parse.in. */
c_parse_init ();
current_function_decl = NULL;
named_labels = NULL;
current_binding_level = NULL_BINDING_LEVEL;

View File

@ -44,7 +44,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
static int c_tree_printer PARAMS ((output_buffer *));
static int c_missing_noreturn_ok_p PARAMS ((tree));
static void c_init PARAMS ((void));
static const char *c_init PARAMS ((const char *));
static void c_init_options PARAMS ((void));
static void c_post_options PARAMS ((void));
static int c_disregard_inline_limits PARAMS ((tree));
@ -108,16 +108,21 @@ c_post_options ()
static void
c_init_options ()
{
parse_in = cpp_create_reader (ident_hash, CLK_GNUC89);
parse_in = cpp_create_reader (CLK_GNUC89);
/* Mark as "unspecified". */
flag_bounds_check = -1;
}
static void
c_init ()
static const char *
c_init (filename)
const char *filename;
{
c_common_lang_init ();
c_init_decl_processing ();
filename = c_common_lang_init (filename);
add_c_tree_codes ();
/* If still unspecified, make it match -std=c99
(allowing for -pedantic-errors). */
@ -138,10 +143,10 @@ c_init ()
lang_expand_decl_stmt = &c_expand_decl_stmt;
lang_missing_noreturn_ok_p = &c_missing_noreturn_ok_p;
c_parse_init ();
VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
ggc_add_tree_varray_root (&deferred_fns, 1);
return filename;
}
/* Used by c-lex.c, but only for objc. */

View File

@ -54,9 +54,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define GET_ENVIRONMENT(ENV_VALUE,ENV_NAME) ((ENV_VALUE) = getenv (ENV_NAME))
#endif
/* The input filename as understood by CPP, where "" represents stdin. */
static const char *cpp_filename;
/* The current line map. */
static const struct line_map *map;
@ -109,7 +106,7 @@ init_c_lex (filename)
struct cpp_callbacks *cb;
struct c_fileinfo *toplevel;
/* Set up filename timing. Must happen before cpp_start_read. */
/* Set up filename timing. Must happen before cpp_read_main_file. */
file_info_tree = splay_tree_new ((splay_tree_compare_fn)strcmp,
0,
(splay_tree_delete_value_fn)free);
@ -142,16 +139,13 @@ init_c_lex (filename)
cb->undef = cb_undef;
}
if (filename == 0 || !strcmp (filename, "-"))
filename = "stdin", cpp_filename = "";
else
cpp_filename = filename;
/* Start it at 0. */
lineno = 0;
return filename;
if (filename == NULL)
filename = "";
return cpp_read_main_file (parse_in, filename, ident_hash);
}
/* A thin wrapper around the real parser that initializes the
@ -160,8 +154,7 @@ init_c_lex (filename)
int
yyparse()
{
if (! cpp_start_read (parse_in, cpp_filename))
return 1; /* cpplib has emitted an error. */
cpp_finish_options (parse_in);
return yyparse_1();
}

View File

@ -304,6 +304,8 @@ static void init_reswords PARAMS ((void));
void
c_parse_init ()
{
init_reswords ();
ggc_add_tree_root (&declspec_stack, 1);
ggc_add_tree_root (&current_declspecs, 1);
ggc_add_tree_root (&prefix_attributes, 1);
@ -3528,17 +3530,6 @@ init_reswords ()
}
}
const char *
init_parse (filename)
const char *filename;
{
add_c_tree_codes ();
init_reswords ();
init_pragma ();
return init_c_lex (filename);
}
void
finish_parse ()
{

View File

@ -164,6 +164,7 @@ extern int yyparse_1 PARAMS ((void));
extern void gen_aux_info_record PARAMS ((tree, int, int, int));
/* in c-decl.c */
extern void c_init_decl_processing PARAMS ((void));
extern void c_print_identifier PARAMS ((FILE *, tree, int));
extern tree build_array_declarator PARAMS ((tree, tree, int, int));
extern tree build_enumerator PARAMS ((tree, tree));

View File

@ -1,3 +1,13 @@
2001-11-15 Neil Booth <neil@daikokuya.demon.co.uk>
* cp-tree.h (init_reswords, cxx_init_decl_processing): New.
(cxx_init): Update prototype.
* decl.c (init_decl_processing): Rename. Move null node init
to its creation time.
* lex.c (cxx_init_options): Update.
(cxx_init): Combine with old init_parse; also call
cxx_init_decl_processing.
2001-11-14 Richard Sandiford <rsandifo@redhat.com>
* decl.c (check_initializer): Try to complete the type of an

View File

@ -3458,6 +3458,9 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
: TYPE_NAME (NODE))
/* in lex.c */
extern void init_reswords PARAMS ((void));
/* Indexed by TREE_CODE, these tables give C-looking names to
operators represented by TREE_CODES. For example,
opname_tab[(int) MINUS_EXPR] == "-". */
@ -3569,6 +3572,7 @@ extern void adjust_clone_args PARAMS ((tree));
/* decl.c */
/* resume_binding_level */
extern void cxx_init_decl_processing PARAMS ((void));
extern int toplevel_bindings_p PARAMS ((void));
extern int namespace_bindings_p PARAMS ((void));
extern void keep_next_level PARAMS ((int));
@ -3882,7 +3886,7 @@ extern void yyerror PARAMS ((const char *));
extern void clear_inline_text_obstack PARAMS ((void));
extern void yyhook PARAMS ((int));
extern int cp_type_qual_from_rid PARAMS ((tree));
extern void cxx_init PARAMS ((void));
extern const char *cxx_init PARAMS ((const char *));
extern void cxx_finish PARAMS ((void));
extern void cxx_init_options PARAMS ((void));
extern void cxx_post_options PARAMS ((void));

View File

@ -6390,7 +6390,7 @@ initialize_predefined_identifiers ()
Make definitions for built-in primitive functions. */
void
init_decl_processing ()
cxx_init_decl_processing ()
{
tree void_ftype;
tree void_ftype_ptr;
@ -6523,8 +6523,6 @@ init_decl_processing ()
/* Indirecting an UNKNOWN_TYPE node yields an UNKNOWN_TYPE node. */
TREE_TYPE (unknown_type_node) = unknown_type_node;
TREE_TYPE (null_node) = type_for_size (POINTER_SIZE, 0);
/* Looking up TYPE_POINTER_TO and TYPE_REFERENCE_TO yield the same
result. */
TYPE_POINTER_TO (unknown_type_node) = unknown_type_node;

View File

@ -53,7 +53,6 @@ extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
static int interface_strcmp PARAMS ((const char *));
static int *init_cpp_parse PARAMS ((void));
static void init_reswords PARAMS ((void));
static void init_cp_pragma PARAMS ((void));
static tree parse_strconst_pragma PARAMS ((const char *, int));
@ -248,7 +247,7 @@ cxx_post_options ()
void
cxx_init_options ()
{
parse_in = cpp_create_reader (ident_hash, CLK_GNUCXX);
parse_in = cpp_create_reader (CLK_GNUCXX);
/* Default exceptions on. */
flag_exceptions = 1;
@ -262,15 +261,6 @@ cxx_init_options ()
diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
}
void
cxx_init ()
{
c_common_lang_init ();
if (flag_gnu_xref) GNU_xref_begin (input_filename);
init_repo (input_filename);
}
void
cxx_finish ()
{
@ -636,7 +626,7 @@ const short rid_to_yy[RID_MAX] =
/* RID_AT_IMPLEMENTATION */ 0
};
static void
void
init_reswords ()
{
unsigned int i;
@ -676,17 +666,18 @@ init_cp_pragma ()
handle_pragma_java_exceptions);
}
/* Initialize the C++ front end. This function is very sensitive to
the exact order that things are done here. It would be nice if the
initialization done by this routine were moved to its subroutines,
and the ordering dependencies clarified and reduced. */
const char *
init_parse (filename)
cxx_init (filename)
const char *filename;
{
decl_printable_name = lang_printable_name;
input_filename = "<internal>";
init_reswords ();
init_pragma ();
init_cp_pragma ();
init_spew ();
init_tree ();
init_cplus_expand ();
@ -726,17 +717,28 @@ init_parse (filename)
TREE_TYPE (enum_type_node) = enum_type_node;
ridpointers[(int) RID_ENUM] = enum_type_node;
cxx_init_decl_processing ();
/* Create the built-in __null node. Note that we can't yet call for
type_for_size here because integer_type_node and so forth are not
set up. Therefore, we don't set the type of these nodes until
init_decl_processing. */
cxx_init_decl_processing. */
null_node = build_int_2 (0, 0);
TREE_TYPE (null_node) = type_for_size (POINTER_SIZE, 0);
ridpointers[RID_NULL] = null_node;
token_count = init_cpp_parse ();
interface_unknown = 1;
return init_c_lex (filename);
filename = c_common_lang_init (filename);
init_cp_pragma ();
if (flag_gnu_xref)
GNU_xref_begin (filename);
init_repo (filename);
return filename;
}
void

View File

@ -173,7 +173,7 @@ static tree defarg_parm; /* current default parameter */
static tree defarg_depfns; /* list of unprocessed fns met during current fn. */
static tree defarg_fnsdone; /* list of fns with circular defargs */
/* Initialize obstacks. Called once, from init_parse. */
/* Initialize obstacks. Called once, from cxx_init. */
void
init_spew ()

View File

@ -53,6 +53,8 @@ _cpp_init_hashtable (pfile, table)
cpp_reader *pfile;
hash_table *table;
{
struct spec_nodes *s;
if (table == NULL)
{
pfile->our_hashtable = 1;
@ -63,6 +65,20 @@ _cpp_init_hashtable (pfile, table)
table->pfile = pfile;
pfile->hash_table = table;
/* Now we can initialize things that use the hash table. */
_cpp_init_directives (pfile);
_cpp_init_internal_pragmas (pfile);
s = &pfile->spec_nodes;
s->n_L = cpp_lookup (pfile, DSC("L"));
s->n_defined = cpp_lookup (pfile, DSC("defined"));
s->n_true = cpp_lookup (pfile, DSC("true"));
s->n_false = cpp_lookup (pfile, DSC("false"));
s->n__STRICT_ANSI__ = cpp_lookup (pfile, DSC("__STRICT_ANSI__"));
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;
}
/* Tear down the identifier hash table. */

View File

@ -63,7 +63,7 @@ struct pending_option
};
/* The `pending' structure accumulates all the options that are not
actually processed until we hit cpp_start_read. It consists of
actually processed until we hit cpp_read_main_file. It consists of
several lists, one for each type of option. We keep both head and
tail pointers for quick insertion. */
struct cpp_pending
@ -111,6 +111,7 @@ static void free_chain PARAMS ((struct pending_option *));
static void set_lang PARAMS ((cpp_reader *, enum c_lang));
static void init_dependency_output PARAMS ((cpp_reader *));
static void init_standard_includes PARAMS ((cpp_reader *));
static void read_original_filename PARAMS ((cpp_reader *));
static void new_pending_directive PARAMS ((struct cpp_pending *,
const char *,
cl_directive_handler));
@ -476,11 +477,9 @@ init_library ()
/* Initialize a cpp_reader structure. */
cpp_reader *
cpp_create_reader (table, lang)
hash_table *table;
cpp_create_reader (lang)
enum c_lang lang;
{
struct spec_nodes *s;
cpp_reader *pfile;
/* Initialise this instance of the library if it hasn't been already. */
@ -534,23 +533,7 @@ cpp_create_reader (table, lang)
/* Initialise the buffer obstack. */
gcc_obstack_init (&pfile->buffer_ob);
/* Initialise the hashtable. */
_cpp_init_hashtable (pfile, table);
_cpp_init_directives (pfile);
_cpp_init_includes (pfile);
_cpp_init_internal_pragmas (pfile);
/* Initialize the special nodes. */
s = &pfile->spec_nodes;
s->n_L = cpp_lookup (pfile, DSC("L"));
s->n_defined = cpp_lookup (pfile, DSC("defined"));
s->n_true = cpp_lookup (pfile, DSC("true"));
s->n_false = cpp_lookup (pfile, DSC("false"));
s->n__STRICT_ANSI__ = cpp_lookup (pfile, DSC("__STRICT_ANSI__"));
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;
}
@ -704,7 +687,7 @@ static const struct builtin builtin_array[] =
#define builtin_array_end \
builtin_array + sizeof(builtin_array)/sizeof(struct builtin)
/* Subroutine of cpp_start_read; reads the builtins table above and
/* Subroutine of cpp_read_main_file; reads the builtins table above and
enters the macros into the hash table. */
static void
init_builtins (pfile)
@ -916,14 +899,21 @@ free_chain (head)
}
}
/* This is called after options have been processed. Setup for
processing input from the file named FNAME, or stdin if it is the
empty string. Return 1 on success, 0 on failure. */
int
cpp_start_read (pfile, fname)
/* This is called after options have been parsed, and partially
processed. Setup for processing input from the file named FNAME,
or stdin if it is the empty string. Return the original filename
on success (e.g. foo.i->foo.c), or NULL on failure. */
const char *
cpp_read_main_file (pfile, fname, table)
cpp_reader *pfile;
const char *fname;
hash_table *table;
{
/* The front ends don't set up the hash table until they have
finished processing the command line options, so initializing the
hashtable is deferred until now. */
_cpp_init_hashtable (pfile, table);
/* Set up the include search path now. */
if (! CPP_OPTION (pfile, no_standard_includes))
init_standard_includes (pfile);
@ -948,16 +938,60 @@ cpp_start_read (pfile, fname)
/* Set the default target (if there is none already). */
deps_add_default_target (pfile->deps, fname);
/* Open the main input file. This must be done early, so we have a
buffer to stand on. */
/* Open the main input file. */
if (!_cpp_read_file (pfile, fname))
return 0;
return NULL;
/* Set this after cpp_post_options so the client can change the
option if it wishes, and after stacking the main file so we don't
trace the main file. */
pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
/* For foo.i, read the original filename foo.c now, for the benefit
of the front ends. */
if (CPP_OPTION (pfile, preprocessed))
read_original_filename (pfile);
return pfile->map->to_file;
}
/* For preprocessed files, if the first tokens are of the form # NUM.
handle the directive so we know the original file name. This will
generate file_change callbacks, which the front ends must handle
appropriately given their state of initialization. */
static void
read_original_filename (pfile)
cpp_reader *pfile;
{
const cpp_token *token, *token1;
/* Lex ahead; if the first tokens are of the form # NUM, then
process the directive, otherwise back up. */
token = _cpp_lex_direct (pfile);
if (token->type == CPP_HASH)
{
token1 = _cpp_lex_direct (pfile);
_cpp_backup_tokens (pfile, 1);
/* If it's a #line directive, handle it. */
if (token1->type == CPP_NUMBER)
{
_cpp_handle_directive (pfile, token->flags & PREV_WHITE);
return;
}
}
/* Backup as if nothing happened. */
_cpp_backup_tokens (pfile, 1);
}
/* Handle pending command line options: -D, -U, -A, -imacros and
-include. This should be called after debugging has been properly
set up in the front ends. */
void
cpp_finish_options (pfile)
cpp_reader *pfile;
{
/* Install builtins and process command line macros etc. in the order
they appeared, but only if not already preprocessed. */
if (! CPP_OPTION (pfile, preprocessed))
@ -986,8 +1020,6 @@ cpp_start_read (pfile, fname)
free_chain (CPP_OPTION (pfile, pending)->directive_head);
_cpp_push_next_buffer (pfile);
return 1;
}
/* Called to push the next buffer on the stack given by -include. If

View File

@ -451,16 +451,8 @@ struct cpp_hashnode
} value;
};
/* Call this first to get a handle to pass to other functions. If you
want cpplib to manage its own hashtable, pass in a NULL pointer.
Or you can pass in an initialised hash table that cpplib will use;
this technique is used by the C front ends. */
extern cpp_reader *cpp_create_reader PARAMS ((struct ht *,
enum c_lang));
/* Call this to release the handle. Any use of the handle after this
function returns is invalid. Returns cpp_errors (pfile). */
extern int cpp_destroy PARAMS ((cpp_reader *));
/* Call this first to get a handle to pass to other functions. */
extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
/* Call these to get pointers to the options and callback structures
for a given reader. These pointers are good until you call
@ -476,13 +468,39 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *));
return value is the number of arguments used. If
cpp_handle_options returns without using all arguments, it couldn't
understand the next switch. When there are no switches left, you
must call cpp_post_options before calling cpp_start_read. Only
must call cpp_post_options before calling cpp_read_main_file. Only
after cpp_post_options are the contents of the cpp_options
structure reliable. */
structure reliable. Options processing is not completed until you
call cpp_finish_options. */
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
extern void cpp_post_options PARAMS ((cpp_reader *));
/* This function reads the file, but does not start preprocessing. It
returns the name of the original file; this is the same as the
input file, except for preprocessed input. This will generate at
least one file change callback, and possibly a line change callback
too. If there was an error opening the file, it returns NULL.
If you want cpplib to manage its own hashtable, pass in a NULL
pointer. Otherise you should pass in an initialised hash table
that cpplib will share; this technique is used by the C front
ends. */
extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *,
struct ht *));
/* Deferred handling of command line options that can generate debug
callbacks, such as -D and -imacros. Call this after
cpp_read_main_file. The front ends need this separation so they
can initialize debug output with the original file name, returned
from cpp_read_main_file, before they get debug callbacks. */
extern void cpp_finish_options PARAMS ((cpp_reader *));
/* Call this to release the handle at the end of preprocessing. Any
use of the handle after this function returns is invalid. Returns
cpp_errors (pfile). */
extern int cpp_destroy PARAMS ((cpp_reader *));
/* Error count. */
extern unsigned int cpp_errors PARAMS ((cpp_reader *));
@ -495,7 +513,6 @@ extern void cpp_register_pragma PARAMS ((cpp_reader *,
const char *, const char *,
void (*) PARAMS ((cpp_reader *))));
extern int cpp_start_read PARAMS ((cpp_reader *, const char *));
extern void cpp_finish PARAMS ((cpp_reader *));
extern int cpp_avoid_paste PARAMS ((cpp_reader *, const cpp_token *,
const cpp_token *));

View File

@ -77,7 +77,7 @@ main (argc, argv)
general_init (argv[0]);
/* Contruct a reader with default language GNU C89. */
pfile = cpp_create_reader (NULL, CLK_GNUC89);
pfile = cpp_create_reader (CLK_GNUC89);
options = cpp_get_options (pfile);
do_preprocessing (argc, argv);
@ -117,10 +117,12 @@ do_preprocessing (argc, argv)
return;
if (argi < argc)
cpp_fatal (pfile, "Invalid option %s", argv[argi]);
else
cpp_post_options (pfile);
{
cpp_fatal (pfile, "Invalid option %s", argv[argi]);
return;
}
cpp_post_options (pfile);
if (CPP_FATAL_ERRORS (pfile))
return;
@ -156,8 +158,10 @@ do_preprocessing (argc, argv)
setup_callbacks ();
if (cpp_start_read (pfile, options->in_fname))
if (cpp_read_main_file (pfile, options->in_fname, NULL))
{
cpp_finish_options (pfile);
/* A successful cpp_start_read guarantees that we can call
cpp_scan_nooutput or cpp_get_token next. */
if (options->no_output)

View File

@ -1,3 +1,10 @@
Thu Nov 15 10:06:38 2001 Neil Booth <neil@daikokuya.demon.co.uk>
* com.c (ffecom_init_decl_processing): Renamed from
init_decl_processing.
(init_parse): Move contents to ffe_init.
(ffe_init): Update prototype.
2001-11-14 Toon Moene <toon@moene.indiv.nluug.nl>
* g77.texi: Update to use `@command', `@option.

View File

@ -260,6 +260,7 @@ struct _ffecom_concat_list_
/* Static functions (internal). */
static void ffecom_init_decl_processing PARAMS ((void));
static tree ffecom_arglist_expr_ (const char *argstring, ffebld args);
static tree ffecom_widest_expr_type_ (ffebld list);
static bool ffecom_overlap_ (tree dest_decl, tree dest_offset,
@ -14120,8 +14121,8 @@ mark_binding_level (void *arg)
}
}
void
init_decl_processing ()
static void
ffecom_init_decl_processing ()
{
static tree *const tree_roots[] = {
&current_function_decl,
@ -14188,31 +14189,6 @@ init_decl_processing ()
ffe_init_0 ();
}
const char *
init_parse (filename)
const char *filename;
{
/* Open input file. */
if (filename == 0 || !strcmp (filename, "-"))
{
finput = stdin;
filename = "stdin";
}
else
finput = fopen (filename, "r");
if (finput == 0)
fatal_io_error ("can't open %s", filename);
#ifdef IO_BUFFER_SIZE
setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
#endif
decl_printable_name = lang_printable_name;
print_error_function = lang_print_error_function;
return filename;
}
void
finish_parse ()
{
@ -14253,7 +14229,7 @@ insert_block (block)
}
/* Each front end provides its own. */
static void ffe_init PARAMS ((void));
static const char *ffe_init PARAMS ((const char *));
static void ffe_finish PARAMS ((void));
static void ffe_init_options PARAMS ((void));
static void ffe_print_identifier PARAMS ((FILE *, tree, int));
@ -14281,6 +14257,45 @@ static void ffe_print_identifier PARAMS ((FILE *, tree, int));
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
static const char *
ffe_init (filename)
const char *filename;
{
/* Open input file. */
if (filename == 0 || !strcmp (filename, "-"))
{
finput = stdin;
filename = "stdin";
}
else
finput = fopen (filename, "r");
if (finput == 0)
fatal_io_error ("can't open %s", filename);
#ifdef IO_BUFFER_SIZE
setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
#endif
ffecom_init_decl_processing ();
decl_printable_name = lang_printable_name;
print_error_function = lang_print_error_function;
/* If the file is output from cpp, it should contain a first line
`# 1 "real-filename"', and the current design of gcc (toplev.c
in particular and the way it sets up information relied on by
INCLUDE) requires that we read this now, and store the
"real-filename" info in master_input_filename. Ask the lexer
to try doing this. */
ffelex_hash_kludge (finput);
/* FIXME: The ffelex_hash_kludge code needs to be cleaned up to
return the new file name. */
if (main_input_filename)
filename = main_input_filename;
return filename;
}
static void
ffe_finish ()
{
@ -14302,18 +14317,6 @@ ffe_init_options ()
flag_complex_divide_method = 1;
}
static void
ffe_init ()
{
/* If the file is output from cpp, it should contain a first line
`# 1 "real-filename"', and the current design of gcc (toplev.c
in particular and the way it sets up information relied on by
INCLUDE) requires that we read this now, and store the
"real-filename" info in master_input_filename. Ask the lexer
to try doing this. */
ffelex_hash_kludge (finput);
}
int
mark_addressable (exp)
tree exp;

View File

@ -1,3 +1,9 @@
2001-11-15 Neil Booth <neil@daikokuya.demon.co.uk>
* decl.c (init_decl_processing): Rename java_init_decl_processing.
* java-tree.h: New prototype.
* lang.c (java_init): Update prototype. Combine with old init_parse.
2001-11-13 Tom Tromey <tromey@redhat.com>
* gjavah.c (method_signature): New global.

View File

@ -398,7 +398,7 @@ create_primitive_vtable (name)
}
void
init_decl_processing ()
java_init_decl_processing ()
{
register tree endlink;
tree field = NULL_TREE;

View File

@ -1031,6 +1031,7 @@ extern tree ident_subst PARAMS ((const char*, int,
const char*, int, int, const char*));
extern tree identifier_subst PARAMS ((const tree,
const char *, int, int, const char *));
extern void java_init_decl_processing PARAMS ((void));
extern tree build_java_signature PARAMS ((tree));
extern tree build_java_argument_signature PARAMS ((tree));
extern void set_java_signature PARAMS ((tree, tree));

View File

@ -48,7 +48,7 @@ struct string_option
int on_value;
};
static void java_init PARAMS ((void));
static const char *java_init PARAMS ((const char *));
static void java_init_options PARAMS ((void));
static int java_decode_option PARAMS ((int, char **));
static void put_decl_string PARAMS ((const char *, int));
@ -186,7 +186,7 @@ lang_W_options[] =
JCF *current_jcf;
/* Variable controlling how dependency tracking is enabled in
init_parse. */
java_init. */
static int dependency_tracking = 0;
/* Flag values for DEPENDENCY_TRACKING. */
@ -411,10 +411,15 @@ java_decode_option (argc, argv)
/* Global open file. */
FILE *finput;
const char *
init_parse (filename)
static const char *
java_init (filename)
const char *filename;
{
#if 0
extern int flag_minimal_debug;
flag_minimal_debug = 0;
#endif
/* Open input file. */
if (filename == 0 || !strcmp (filename, "-"))
@ -476,6 +481,30 @@ init_parse (filename)
}
}
jcf_path_init ();
jcf_path_seal (version_flag);
decl_printable_name = lang_printable_name;
print_error_function = lang_print_error;
lang_expand_expr = java_lang_expand_expr;
/* Append to Gcc tree node definition arrays */
memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
java_tree_code_type,
(int)LAST_JAVA_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
java_tree_code_length,
(LAST_JAVA_TREE_CODE -
(int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
java_tree_code_name,
(LAST_JAVA_TREE_CODE -
(int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
java_init_decl_processing ();
using_eh_for_cleanups ();
return filename;
}
@ -677,38 +706,6 @@ lang_print_error (context, file)
}
static void
java_init ()
{
#if 0
extern int flag_minimal_debug;
flag_minimal_debug = 0;
#endif
jcf_path_init ();
jcf_path_seal (version_flag);
decl_printable_name = lang_printable_name;
print_error_function = lang_print_error;
lang_expand_expr = java_lang_expand_expr;
/* Append to Gcc tree node definition arrays */
memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
java_tree_code_type,
(int)LAST_JAVA_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
java_tree_code_length,
(LAST_JAVA_TREE_CODE -
(int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
java_tree_code_name,
(LAST_JAVA_TREE_CODE -
(int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
using_eh_for_cleanups ();
}
/* This doesn't do anything on purpose. It's used to satisfy the
print_error_function hook we don't print error messages with bogus
function prototypes. */

View File

@ -59,8 +59,10 @@ struct lang_hooks
identifier nodes long enough for the language-specific slots. */
size_t identifier_size;
/* Called first, to initialize the front end. */
void (*init) PARAMS ((void));
/* Called after options parsing, to initialize the front end. The
main input filename is passed, which may be NULL; the front end
should return the original filename (e.g. foo.i -> foo.c). */
const char * (*init) PARAMS ((const char *));
/* Called last, as a finalizer. */
void (*finish) PARAMS ((void));
@ -81,7 +83,7 @@ struct lang_hooks
done for this option. */
int (*decode_option) PARAMS ((int, char **));
/* Called when all command line options have been processed. */
/* Called when all command line options have been parsed. */
void (*post_options) PARAMS ((void));
/* Called to obtain the alias set to be used for an expression or type.

View File

@ -157,7 +157,7 @@ char *util_firstobj;
static void init_objc PARAMS ((void));
static void finish_objc PARAMS ((void));
static void objc_init PARAMS ((void));
static const char *objc_init PARAMS ((const char *));
static void objc_init_options PARAMS ((void));
static int objc_decode_option PARAMS ((int, char **));
static void objc_post_options PARAMS ((void));
@ -545,20 +545,25 @@ generate_struct_by_value_array ()
static void
objc_init_options ()
{
parse_in = cpp_create_reader (ident_hash, CLK_OBJC);
parse_in = cpp_create_reader (CLK_OBJC);
c_language = clk_objective_c;
}
static void
objc_init ()
static const char *
objc_init (filename)
const char *filename;
{
c_init_decl_processing ();
filename = c_common_lang_init (filename);
add_c_tree_codes ();
/* Force the line number back to 0; check_newline will have
raised it to 1, which will make the builtin functions appear
not to be built in. */
lineno = 0;
c_common_lang_init ();
/* If gen_declaration desired, open the output file. */
if (flag_gen_declaration)
{
@ -595,10 +600,11 @@ objc_init ()
generate_struct_by_value_array ();
objc_act_parse_init ();
c_parse_init ();
VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
ggc_add_tree_varray_root (&deferred_fns, 1);
return filename;
}
/* Register a function tree, so that its optimization and conversion

File diff suppressed because it is too large Load Diff

View File

@ -2647,7 +2647,6 @@ extern const char *(*decl_printable_name) PARAMS ((tree, int));
extern void (*incomplete_decl_finalize_hook) PARAMS ((tree));
extern const char *init_parse PARAMS ((const char *));
extern void finish_parse PARAMS ((void));
/* Declare a predefined function. Return the declaration. This function is
@ -2775,9 +2774,6 @@ extern tree fold_builtin PARAMS ((tree));
/* The language front-end must define these functions. */
/* Function of no arguments for initializing the symbol table. */
extern void init_decl_processing PARAMS ((void));
/* Function to replace the DECL_LANG_SPECIFIC field of a DECL with a copy. */
extern void copy_lang_decl PARAMS ((tree));