summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2007-02-25 18:47:05 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2007-02-25 18:47:05 +0000
commitfc8600f9c12ccb952cb38fbad4a2f34e0d958473 (patch)
treecfcdaf9660cd0bdc1216594b6e66f5e22560aa3e /gcc/cp
parent2a025b54f6867e218f4ec07a70c57833162c0c32 (diff)
downloadgcc-fc8600f9c12ccb952cb38fbad4a2f34e0d958473.tar.gz
extend.texi: Document optional priority argument to constructors and destructors.
* doc/extend.texi: Document optional priority argument to constructors and destructors. * tree.c (init_priority_for_decl): Adjust GTY markers. (init_ttree): Use priority-info hash functions for init_priority_for_decl. (tree_map_eq): Rename to ... (tree_map_base_eq): ... this. (tree_map_marked_p): Rename to ... (tree_map_base_marked_p): ... this. (tree_map_base_hash): New function. (decl_init_priority_lookup): Rework. (decl_fini_priority_lookup): New function. (decl_priority_info): New function. (decl_init_priority_insert): Use it. (decl_fini_priority_insert): Likewise. (decl_restrict_base_lookup): Adjust for refactoring of tree_map hierarchy. (decl_restrict_base_insert): Likewise. (decl_debug_expr_insert): Likewise. (decl_value_expr_lookup): Likewise. (decl_value_expr_insert): Likewise. * tree.h (priority_type): New type. (decl_init_priority_lookup): Use priority_type. (decl_fini_priority_lookup): New function. (decl_init_priority_insert): Use priority_type. (decl_fini_priority_insert): New function. (DECL_HAS_INIT_PRIORITY): Tweak comments. (DECL_INIT_PRIORITY): Likewise. (SET_DECL_INIT_PRIORITY): Add comment. (DECL_FINI_PRIORITY): New macro. (SET_DECL_FINI_PRIORITY): Likewise. (DEFAULT_INIT_PRIORITY): Document. (MAX_INIT_PRIORITY): Likewise. (MAX_RESERVED_INIT_PRIORITY): Likewise. (tree_map_base): New type. (tree_map_base_eq): New function. (tree_map_base_hash): Likewise. (tree_map_base_marked_p): Likewise. (tree_map): Inherit from tree_map_base. (tree_map_eq): Make it a macro. (tree_map_marked_p): Likewise. (tree_int_map): Inherit from tree_map_base. (tree_int_map_eq): Make it a macro. (tree_int_map_hash): Likewise. (tree_int_map_marked_p): Likewise. (tree_priority_map): New type. (tree_priority_map_eq): New macro. (tree_priority_map_hash): Likewise. (tree_priority_map_marked_p): Likewise. * varasm.c (emults_decl): Adjust for refactoring of tree_map hierarchy. (emutls_common_1): Likewise. * lambda-code.c (replace_uses_equiv_to_x_with_y): Likewise. * tree-ssa-structalias.c (heapvar_lookup): Adjust for refactoring of tree_map hierarchy. * tree-cfg.c (move_stmt_r): Likewise. (new_label_mapper): Likewise. * c-tree.h (c_expand_body): Move to ... * c-common.h (c_expand_body): ... here. * c-decl.c (c_expand_body): Move to ... * c-common.c (c_expand_body): ... here. (c_common_attribute_table): Allow 1 argument for the constructor and destructor attributes. (get_priority): New function. (handle_constructor_attribute): Set DECL_INIT_PRIORITY. (handle_destructor_attribute): Set DECL_FINI_PRIORITY. * cp-tree.h (static_ctors): Remove. * cp-tree.h (static_dtors): Likewise. * cp-objcp-common.c (decl_shadowed_for_var_lookup): Adjust for refactoring of tree_map hierarchy. (decl_shadowed_for_var_insert): Likewise. * semantics.c (expand_body): Use c_expand_body. (expand_or_defer_fn): Don't update static_ctors or static_dtors. * decl2.c (static_ctors): Remove. (static_dtors): Likewise. (generate_ctor_or_dtor_function): Pass NULL_TREE to objc_generate_static_init_call. Do not call static_[cd]tors. (generate_ctor_and_dtor_functions_for_priority): Do not check for static_[cd]tors. (cp_write_global_declarations): Likewise. * decl.c (annotate_value): Adjust for refactoring of tree_map hierarchy. * gcc.dg/initpri1.c: New test. * gcc.dg/initpri2.c: Likewise. * g++.dg/special/initpri1.C: New test. * g++.dg/special/initpri2.C: Likewise. * g++.dg/special/conpr-1.C: Use init_priority effective target. * g++.dg/special/conpr-2.C: Likewise. * g++.dg/special/conpr-3.C: Likewise. * g++.dg/special/conpr-4.C: Likewise. * g++.dg/special/initp1.C: Likewise. * g++.dg/special/ecos.exp: Remove code to detect availability of constructor priorities. * lib/target-support.exp (target_init_priority): New function. From-SVN: r122315
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog17
-rw-r--r--gcc/cp/cp-objcp-common.c4
-rw-r--r--gcc/cp/cp-tree.h5
-rw-r--r--gcc/cp/decl2.c52
-rw-r--r--gcc/cp/semantics.c14
5 files changed, 28 insertions, 64 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bdef6b5734b..a9f4d254c47 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,20 @@
+2007-02-25 Mark Mitchell <mark@codesourcery.com>
+
+ * cp-tree.h (static_ctors): Remove.
+ * cp-tree.h (static_dtors): Likewise.
+ * cp-objcp-common.c (decl_shadowed_for_var_lookup): Adjust for
+ refactoring of tree_map hierarchy.
+ (decl_shadowed_for_var_insert): Likewise.
+ * semantics.c (expand_body): Use c_expand_body.
+ (expand_or_defer_fn): Don't update static_ctors or static_dtors.
+ * decl2.c (static_ctors): Remove.
+ (static_dtors): Likewise.
+ (generate_ctor_or_dtor_function): Pass NULL_TREE to
+ objc_generate_static_init_call. Do not call static_[cd]tors.
+ (generate_ctor_and_dtor_functions_for_priority): Do not check for
+ static_[cd]tors.
+ (cp_write_global_declarations): Likewise.
+
2007-02-23 Richard Guenther <rguenther@suse.de>
* class.c (note_name_declared_in_class): Make declaration
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 2fdea268106..372e8e5ac3e 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -228,7 +228,7 @@ tree
decl_shadowed_for_var_lookup (tree from)
{
struct tree_map *h, in;
- in.from = from;
+ in.base.from = from;
h = (struct tree_map *) htab_find_with_hash (shadowed_var_for_decl, &in,
htab_hash_pointer (from));
@@ -247,7 +247,7 @@ decl_shadowed_for_var_insert (tree from, tree to)
h = GGC_NEW (struct tree_map);
h->hash = htab_hash_pointer (from);
- h->from = from;
+ h->base.from = from;
h->to = to;
loc = htab_find_slot_with_hash (shadowed_var_for_decl, h, h->hash, INSERT);
*(struct tree_map **) loc = h;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index a070411e625..e03003e1210 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3479,11 +3479,6 @@ extern int at_eof;
TREE_PURPOSE slot. */
extern GTY(()) tree static_aggregates;
-/* Functions called along with real static constructors and destructors. */
-
-extern GTY(()) tree static_ctors;
-extern GTY(()) tree static_dtors;
-
enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
/* These are uses as bits in flags passed to various functions to
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 68917b68bd9..1feb3a7661f 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -97,11 +97,6 @@ static GTY(()) VEC(tree,gc) *deferred_fns;
int at_eof;
-/* Functions called along with real static constructors and destructors. */
-
-tree static_ctors;
-tree static_dtors;
-
/* Return a member function type (a METHOD_TYPE), given FNTYPE (a
@@ -2847,7 +2842,7 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority,
&& constructor_p && objc_static_init_needed_p ())
{
body = start_objects (function_key, priority);
- static_ctors = objc_generate_static_init_call (static_ctors);
+ objc_generate_static_init_call (NULL_TREE);
}
/* Call the static storage duration function with appropriate
@@ -2870,29 +2865,6 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority,
}
}
- /* If we're generating code for the DEFAULT_INIT_PRIORITY, throw in
- calls to any functions marked with attributes indicating that
- they should be called at initialization- or destruction-time. */
- if (priority == DEFAULT_INIT_PRIORITY)
- {
- tree fns;
-
- for (fns = constructor_p ? static_ctors : static_dtors;
- fns;
- fns = TREE_CHAIN (fns))
- {
- fndecl = TREE_VALUE (fns);
-
- /* Calls to pure/const functions will expand to nothing. */
- if (! (flags_from_decl_or_type (fndecl) & (ECF_CONST | ECF_PURE)))
- {
- if (! body)
- body = start_objects (function_key, priority);
- finish_expr_stmt (build_function_call (fndecl, NULL_TREE));
- }
- }
- }
-
/* Close out the function. */
if (body)
finish_objects (function_key, priority, body);
@@ -2910,11 +2882,9 @@ generate_ctor_and_dtor_functions_for_priority (splay_tree_node n, void * data)
/* Generate the functions themselves, but only if they are really
needed. */
- if (pi->initializations_p
- || (priority == DEFAULT_INIT_PRIORITY && static_ctors))
+ if (pi->initializations_p)
generate_ctor_or_dtor_function (/*constructor_p=*/true, priority, locus);
- if (pi->destructions_p
- || (priority == DEFAULT_INIT_PRIORITY && static_dtors))
+ if (pi->destructions_p)
generate_ctor_or_dtor_function (/*constructor_p=*/false, priority, locus);
/* Keep iterating. */
@@ -3309,17 +3279,11 @@ cp_write_global_declarations (void)
splay_tree_foreach (priority_info_map,
generate_ctor_and_dtor_functions_for_priority,
/*data=*/&locus);
- else
- {
- /* If we have a ctor or this is obj-c++ and we need a static init,
- call generate_ctor_or_dtor_function. */
- if (static_ctors || (c_dialect_objc () && objc_static_init_needed_p ()))
- generate_ctor_or_dtor_function (/*constructor_p=*/true,
- DEFAULT_INIT_PRIORITY, &locus);
- if (static_dtors)
- generate_ctor_or_dtor_function (/*constructor_p=*/false,
- DEFAULT_INIT_PRIORITY, &locus);
- }
+ else if (c_dialect_objc () && objc_static_init_needed_p ())
+ /* If this is obj-c++ and we need a static init, call
+ generate_ctor_or_dtor_function. */
+ generate_ctor_or_dtor_function (/*constructor_p=*/true,
+ DEFAULT_INIT_PRIORITY, &locus);
/* We're done with the splay-tree now. */
if (priority_info_map)
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index c4cdd954982..71c16e07e11 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3099,7 +3099,7 @@ expand_body (tree fn)
generating trees for a function. */
gcc_assert (function_depth == 0);
- tree_rest_of_compilation (fn);
+ c_expand_body (fn);
current_function_decl = saved_function;
@@ -3159,18 +3159,6 @@ expand_or_defer_fn (tree fn)
return;
}
- /* If this function is marked with the constructor attribute, add it
- to the list of functions to be called along with constructors
- from static duration objects. */
- if (DECL_STATIC_CONSTRUCTOR (fn))
- static_ctors = tree_cons (NULL_TREE, fn, static_ctors);
-
- /* If this function is marked with the destructor attribute, add it
- to the list of functions to be called along with destructors from
- static duration objects. */
- if (DECL_STATIC_DESTRUCTOR (fn))
- static_dtors = tree_cons (NULL_TREE, fn, static_dtors);
-
/* We make a decision about linkage for these functions at the end
of the compilation. Until that point, we do not want the back
end to output them -- but we do want it to see the bodies of