+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>
* class.c (build_base_path): Use build_address directly.
static void dump_thunk (FILE *, int, tree);
static tree build_vtable (tree, tree, tree);
static void initialize_vtable (tree, tree);
-static void initialize_array (tree, tree);
static void layout_nonempty_base_or_field (record_layout_info,
tree, tree, splay_tree);
static tree end_of_class (tree, int);
layout_vtable_decl (binfo, list_length (inits));
decl = get_vtbl_decl_for_binfo (binfo);
- initialize_array (decl, inits);
+ initialize_artificial_var (decl, inits);
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.
A class requires a VTT if it has virtual bases.
/* Now, build the VTT object itself. */
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. */
TREE_CHAIN (vtt) = TREE_CHAIN (CLASSTYPE_VTABLES (t));
TREE_CHAIN (CLASSTYPE_VTABLES (t)) = vtt;
/* Initialize the construction vtable. */
CLASSTYPE_VTABLES (t) = chainon (CLASSTYPE_VTABLES (t), vtbl);
- initialize_array (vtbl, inits);
+ initialize_artificial_var (vtbl, inits);
dump_vtable (t, binfo, vtbl);
}
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;
install its line number and initial value.
If the length of an array type is not known before,