diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-30 22:54:06 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-30 22:54:06 +0000 |
commit | aff47ac3ef17fc2ea10260f59f8c80ac59b068e4 (patch) | |
tree | cb48a2f26270dff9ebb3b93323918ba903e7d7e4 /gcc/cp | |
parent | 723941490d5c82023cb20868afef06c606e760f3 (diff) | |
download | gcc-aff47ac3ef17fc2ea10260f59f8c80ac59b068e4.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86809 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/class.c | 17 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/decl.c | 16 |
4 files changed, 29 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 97296e940a5..eea871b4c82 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +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. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 272c4d6a0ff..21bdfdd2f6f 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -170,7 +170,6 @@ static void dump_vtt (tree, tree); 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); @@ -6681,20 +6680,10 @@ initialize_vtable (tree binfo, tree inits) 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. @@ -6731,7 +6720,7 @@ build_vtt (tree t) /* 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; @@ -7018,7 +7007,7 @@ build_ctor_vtbl_group (tree binfo, tree t) /* 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); } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 49c9d471451..9e894ff2370 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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 void warn_extern_redeclared_static (tree, tree); extern bool cp_missing_noreturn_ok_p (tree); +extern void initialize_artificial_var (tree, tree); extern bool have_extern_spec; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bd7098289b2..2932ae9a484 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4640,6 +4640,22 @@ initialize_local_var (tree decl, tree init) 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, |