Commit 2b59501b by Matt Austern Committed by Matt Austern

langhooks.h, [...]: introduce new langhook...


       * langhooks.h, langhooks-def.h: introduce new langhook,
       final_write_globals, with write_global_declarations as default.
       * toplev.c: Move invocation of wrapup_global_declarations from
       compile_file to new function, write_global_declarations.  Change
       compile_file to use final_write_globals hook.  Change
       wrapup_global_declarations so writing to DECL_DEFER_OUTPUT is
       conditional.

       * cp/cp-lang.c: Change lang hooks so that final_write_globals does
       nothing for C++.
       * cp/decl.c (wrapup_globals_for_namespace): Remove special
       handling of global namespace.

From-SVN: r63051
parent 131efcd8
2003-02-18 Matt Austern <austern@apple.com>
* langhooks.h, langhooks-def.h: introduce new langhook,
final_write_globals, with write_global_declarations as default.
* toplev.c: Move invocation of wrapup_global_declarations from
compile_file to new function, write_global_declarations. Change
compile_file to use final_write_globals hook. Change
wrapup_global_declarations so writing to DECL_DEFER_OUTPUT is
conditional.
2003-02-18 John David Anglin <dave.anglin@nrc-cnrc.gc.ca> 2003-02-18 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* pa.md: Correct and enhance comment. * pa.md: Correct and enhance comment.
......
2003-02-18 Matt Austern <austern@apple.com>
* cp/cp-lang.c: Change lang hooks so that final_write_globals does
nothing for C++.
* cp/decl.c (wrapup_globals_for_namespace): Remove special
handling of global namespace.
2003-02-18 Geoffrey Keating <geoffk@apple.com> 2003-02-18 Geoffrey Keating <geoffk@apple.com>
* cp-tree.h (rid_to_yy): Delete. * cp-tree.h (rid_to_yy): Delete.
......
...@@ -92,6 +92,9 @@ static bool cp_var_mod_type_p (tree); ...@@ -92,6 +92,9 @@ static bool cp_var_mod_type_p (tree);
#define LANG_HOOKS_PRINT_ERROR_FUNCTION cxx_print_error_function #define LANG_HOOKS_PRINT_ERROR_FUNCTION cxx_print_error_function
#undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
#undef LANG_HOOKS_WRITE_GLOBALS
#define LANG_HOOKS_WRITE_GLOBALS lhd_do_nothing
#undef LANG_HOOKS_FUNCTION_INIT #undef LANG_HOOKS_FUNCTION_INIT
#define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context #define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context
......
...@@ -1855,10 +1855,6 @@ wrapup_globals_for_namespace (tree namespace, void* data) ...@@ -1855,10 +1855,6 @@ wrapup_globals_for_namespace (tree namespace, void* data)
tree decl; tree decl;
int last_time = (data != 0); int last_time = (data != 0);
if (last_time && namespace == global_namespace)
/* Let compile_file handle the global namespace. */
return 0;
/* Process the decls in reverse order--earliest first. /* Process the decls in reverse order--earliest first.
Put them into VEC from back to front, then take out from front. */ Put them into VEC from back to front, then take out from front. */
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
......
...@@ -82,6 +82,9 @@ int lhd_tree_inlining_start_inlining PARAMS ((tree)); ...@@ -82,6 +82,9 @@ int lhd_tree_inlining_start_inlining PARAMS ((tree));
void lhd_tree_inlining_end_inlining PARAMS ((tree)); void lhd_tree_inlining_end_inlining PARAMS ((tree));
tree lhd_tree_inlining_convert_parm_for_inlining PARAMS ((tree, tree, tree)); tree lhd_tree_inlining_convert_parm_for_inlining PARAMS ((tree, tree, tree));
/* In toplev.c */
void write_global_declarations PARAMS ((void));
#define LANG_HOOKS_NAME "GNU unknown" #define LANG_HOOKS_NAME "GNU unknown"
#define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier) #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier)
#define LANG_HOOKS_INIT lhd_do_nothing #define LANG_HOOKS_INIT lhd_do_nothing
...@@ -217,6 +220,7 @@ int lhd_tree_dump_type_quals PARAMS ((tree)); ...@@ -217,6 +220,7 @@ int lhd_tree_dump_type_quals PARAMS ((tree));
#define LANG_HOOKS_PUSHDECL pushdecl #define LANG_HOOKS_PUSHDECL pushdecl
#define LANG_HOOKS_GETDECLS getdecls #define LANG_HOOKS_GETDECLS getdecls
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
#define LANG_HOOKS_WRITE_GLOBALS write_global_declarations
#define LANG_HOOKS_DECLS { \ #define LANG_HOOKS_DECLS { \
LANG_HOOKS_PUSHLEVEL, \ LANG_HOOKS_PUSHLEVEL, \
...@@ -226,7 +230,8 @@ int lhd_tree_dump_type_quals PARAMS ((tree)); ...@@ -226,7 +230,8 @@ int lhd_tree_dump_type_quals PARAMS ((tree));
LANG_HOOKS_SET_BLOCK, \ LANG_HOOKS_SET_BLOCK, \
LANG_HOOKS_PUSHDECL, \ LANG_HOOKS_PUSHDECL, \
LANG_HOOKS_GETDECLS, \ LANG_HOOKS_GETDECLS, \
LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL \ LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
LANG_HOOKS_WRITE_GLOBALS \
} }
/* The whole thing. The structure is defined in langhooks.h. */ /* The whole thing. The structure is defined in langhooks.h. */
......
...@@ -176,6 +176,10 @@ struct lang_hooks_for_decls ...@@ -176,6 +176,10 @@ struct lang_hooks_for_decls
/* Returns true when we should warn for an unused global DECL. /* Returns true when we should warn for an unused global DECL.
We will already have checked that it has static binding. */ We will already have checked that it has static binding. */
bool (*warn_unused_global) PARAMS ((tree)); bool (*warn_unused_global) PARAMS ((tree));
/* Obtain a list of globals and do final output on them at end
of compilation */
void (*final_write_globals) PARAMS ((void));
}; };
/* Language-specific hooks. See langhooks-def.h for defaults. */ /* Language-specific hooks. See langhooks-def.h for defaults. */
......
...@@ -1933,8 +1933,10 @@ wrapup_global_declarations (vec, len) ...@@ -1933,8 +1933,10 @@ wrapup_global_declarations (vec, len)
{ {
decl = vec[i]; decl = vec[i];
/* We're not deferring this any longer. */ /* We're not deferring this any longer. Assignment is
DECL_DEFER_OUTPUT (decl) = 0; conditional to avoid needlessly dirtying PCH pages. */
if (DECL_DEFER_OUTPUT (decl) != 0)
DECL_DEFER_OUTPUT (decl) = 0;
if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0) if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
(*lang_hooks.finish_incomplete_decl) (decl); (*lang_hooks.finish_incomplete_decl) (decl);
...@@ -2141,8 +2143,6 @@ pop_srcloc () ...@@ -2141,8 +2143,6 @@ pop_srcloc ()
static void static void
compile_file () compile_file ()
{ {
tree globals;
/* Initialize yet another pass. */ /* Initialize yet another pass. */
init_final (main_input_filename); init_final (main_input_filename);
...@@ -2165,25 +2165,7 @@ compile_file () ...@@ -2165,25 +2165,7 @@ compile_file ()
if (flag_syntax_only) if (flag_syntax_only)
return; return;
globals = (*lang_hooks.decls.getdecls) (); (*lang_hooks.decls.final_write_globals)();
/* Really define vars that have had only a tentative definition.
Really output inline functions that must actually be callable
and have not been output so far. */
{
int len = list_length (globals);
tree *vec = (tree *) xmalloc (sizeof (tree) * len);
int i;
tree decl;
/* Process the decls in reverse order--earliest first.
Put them into VEC from back to front, then take out from front. */
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
vec[len - i - 1] = decl;
wrapup_global_declarations (vec, len);
if (profile_arc_flag) if (profile_arc_flag)
/* This must occur after the loop to output deferred functions. /* This must occur after the loop to output deferred functions.
...@@ -2191,12 +2173,6 @@ compile_file () ...@@ -2191,12 +2173,6 @@ compile_file ()
functions in this compilation unit were deferred. */ functions in this compilation unit were deferred. */
create_profiler (); create_profiler ();
check_global_declarations (vec, len);
/* Clean up. */
free (vec);
}
/* Write out any pending weak symbol declarations. */ /* Write out any pending weak symbol declarations. */
weak_finish (); weak_finish ();
...@@ -2248,6 +2224,36 @@ compile_file () ...@@ -2248,6 +2224,36 @@ compile_file ()
timevar_pop (TV_DUMP); timevar_pop (TV_DUMP);
} }
} }
/* Default for lang_hooks.decls.final_write_globals */
void write_global_declarations ()
{
tree globals = (*lang_hooks.decls.getdecls) ();
/* Really define vars that have had only a tentative definition.
Really output inline functions that must actually be callable
and have not been output so far. */
{
int len = list_length (globals);
tree *vec = (tree *) xmalloc (sizeof (tree) * len);
int i;
tree decl;
/* Process the decls in reverse order--earliest first.
Put them into VEC from back to front, then take out from front. */
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
vec[len - i - 1] = decl;
wrapup_global_declarations (vec, len);
check_global_declarations (vec, len);
/* Clean up. */
free (vec);
}
}
/* This is called from various places for FUNCTION_DECL, VAR_DECL, /* This is called from various places for FUNCTION_DECL, VAR_DECL,
and TYPE_DECL nodes. and TYPE_DECL nodes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment