Commit 19c29b2f by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (initialize_artificial_var): Declare.

	* cp-tree.h (initialize_artificial_var): Declare.
	* decl.c (initialize_artifical_var): New function.
	* class.c (initialize_array): Remove.
	(initialize_vtable): Use initialize_artificial_var.
	(build_vtt): Likewise.
	(build_ctor_vtbl_group): Likewise.

From-SVN: r86809
parent ff164b22
2004-08-30 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (initialize_artificial_var): Declare.
* decl.c (initialize_artifical_var): New function.
* class.c (initialize_array): Remove.
(initialize_vtable): Use initialize_artificial_var.
(build_vtt): Likewise.
(build_ctor_vtbl_group): Likewise.
2004-08-30 Richard Henderson <rth@redhat.com> 2004-08-30 Richard Henderson <rth@redhat.com>
* class.c (build_base_path): Use build_address directly. * class.c (build_base_path): Use build_address directly.
......
...@@ -170,7 +170,6 @@ static void dump_vtt (tree, tree); ...@@ -170,7 +170,6 @@ static void dump_vtt (tree, tree);
static void dump_thunk (FILE *, int, tree); static void dump_thunk (FILE *, int, tree);
static tree build_vtable (tree, tree, tree); static tree build_vtable (tree, tree, tree);
static void initialize_vtable (tree, tree); static void initialize_vtable (tree, tree);
static void initialize_array (tree, tree);
static void layout_nonempty_base_or_field (record_layout_info, static void layout_nonempty_base_or_field (record_layout_info,
tree, tree, splay_tree); tree, tree, splay_tree);
static tree end_of_class (tree, int); static tree end_of_class (tree, int);
...@@ -6681,20 +6680,10 @@ initialize_vtable (tree binfo, tree inits) ...@@ -6681,20 +6680,10 @@ initialize_vtable (tree binfo, tree inits)
layout_vtable_decl (binfo, list_length (inits)); layout_vtable_decl (binfo, list_length (inits));
decl = get_vtbl_decl_for_binfo (binfo); decl = get_vtbl_decl_for_binfo (binfo);
initialize_array (decl, inits); initialize_artificial_var (decl, inits);
dump_vtable (BINFO_TYPE (binfo), binfo, decl); dump_vtable (BINFO_TYPE (binfo), binfo, decl);
} }
/* Initialize DECL (a declaration for a namespace-scope array) with
the INITS. */
static void
initialize_array (tree decl, tree inits)
{
DECL_INITIAL (decl) = build_constructor (NULL_TREE, inits);
cp_finish_decl (decl, DECL_INITIAL (decl), NULL_TREE, 0);
}
/* Build the VTT (virtual table table) for T. /* Build the VTT (virtual table table) for T.
A class requires a VTT if it has virtual bases. A class requires a VTT if it has virtual bases.
...@@ -6731,7 +6720,7 @@ build_vtt (tree t) ...@@ -6731,7 +6720,7 @@ build_vtt (tree t)
/* Now, build the VTT object itself. */ /* Now, build the VTT object itself. */
vtt = build_vtable (t, get_vtt_name (t), type); vtt = build_vtable (t, get_vtt_name (t), type);
initialize_array (vtt, inits); initialize_artificial_var (vtt, inits);
/* Add the VTT to the vtables list. */ /* Add the VTT to the vtables list. */
TREE_CHAIN (vtt) = TREE_CHAIN (CLASSTYPE_VTABLES (t)); TREE_CHAIN (vtt) = TREE_CHAIN (CLASSTYPE_VTABLES (t));
TREE_CHAIN (CLASSTYPE_VTABLES (t)) = vtt; TREE_CHAIN (CLASSTYPE_VTABLES (t)) = vtt;
...@@ -7018,7 +7007,7 @@ build_ctor_vtbl_group (tree binfo, tree t) ...@@ -7018,7 +7007,7 @@ build_ctor_vtbl_group (tree binfo, tree t)
/* Initialize the construction vtable. */ /* Initialize the construction vtable. */
CLASSTYPE_VTABLES (t) = chainon (CLASSTYPE_VTABLES (t), vtbl); CLASSTYPE_VTABLES (t) = chainon (CLASSTYPE_VTABLES (t), vtbl);
initialize_array (vtbl, inits); initialize_artificial_var (vtbl, inits);
dump_vtable (t, binfo, vtbl); dump_vtable (t, binfo, vtbl);
} }
......
...@@ -3795,6 +3795,7 @@ extern tree builtin_function (const char *name, tree type, ...@@ -3795,6 +3795,7 @@ extern tree builtin_function (const char *name, tree type,
extern tree check_elaborated_type_specifier (enum tag_types, tree, bool); extern tree check_elaborated_type_specifier (enum tag_types, tree, bool);
extern void warn_extern_redeclared_static (tree, tree); extern void warn_extern_redeclared_static (tree, tree);
extern bool cp_missing_noreturn_ok_p (tree); extern bool cp_missing_noreturn_ok_p (tree);
extern void initialize_artificial_var (tree, tree);
extern bool have_extern_spec; extern bool have_extern_spec;
......
...@@ -4640,6 +4640,22 @@ initialize_local_var (tree decl, tree init) ...@@ -4640,6 +4640,22 @@ initialize_local_var (tree decl, tree init)
finish_decl_cleanup (decl, cleanup); finish_decl_cleanup (decl, cleanup);
} }
/* DECL is a VAR_DECL for a compiler-generated variable with static
storage duration (like a virtual table) whose initializer is a
compile-time constant. Initialize the variable and provide it to
the back end. */
void
initialize_artificial_var (tree decl, tree init)
{
DECL_INITIAL (decl) = build_constructor (NULL_TREE, init);
DECL_INITIALIZED_P (decl) = 1;
determine_visibility (decl);
layout_var_decl (decl);
maybe_commonize_var (decl);
make_rtl_for_nonlocal_decl (decl, init, /*asmspec=*/NULL);
}
/* Finish processing of a declaration; /* Finish processing of a declaration;
install its line number and initial value. install its line number and initial value.
If the length of an array type is not known before, If the length of an array type is not known before,
......
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