Commit 0352cfc8 by Mark Mitchell Committed by Mark Mitchell

class.c (build_vtable): Use build_lang_decl when building vtables, not just build_decl.

	* class.c (build_vtable): Use build_lang_decl when building
	vtables, not just build_decl.
	(prepare_fresh_vtable): Likewise.
	* decl.c (wrapup_globals_for_namespace): Mark vtables as
	DECL_EXTERNAL when calling wrapup_global_declarations.
	* decl2.c (priority_info_s): Add initializations_p and
	destructions_p members.
	(finish_vtable_vardecl): Use TREE_SYMBOL_REFERENCED, not TREE_USED,
	when deciding what vtables to write out.
	(ssdf_decls): New variable.
	(ssdf_decls_used): Likewise.
	(start_static_storage_duration_function): Deal with being called
	multiple times.  Avoid inlining this function.
	(generate_inits_for_priority): Deal with reuse of priority map.
	(get_priority_info): Clear initializations_p and destructions_p.
	(do_static_initialization): Tweak comment.
	(do_static_destruction): Likewise.  Fix condition on sentries for
	destruction.
	(generate_ctor_or_dtor_function): Call all of the static storage
	duration functions.
	(generate_ctor_or_dtor_function_for_priority): Check
	initializations_p and destructions_p to see what priorities need
	initialization functions.
	(finish_file): Rework to generate multiple static storage duration
	functions, rather than just one.

From-SVN: r26713
parent 3fd91cbd
1999-04-30 Mark Mitchell <mark@codesourcery.com> 1999-04-30 Mark Mitchell <mark@codesourcery.com>
* class.c (build_vtable): Use build_lang_decl when building
vtables, not just build_decl.
(prepare_fresh_vtable): Likewise.
* decl.c (wrapup_globals_for_namespace): Mark vtables as
DECL_EXTERNAL when calling wrapup_global_declarations.
* decl2.c (priority_info_s): Add initializations_p and
destructions_p members.
(finish_vtable_vardecl): Use TREE_SYMBOL_REFERENCED, not TREE_USED,
when deciding what vtables to write out.
(ssdf_decls): New variable.
(ssdf_decls_used): Likewise.
(start_static_storage_duration_function): Deal with being called
multiple times. Avoid inlining this function.
(generate_inits_for_priority): Deal with reuse of priority map.
(get_priority_info): Clear initializations_p and destructions_p.
(do_static_initialization): Tweak comment.
(do_static_destruction): Likewise. Fix condition on sentries for
destruction.
(generate_ctor_or_dtor_function): Call all of the static storage
duration functions.
(generate_ctor_or_dtor_function_for_priority): Check
initializations_p and destructions_p to see what priorities need
initialization functions.
(finish_file): Rework to generate multiple static storage duration
functions, rather than just one.
* typeck.c (build_const_cast): Tweak last change to handle * typeck.c (build_const_cast): Tweak last change to handle
templates correctly. templates correctly.
......
...@@ -712,7 +712,7 @@ build_vtable (binfo, type) ...@@ -712,7 +712,7 @@ build_vtable (binfo, type)
tree offset; tree offset;
virtuals = copy_list (BINFO_VIRTUALS (binfo)); virtuals = copy_list (BINFO_VIRTUALS (binfo));
decl = build_decl (VAR_DECL, name, TREE_TYPE (BINFO_VTABLE (binfo))); decl = build_lang_decl (VAR_DECL, name, TREE_TYPE (BINFO_VTABLE (binfo)));
/* Now do rtti stuff. */ /* Now do rtti stuff. */
offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE); offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE);
...@@ -722,7 +722,7 @@ build_vtable (binfo, type) ...@@ -722,7 +722,7 @@ build_vtable (binfo, type)
else else
{ {
virtuals = NULL_TREE; virtuals = NULL_TREE;
decl = build_decl (VAR_DECL, name, void_type_node); decl = build_lang_decl (VAR_DECL, name, void_type_node);
} }
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
...@@ -872,7 +872,7 @@ prepare_fresh_vtable (binfo, for_type) ...@@ -872,7 +872,7 @@ prepare_fresh_vtable (binfo, for_type)
buf2 = new_buf2; buf2 = new_buf2;
} }
new_decl = build_decl (VAR_DECL, name, TREE_TYPE (orig_decl)); new_decl = build_lang_decl (VAR_DECL, name, TREE_TYPE (orig_decl));
/* Remember which class this vtable is really for. */ /* Remember which class this vtable is really for. */
DECL_CONTEXT (new_decl) = for_type; DECL_CONTEXT (new_decl) = for_type;
......
...@@ -1988,6 +1988,7 @@ wrapup_globals_for_namespace (namespace, data) ...@@ -1988,6 +1988,7 @@ wrapup_globals_for_namespace (namespace, data)
int len = list_length (globals); int len = list_length (globals);
tree *vec = (tree *) alloca (sizeof (tree) * len); tree *vec = (tree *) alloca (sizeof (tree) * len);
int i; int i;
int result;
tree decl; tree decl;
int last_time = (data != 0); int last_time = (data != 0);
...@@ -2001,11 +2002,35 @@ wrapup_globals_for_namespace (namespace, data) ...@@ -2001,11 +2002,35 @@ wrapup_globals_for_namespace (namespace, data)
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
vec[len - i - 1] = decl; vec[len - i - 1] = decl;
if (!last_time) if (last_time)
return wrapup_global_declarations (vec, len); {
check_global_declarations (vec, len);
return 0;
}
check_global_declarations (vec, len); /* Temporarily mark vtables as external. That prevents
return 0; wrapup_global_declarations from writing them out; we must process
them ourselves in finish_vtable_vardecl. */
for (i = 0; i < len; ++i)
if (vtable_decl_p (vec[i], /*data=*/0))
{
DECL_NOT_REALLY_EXTERN (vec[i]) = 1;
DECL_EXTERNAL (vec[i]) = 1;
}
/* Write out any globals that need to be output. */
result = wrapup_global_declarations (vec, len);
/* Undo the hack to DECL_EXTERNAL above. */
for (i = 0; i < len; ++i)
if (vtable_decl_p (vec[i], /*data=*/0)
&& DECL_NOT_REALLY_EXTERN (vec[i]))
{
DECL_NOT_REALLY_EXTERN (vec[i]) = 0;
DECL_EXTERNAL (vec[i]) = 0;
}
return result;
} }
......
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