aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-11-15 10:01:10 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-11-15 10:01:10 +0000
commitf5e99456f19b80978984f781e1d847b90d09b30a (patch)
treecac90266aeb52525edc15fddc73e9428ce8a8556 /gcc
parent87bc7fa6aab909eb842be0800e0284b0daa3de70 (diff)
downloadgcc-f5e99456f19b80978984f781e1d847b90d09b30a.zip
gcc-f5e99456f19b80978984f781e1d847b90d09b30a.tar.gz
gcc-f5e99456f19b80978984f781e1d847b90d09b30a.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog42
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/misc.c71
-rw-r--r--gcc/ada/utils.c4
-rw-r--r--gcc/c-common.c12
-rw-r--r--gcc/c-common.h2
-rw-r--r--gcc/c-decl.c5
-rw-r--r--gcc/c-lang.c19
-rw-r--r--gcc/c-lex.c19
-rw-r--r--gcc/c-parse.in13
-rw-r--r--gcc/c-tree.h1
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/cp-tree.h6
-rw-r--r--gcc/cp/decl.c4
-rw-r--r--gcc/cp/lex.c38
-rw-r--r--gcc/cp/spew.c2
-rw-r--r--gcc/cpphash.c16
-rw-r--r--gcc/cppinit.c94
-rw-r--r--gcc/cpplib.h43
-rw-r--r--gcc/cppmain.c14
-rw-r--r--gcc/f/ChangeLog7
-rw-r--r--gcc/f/com.c83
-rw-r--r--gcc/java/ChangeLog6
-rw-r--r--gcc/java/decl.c2
-rw-r--r--gcc/java/java-tree.h1
-rw-r--r--gcc/java/lang.c69
-rw-r--r--gcc/langhooks.h8
-rw-r--r--gcc/objc/objc-act.c20
-rw-r--r--gcc/toplev.c882
-rw-r--r--gcc/tree.h4
30 files changed, 860 insertions, 645 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4026e7e..e8a3715 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index dafcd0e..b2aecad 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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.
diff --git a/gcc/ada/misc.c b/gcc/ada/misc.c
index 3a33494..0ea1339 100644
--- a/gcc/ada/misc.c
+++ b/gcc/ada/misc.c
@@ -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 ()
{
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c
index a190009..1b4f805 100644
--- a/gcc/ada/utils.c
+++ b/gcc/ada/utils.c
@@ -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;
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 312060d..26a7f9e 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 459976d..76c59aa 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -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));
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index f2289fe..f240aac 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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;
diff --git a/gcc/c-lang.c b/gcc/c-lang.c
index b75ce51..72d2536 100644
--- a/gcc/c-lang.c
+++ b/gcc/c-lang.c
@@ -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. */
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index ca59266..ea824ec 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -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();
}
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 41208c3..14a0253 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -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 ()
{
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index 19e5b03..865e734 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -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));
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5717f57..7c856b4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index d4f3341..af8f396 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 39708f9..5098b57 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index f5fdc0f..21e3594 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -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;
@@ -263,15 +262,6 @@ cxx_init_options ()
}
void
-cxx_init ()
-{
- c_common_lang_init ();
-
- if (flag_gnu_xref) GNU_xref_begin (input_filename);
- init_repo (input_filename);
-}
-
-void
cxx_finish ()
{
if (flag_gnu_xref)
@@ -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
diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c
index 9e4f13b..68ad412 100644
--- a/gcc/cp/spew.c
+++ b/gcc/cp/spew.c
@@ -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 ()
diff --git a/gcc/cpphash.c b/gcc/cpphash.c
index def5171..1bb1275 100644
--- a/gcc/cpphash.c
+++ b/gcc/cpphash.c
@@ -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. */
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index d17dcac01..ba9f122 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -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
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 2ccac62..e9002fb 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -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 *));
diff --git a/gcc/cppmain.c b/gcc/cppmain.c
index 02dfdb7..923c716 100644
--- a/gcc/cppmain.c
+++ b/gcc/cppmain.c
@@ -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)
diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog
index 16f63a6..586b6e3 100644
--- a/gcc/f/ChangeLog
+++ b/gcc/f/ChangeLog
@@ -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.
diff --git a/gcc/f/com.c b/gcc/f/com.c
index ae4201d..fb7bd4f 100644
--- a/gcc/f/com.c
+++ b/gcc/f/com.c
@@ -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;
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 614198b..0826451 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -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.
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index 86b5610..2577122 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -398,7 +398,7 @@ create_primitive_vtable (name)
}
void
-init_decl_processing ()
+java_init_decl_processing ()
{
register tree endlink;
tree field = NULL_TREE;
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index d9417b4..e2e8cf3 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -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));
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index 9ba1849..977ed17 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -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. */
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index 466b7ae..9823dc8 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -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.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 2d34588..3dd0a33 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -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
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 5825c55..3db578f 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -161,13 +161,20 @@ extern char **environ;
extern int size_directive_output;
extern tree last_assemble_variable_decl;
+static void general_init PARAMS ((char *));
+static void parse_options_and_default_flags PARAMS ((int, char **));
+static void process_options PARAMS ((void));
+static void lang_independent_init PARAMS ((void));
+static void lang_dependent_init PARAMS ((const char *));
+static void init_asm_output PARAMS ((const char *));
+
static void set_target_switch PARAMS ((const char *));
static const char *decl_name PARAMS ((tree, int));
static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
static void set_float_handler PARAMS ((jmp_buf));
-static void compile_file PARAMS ((const char *));
+static void compile_file PARAMS ((void));
static void display_help PARAMS ((void));
static void display_target_options PARAMS ((void));
@@ -232,7 +239,7 @@ extern int target_flags;
/* Debug hooks - dependent upon command line options. */
-struct gcc_debug_hooks *debug_hooks;
+struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
/* Describes a dump file. */
@@ -1438,23 +1445,6 @@ int warn_unused_parameter;
int warn_unused_variable;
int warn_unused_value;
-void
-set_Wunused (setting)
- int setting;
-{
- warn_unused_function = setting;
- warn_unused_label = setting;
- /* Unused function parameter warnings are reported when either ``-W
- -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
- -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
- if (!setting)
- warn_unused_parameter = 0;
- else if (!warn_unused_parameter)
- warn_unused_parameter = -1;
- warn_unused_variable = setting;
- warn_unused_value = setting;
-}
-
/* Nonzero to warn about code which is never reached. */
int warn_notreached;
@@ -1556,6 +1546,23 @@ lang_independent_options W_options[] =
N_("Warn about functions which might be candidates for attribute noreturn") }
};
+void
+set_Wunused (setting)
+ int setting;
+{
+ warn_unused_function = setting;
+ warn_unused_label = setting;
+ /* Unused function parameter warnings are reported when either ``-W
+ -Wunused'' or ``-Wunused-parameter'' is specified. Differentiate
+ -Wunused by setting WARN_UNUSED_PARAMETER to -1. */
+ if (!setting)
+ warn_unused_parameter = 0;
+ else if (!warn_unused_parameter)
+ warn_unused_parameter = -1;
+ warn_unused_variable = setting;
+ warn_unused_value = setting;
+}
+
/* The following routines are useful in setting all the flags that
-ffast-math and -fno-fast-math imply. */
@@ -2132,203 +2139,14 @@ pop_srcloc ()
lineno = input_file_stack->line;
}
-/* Compile an entire translation unit, whose primary source file is
- named NAME. Write a file of assembly output and various debugging
- dumps. */
+/* Compile an entire translation unit. Write a file of assembly
+ output and various debugging dumps. */
static void
-compile_file (name)
- const char *name;
+compile_file ()
{
tree globals;
- int name_specified = name != 0;
-
- if (dump_base_name == 0)
- dump_base_name = name ? name : "gccdump";
-
- if (! quiet_flag)
- time_report = 1;
-
- /* Start timing total execution time. */
-
- init_timevar ();
- timevar_start (TV_TOTAL);
-
- /* Open assembly code output file. Do this even if -fsyntax-only is on,
- because then the driver will have provided the name of a temporary
- file or bit bucket for us. */
-
- if (! name_specified && asm_file_name == 0)
- asm_out_file = stdout;
- else
- {
- if (asm_file_name == 0)
- {
- int len = strlen (dump_base_name);
- char *dumpname = (char *) xmalloc (len + 6);
- memcpy (dumpname, dump_base_name, len + 1);
- strip_off_ending (dumpname, len);
- strcat (dumpname, ".s");
- asm_file_name = dumpname;
- }
- if (!strcmp (asm_file_name, "-"))
- asm_out_file = stdout;
- else
- asm_out_file = fopen (asm_file_name, "w");
- if (asm_out_file == 0)
- fatal_io_error ("can't open %s for writing", asm_file_name);
- }
-
- /* Initialize data in various passes. */
-
- init_obstacks ();
- name = init_parse (name);
- init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
- || debug_info_level == DINFO_LEVEL_VERBOSE
- || flag_test_coverage
- || warn_notreached);
- init_regs ();
- init_alias_once ();
- init_decl_processing ();
- init_eh ();
- init_optabs ();
- init_stmt ();
- init_loop ();
- init_reload ();
- init_function_once ();
- init_stor_layout_once ();
- init_varasm_once ();
- init_EXPR_INSN_LIST_cache ();
-
- /* The following initialization functions need to generate rtl, so
- provide a dummy function context for them. */
- init_dummy_function_start ();
- init_expmed ();
- init_expr_once ();
- if (flag_caller_saves)
- init_caller_save ();
- expand_dummy_function_end ();
-
- /* If auxiliary info generation is desired, open the output file.
- This goes in the same directory as the source file--unlike
- all the other output files. */
- if (flag_gen_aux_info)
- {
- aux_info_file = fopen (aux_info_file_name, "w");
- if (aux_info_file == 0)
- fatal_io_error ("can't open %s", aux_info_file_name);
- }
-
-#ifdef IO_BUFFER_SIZE
- setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
- _IOFBF, IO_BUFFER_SIZE);
-#endif
-
- if (name != 0)
- name = ggc_strdup (name);
-
- input_filename = name;
-
- /* Put an entry on the input file stack for the main input file. */
- push_srcloc (input_filename, 0);
-
- /* Perform language-specific initialization.
- This may set main_input_filename. */
- (*lang_hooks.init) ();
-
- /* If the input doesn't start with a #line, use the input name
- as the official input file name. */
- if (main_input_filename == 0)
- main_input_filename = name;
-
- if (flag_syntax_only)
- {
- write_symbols = NO_DEBUG;
- profile_flag = 0;
- profile_block_flag = 0;
- }
- else
- {
-#ifdef ASM_FILE_START
- ASM_FILE_START (asm_out_file);
-#endif
-
-#ifdef ASM_COMMENT_START
- if (flag_verbose_asm)
- {
- /* Print the list of options in effect. */
- print_version (asm_out_file, ASM_COMMENT_START);
- print_switch_values (asm_out_file, 0, MAX_LINE,
- ASM_COMMENT_START, " ", "\n");
- /* Add a blank line here so it appears in assembler output but not
- screen output. */
- fprintf (asm_out_file, "\n");
- }
-#endif
- } /* ! flag_syntax_only */
-
- /* Set up the debug hooks based on write_symbols. Default to doing
- nothing. */
- debug_hooks = &do_nothing_debug_hooks;
-#if defined(DBX_DEBUGGING_INFO)
- if (write_symbols == DBX_DEBUG)
- debug_hooks = &dbx_debug_hooks;
-#endif
-#if defined(XCOFF_DEBUGGING_INFO)
- if (write_symbols == XCOFF_DEBUG)
- debug_hooks = &xcoff_debug_hooks;
-#endif
-#ifdef SDB_DEBUGGING_INFO
- if (write_symbols == SDB_DEBUG)
- debug_hooks = &sdb_debug_hooks;
-#endif
-#ifdef DWARF_DEBUGGING_INFO
- if (write_symbols == DWARF_DEBUG)
- debug_hooks = &dwarf_debug_hooks;
-#endif
-#ifdef DWARF2_DEBUGGING_INFO
- if (write_symbols == DWARF2_DEBUG)
- debug_hooks = &dwarf2_debug_hooks;
-#endif
-
- if (! targetm.have_named_sections)
- {
- if (flag_function_sections)
- {
- warning ("-ffunction-sections not supported for this target.");
- flag_function_sections = 0;
- }
- if (flag_data_sections)
- {
- warning ("-fdata-sections not supported for this target.");
- flag_data_sections = 0;
- }
- }
-
- if (flag_function_sections
- && (profile_flag || profile_block_flag))
- {
- warning ("-ffunction-sections disabled; it makes profiling impossible.");
- flag_function_sections = 0;
- }
-
-#ifndef OBJECT_FORMAT_ELF
- if (flag_function_sections && write_symbols != NO_DEBUG)
- warning ("-ffunction-sections may affect debugging on some targets.");
-#endif
-
- /* If dbx symbol table desired, initialize writing it
- and output the predefined types. */
- timevar_push (TV_SYMOUT);
-#ifdef DWARF2_UNWIND_INFO
- if (dwarf2out_do_frame ())
- dwarf2out_frame_init ();
-#endif
-
- (*debug_hooks->init) (main_input_filename);
- timevar_pop (TV_SYMOUT);
-
/* Initialize yet another pass. */
init_final (main_input_filename);
@@ -2491,13 +2309,6 @@ compile_file (name)
/* Free up memory for the benefit of leak detectors. */
free_reg_info ();
-
- /* Stop timing total execution time. */
- timevar_stop (TV_TOTAL);
-
- /* Print the times. */
-
- timevar_print (stderr);
}
/* This is called from various places for FUNCTION_DECL, VAR_DECL,
@@ -4591,27 +4402,241 @@ independent_decode_option (argc, argv)
return 1;
}
-/* Entry point of cc1, cc1plus, jc1, f771, etc.
- Decode command args, then call compile_file.
- Exit code is FATAL_EXIT_CODE if can't open files or if there were
- any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
+/* Decode -m switches. */
+/* Decode the switch -mNAME. */
- It is not safe to call this function more than once. */
+static void
+set_target_switch (name)
+ const char *name;
+{
+ size_t j;
+ int valid_target_option = 0;
-int
-toplev_main (argc, argv)
- int argc;
- char **argv;
+ for (j = 0; j < ARRAY_SIZE (target_switches); j++)
+ if (!strcmp (target_switches[j].name, name))
+ {
+ if (target_switches[j].value < 0)
+ target_flags &= ~-target_switches[j].value;
+ else
+ target_flags |= target_switches[j].value;
+ valid_target_option = 1;
+ }
+
+#ifdef TARGET_OPTIONS
+ if (!valid_target_option)
+ for (j = 0; j < ARRAY_SIZE (target_options); j++)
+ {
+ int len = strlen (target_options[j].prefix);
+ if (!strncmp (target_options[j].prefix, name, len))
+ {
+ *target_options[j].variable = name + len;
+ valid_target_option = 1;
+ }
+ }
+#endif
+
+ if (!valid_target_option)
+ error ("Invalid option `%s'", name);
+}
+
+/* Print version information to FILE.
+ Each line begins with INDENT (for the case where FILE is the
+ assembler output file). */
+
+static void
+print_version (file, indent)
+ FILE *file;
+ const char *indent;
{
- int i;
- char *p;
+#ifndef __VERSION__
+#define __VERSION__ "[?]"
+#endif
+ fnotice (file,
+#ifdef __GNUC__
+ "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
+#else
+ "%s%s%s version %s (%s) compiled by CC.\n"
+#endif
+ , indent, *indent != 0 ? " " : "",
+ lang_hooks.name, version_string, TARGET_NAME,
+ indent, __VERSION__);
+}
- /* save in case md file wants to emit args as a comment. */
- save_argc = argc;
- save_argv = argv;
+/* Print an option value and return the adjusted position in the line.
+ ??? We don't handle error returns from fprintf (disk full); presumably
+ other code will catch a disk full though. */
+
+static int
+print_single_switch (file, pos, max, indent, sep, term, type, name)
+ FILE *file;
+ int pos, max;
+ const char *indent, *sep, *term, *type, *name;
+{
+ /* The ultrix fprintf returns 0 on success, so compute the result we want
+ here since we need it for the following test. */
+ int len = strlen (sep) + strlen (type) + strlen (name);
+
+ if (pos != 0
+ && pos + len > max)
+ {
+ fprintf (file, "%s", term);
+ pos = 0;
+ }
+ if (pos == 0)
+ {
+ fprintf (file, "%s", indent);
+ pos = strlen (indent);
+ }
+ fprintf (file, "%s%s%s", sep, type, name);
+ pos += len;
+ return pos;
+}
+
+/* Print active target switches to FILE.
+ POS is the current cursor position and MAX is the size of a "line".
+ Each line begins with INDENT and ends with TERM.
+ Each switch is separated from the next by SEP. */
+
+static void
+print_switch_values (file, pos, max, indent, sep, term)
+ FILE *file;
+ int pos, max;
+ const char *indent, *sep, *term;
+{
+ size_t j;
+ char **p;
+
+ /* Print the options as passed. */
+
+ pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
+ _("options passed: "), "");
+
+ for (p = &save_argv[1]; *p != NULL; p++)
+ if (**p == '-')
+ {
+ /* Ignore these. */
+ if (strcmp (*p, "-o") == 0)
+ {
+ if (p[1] != NULL)
+ p++;
+ continue;
+ }
+ if (strcmp (*p, "-quiet") == 0)
+ continue;
+ if (strcmp (*p, "-version") == 0)
+ continue;
+ if ((*p)[1] == 'd')
+ continue;
+
+ pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
+ }
+ if (pos > 0)
+ fprintf (file, "%s", term);
+
+ /* Print the -f and -m options that have been enabled.
+ We don't handle language specific options but printing argv
+ should suffice. */
+
+ pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
+ _("options enabled: "), "");
+
+ for (j = 0; j < ARRAY_SIZE (f_options); j++)
+ if (*f_options[j].variable == f_options[j].on_value)
+ pos = print_single_switch (file, pos, max, indent, sep, term,
+ "-f", f_options[j].string);
+
+ /* Print target specific options. */
+
+ for (j = 0; j < ARRAY_SIZE (target_switches); j++)
+ if (target_switches[j].name[0] != '\0'
+ && target_switches[j].value > 0
+ && ((target_switches[j].value & target_flags)
+ == target_switches[j].value))
+ {
+ pos = print_single_switch (file, pos, max, indent, sep, term,
+ "-m", target_switches[j].name);
+ }
+
+#ifdef TARGET_OPTIONS
+ for (j = 0; j < ARRAY_SIZE (target_options); j++)
+ if (*target_options[j].variable != NULL)
+ {
+ char prefix[256];
+ sprintf (prefix, "-m%s", target_options[j].prefix);
+ pos = print_single_switch (file, pos, max, indent, sep, term,
+ prefix, *target_options[j].variable);
+ }
+#endif
+
+ fprintf (file, "%s", term);
+}
+
+/* Open assembly code output file. Do this even if -fsyntax-only is
+ on, because then the driver will have provided the name of a
+ temporary file or bit bucket for us. NAME is the file specified on
+ the command line, possibly NULL. */
+static void
+init_asm_output (name)
+ const char *name;
+{
+ if (name == NULL && asm_file_name == 0)
+ asm_out_file = stdout;
+ else
+ {
+ if (asm_file_name == 0)
+ {
+ int len = strlen (dump_base_name);
+ char *dumpname = (char *) xmalloc (len + 6);
+ memcpy (dumpname, dump_base_name, len + 1);
+ strip_off_ending (dumpname, len);
+ strcat (dumpname, ".s");
+ asm_file_name = dumpname;
+ }
+ if (!strcmp (asm_file_name, "-"))
+ asm_out_file = stdout;
+ else
+ asm_out_file = fopen (asm_file_name, "w");
+ if (asm_out_file == 0)
+ fatal_io_error ("can't open %s for writing", asm_file_name);
+ }
+
+#ifdef IO_BUFFER_SIZE
+ setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
+ _IOFBF, IO_BUFFER_SIZE);
+#endif
+
+ if (!flag_syntax_only)
+ {
+#ifdef ASM_FILE_START
+ ASM_FILE_START (asm_out_file);
+#endif
+
+#ifdef ASM_COMMENT_START
+ if (flag_verbose_asm)
+ {
+ /* Print the list of options in effect. */
+ print_version (asm_out_file, ASM_COMMENT_START);
+ print_switch_values (asm_out_file, 0, MAX_LINE,
+ ASM_COMMENT_START, " ", "\n");
+ /* Add a blank line here so it appears in assembler output but not
+ screen output. */
+ fprintf (asm_out_file, "\n");
+ }
+#endif
+ }
+}
+
+/* Initialization of the front end environment, before command line
+ options are parsed. Signal handlers, internationalization etc.
+ ARGV0 is main's argv[0]. */
+static void
+general_init (argv0)
+ char *argv0;
+{
+ char *p;
- p = argv[0] + strlen (argv[0]);
- while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
+ p = argv0 + strlen (argv0);
+ while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
--p;
progname = p;
@@ -4640,29 +4665,28 @@ toplev_main (argc, argv)
signal (SIGIOT, crash_signal);
#endif
- decl_printable_name = decl_name;
- lang_expand_expr = (lang_expand_expr_t) do_abort;
-
- /* Initialize whether `char' is signed. */
- flag_signed_char = DEFAULT_SIGNED_CHAR;
-#ifdef DEFAULT_SHORT_ENUMS
- /* Initialize how much space enums occupy, by default. */
- flag_short_enums = DEFAULT_SHORT_ENUMS;
-#endif
-
- tree_code_length[(int) IDENTIFIER_NODE]
- = ((lang_hooks.identifier_size - sizeof (struct tree_common))
- / sizeof (tree));
+ /* Initialize the diagnostics reporting machinery, so option parsing
+ can give warnings and errors. */
+ diagnostic_initialize (global_dc);
+}
+
+/* Parse command line options and set default flag values, called
+ after language-independent option-independent intialization. Do
+ minimal options processing. Outputting diagnostics is OK, but GC
+ and identifier hashtables etc. are not initialized yet. */
+static void
+parse_options_and_default_flags (argc, argv)
+ int argc;
+ char **argv;
+{
+ int i;
- /* Initialize the garbage-collector. */
- init_ggc ();
- init_stringpool ();
- ggc_add_rtx_root (&stack_limit_rtx, 1);
- ggc_add_tree_root (&current_function_decl, 1);
- ggc_add_tree_root (&current_function_func_begin_label, 1);
+ /* Save in case md file wants to emit args as a comment. */
+ save_argc = argc;
+ save_argv = argv;
- /* Initialize the diagnostics reporting machinery. */
- diagnostic_initialize (global_dc);
+ /* Initialize register usage now so switches may override. */
+ init_reg_sets ();
/* Register the language-independent parameters. */
add_params (lang_independent_params, LAST_PARAM);
@@ -4758,6 +4782,13 @@ toplev_main (argc, argv)
align_functions = 1;
}
+ /* Initialize whether `char' is signed. */
+ flag_signed_char = DEFAULT_SIGNED_CHAR;
+#ifdef DEFAULT_SHORT_ENUMS
+ /* Initialize how much space enums occupy, by default. */
+ flag_short_enums = DEFAULT_SHORT_ENUMS;
+#endif
+
/* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
modify it. */
target_flags = 0;
@@ -4774,9 +4805,6 @@ toplev_main (argc, argv)
OPTIMIZATION_OPTIONS (optimize, optimize_size);
#endif
- /* Initialize register usage now so switches may override. */
- init_reg_sets ();
-
/* Perform normal command line switch decoding. */
for (i = 1; i < argc;)
{
@@ -4844,10 +4872,12 @@ toplev_main (argc, argv)
/* All command line options have been processed. */
(*lang_hooks.post_options) ();
-
- if (exit_after_options)
- exit (0);
-
+}
+
+/* Process the options that have been parsed. */
+static void
+process_options ()
+{
/* Checker uses the frame pointer. */
if (flag_check_memory_usage)
flag_omit_frame_pointer = 0;
@@ -4963,180 +4993,214 @@ toplev_main (argc, argv)
print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
}
- compile_file (filename);
+ if (! quiet_flag)
+ time_report = 1;
- if (errorcount)
- return (FATAL_EXIT_CODE);
- if (sorrycount)
- return (FATAL_EXIT_CODE);
- return (SUCCESS_EXIT_CODE);
+ if (flag_syntax_only)
+ {
+ write_symbols = NO_DEBUG;
+ profile_flag = 0;
+ profile_block_flag = 0;
+ }
+
+ /* Now we know write_symbols, set up the debug hooks based on it.
+ By default we do nothing for debug output. */
+#if defined(DBX_DEBUGGING_INFO)
+ if (write_symbols == DBX_DEBUG)
+ debug_hooks = &dbx_debug_hooks;
+#endif
+#if defined(XCOFF_DEBUGGING_INFO)
+ if (write_symbols == XCOFF_DEBUG)
+ debug_hooks = &xcoff_debug_hooks;
+#endif
+#ifdef SDB_DEBUGGING_INFO
+ if (write_symbols == SDB_DEBUG)
+ debug_hooks = &sdb_debug_hooks;
+#endif
+#ifdef DWARF_DEBUGGING_INFO
+ if (write_symbols == DWARF_DEBUG)
+ debug_hooks = &dwarf_debug_hooks;
+#endif
+#ifdef DWARF2_DEBUGGING_INFO
+ if (write_symbols == DWARF2_DEBUG)
+ debug_hooks = &dwarf2_debug_hooks;
+#endif
+
+ /* If auxiliary info generation is desired, open the output file.
+ This goes in the same directory as the source file--unlike
+ all the other output files. */
+ if (flag_gen_aux_info)
+ {
+ aux_info_file = fopen (aux_info_file_name, "w");
+ if (aux_info_file == 0)
+ fatal_io_error ("can't open %s", aux_info_file_name);
+ }
+
+ if (! targetm.have_named_sections)
+ {
+ if (flag_function_sections)
+ {
+ warning ("-ffunction-sections not supported for this target.");
+ flag_function_sections = 0;
+ }
+ if (flag_data_sections)
+ {
+ warning ("-fdata-sections not supported for this target.");
+ flag_data_sections = 0;
+ }
+ }
+
+ if (flag_function_sections
+ && (profile_flag || profile_block_flag))
+ {
+ warning ("-ffunction-sections disabled; it makes profiling impossible.");
+ flag_function_sections = 0;
+ }
+
+#ifndef OBJECT_FORMAT_ELF
+ if (flag_function_sections && write_symbols != NO_DEBUG)
+ warning ("-ffunction-sections may affect debugging on some targets.");
+#endif
}
-/* Decode -m switches. */
-/* Decode the switch -mNAME. */
-
+/* Language-independent initialization, before language-dependent
+ initialization. */
static void
-set_target_switch (name)
- const char *name;
+lang_independent_init ()
{
- size_t j;
- int valid_target_option = 0;
+ decl_printable_name = decl_name;
+ lang_expand_expr = (lang_expand_expr_t) do_abort;
- for (j = 0; j < ARRAY_SIZE (target_switches); j++)
- if (!strcmp (target_switches[j].name, name))
- {
- if (target_switches[j].value < 0)
- target_flags &= ~-target_switches[j].value;
- else
- target_flags |= target_switches[j].value;
- valid_target_option = 1;
- }
+ /* Set the language-dependent identifer size. */
+ tree_code_length[(int) IDENTIFIER_NODE]
+ = ((lang_hooks.identifier_size - sizeof (struct tree_common))
+ / sizeof (tree));
-#ifdef TARGET_OPTIONS
- if (!valid_target_option)
- for (j = 0; j < ARRAY_SIZE (target_options); j++)
- {
- int len = strlen (target_options[j].prefix);
- if (!strncmp (target_options[j].prefix, name, len))
- {
- *target_options[j].variable = name + len;
- valid_target_option = 1;
- }
- }
-#endif
+ /* Initialize the garbage-collector, and string pools. FIXME: We
+ should do this later, in independent_init () when we know we
+ actually want to compile something, but cpplib currently wants to
+ use the hash table immediately in cpp_create_reader. */
+ init_ggc ();
+ ggc_add_rtx_root (&stack_limit_rtx, 1);
+ ggc_add_tree_root (&current_function_decl, 1);
+ ggc_add_tree_root (&current_function_func_begin_label, 1);
- if (!valid_target_option)
- error ("Invalid option `%s'", name);
+ init_stringpool ();
+ init_obstacks ();
+
+ init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
+ || debug_info_level == DINFO_LEVEL_VERBOSE
+ || flag_test_coverage
+ || warn_notreached);
+ init_regs ();
+ init_alias_once ();
+ init_stmt ();
+ init_loop ();
+ init_reload ();
+ init_function_once ();
+ init_stor_layout_once ();
+ init_varasm_once ();
+ init_EXPR_INSN_LIST_cache ();
+
+ /* The following initialization functions need to generate rtl, so
+ provide a dummy function context for them. */
+ init_dummy_function_start ();
+ init_expmed ();
+ init_expr_once ();
+ if (flag_caller_saves)
+ init_caller_save ();
+ expand_dummy_function_end ();
}
-/* Print version information to FILE.
- Each line begins with INDENT (for the case where FILE is the
- assembler output file). */
-
+/* Language-dependent initialization. */
static void
-print_version (file, indent)
- FILE *file;
- const char *indent;
+lang_dependent_init (name)
+ const char *name;
{
-#ifndef __VERSION__
-#define __VERSION__ "[?]"
-#endif
- fnotice (file,
-#ifdef __GNUC__
- "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
-#else
- "%s%s%s version %s (%s) compiled by CC.\n"
-#endif
- , indent, *indent != 0 ? " " : "",
- lang_hooks.name, version_string, TARGET_NAME,
- indent, __VERSION__);
-}
+ if (dump_base_name == 0)
+ dump_base_name = name ? name : "gccdump";
-/* Print an option value and return the adjusted position in the line.
- ??? We don't handle error returns from fprintf (disk full); presumably
- other code will catch a disk full though. */
+ /* Front-end initialization. This hook can assume that GC,
+ identifier hashes etc. are set up, but debug initialization is
+ not done yet. This routine must return the original filename
+ (e.g. foo.i -> foo.c) so can correctly initialize debug output. */
+ name = (*lang_hooks.init) (name);
-static int
-print_single_switch (file, pos, max, indent, sep, term, type, name)
- FILE *file;
- int pos, max;
- const char *indent, *sep, *term, *type, *name;
-{
- /* The ultrix fprintf returns 0 on success, so compute the result we want
- here since we need it for the following test. */
- int len = strlen (sep) + strlen (type) + strlen (name);
+ if (name)
+ name = ggc_strdup (name);
- if (pos != 0
- && pos + len > max)
- {
- fprintf (file, "%s", term);
- pos = 0;
- }
- if (pos == 0)
- {
- fprintf (file, "%s", indent);
- pos = strlen (indent);
- }
- fprintf (file, "%s%s%s", sep, type, name);
- pos += len;
- return pos;
+ main_input_filename = input_filename = name;
+ init_asm_output (name);
+
+ /* These create various _DECL nodes, so need to be called after the
+ front end is initialized. */
+ init_eh ();
+ init_optabs ();
+
+ /* Put an entry on the input file stack for the main input file. */
+ push_srcloc (input_filename, 0);
+
+ /* If dbx symbol table desired, initialize writing it and output the
+ predefined types. */
+ timevar_push (TV_SYMOUT);
+
+#ifdef DWARF2_UNWIND_INFO
+ if (dwarf2out_do_frame ())
+ dwarf2out_frame_init ();
+#endif
+
+ /* Now we have the correct original filename, we can initialize
+ debug output. */
+ (*debug_hooks->init) (name);
+
+ timevar_pop (TV_SYMOUT);
}
+
+/* Entry point of cc1, cc1plus, jc1, f771, etc.
+ Decode command args, then call compile_file.
+ Exit code is FATAL_EXIT_CODE if can't open files or if there were
+ any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
-/* Print active target switches to FILE.
- POS is the current cursor position and MAX is the size of a "line".
- Each line begins with INDENT and ends with TERM.
- Each switch is separated from the next by SEP. */
+ It is not safe to call this function more than once. */
-static void
-print_switch_values (file, pos, max, indent, sep, term)
- FILE *file;
- int pos, max;
- const char *indent, *sep, *term;
+int
+toplev_main (argc, argv)
+ int argc;
+ char **argv;
{
- size_t j;
- char **p;
+ /* Initialization of GCC's environment, and diagnostics. */
+ general_init (argv [0]);
- /* Print the options as passed. */
-
- pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
- _("options passed: "), "");
+ /* Parse the options and do minimal processing; basically just
+ enough to default flags appropriately. */
+ parse_options_and_default_flags (argc, argv);
- for (p = &save_argv[1]; *p != NULL; p++)
- if (**p == '-')
- {
- /* Ignore these. */
- if (strcmp (*p, "-o") == 0)
- {
- if (p[1] != NULL)
- p++;
- continue;
- }
- if (strcmp (*p, "-quiet") == 0)
- continue;
- if (strcmp (*p, "-version") == 0)
- continue;
- if ((*p)[1] == 'd')
- continue;
+ /* Exit early if we can (e.g. -help). */
+ if (exit_after_options)
+ return (SUCCESS_EXIT_CODE);
- pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
- }
- if (pos > 0)
- fprintf (file, "%s", term);
+ /* Start timing total execution time. */
+ init_timevar ();
+ timevar_start (TV_TOTAL);
- /* Print the -f and -m options that have been enabled.
- We don't handle language specific options but printing argv
- should suffice. */
+ /* The bulk of command line switch processing. */
+ process_options ();
- pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
- _("options enabled: "), "");
+ /* Language-independent initialization. Also sets up GC, identifier
+ hashes etc. */
+ lang_independent_init ();
- for (j = 0; j < ARRAY_SIZE (f_options); j++)
- if (*f_options[j].variable == f_options[j].on_value)
- pos = print_single_switch (file, pos, max, indent, sep, term,
- "-f", f_options[j].string);
+ /* Language-dependent initialization. */
+ lang_dependent_init (filename);
- /* Print target specific options. */
+ compile_file ();
- for (j = 0; j < ARRAY_SIZE (target_switches); j++)
- if (target_switches[j].name[0] != '\0'
- && target_switches[j].value > 0
- && ((target_switches[j].value & target_flags)
- == target_switches[j].value))
- {
- pos = print_single_switch (file, pos, max, indent, sep, term,
- "-m", target_switches[j].name);
- }
+ /* Stop timing and print the times. */
+ timevar_stop (TV_TOTAL);
+ timevar_print (stderr);
-#ifdef TARGET_OPTIONS
- for (j = 0; j < ARRAY_SIZE (target_options); j++)
- if (*target_options[j].variable != NULL)
- {
- char prefix[256];
- sprintf (prefix, "-m%s", target_options[j].prefix);
- pos = print_single_switch (file, pos, max, indent, sep, term,
- prefix, *target_options[j].variable);
- }
-#endif
+ if (errorcount || sorrycount)
+ return (FATAL_EXIT_CODE);
- fprintf (file, "%s", term);
+ return (SUCCESS_EXIT_CODE);
}
diff --git a/gcc/tree.h b/gcc/tree.h
index 45ce33f..4fa3280 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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));