summaryrefslogtreecommitdiffstats
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-28 19:30:41 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-28 19:30:41 +0000
commitfc29cd44f1c047284849a1c71be3ab840f91a479 (patch)
treee5c12c770c62e621116a2a00a3afc04795875cf7 /gcc/cp/decl2.c
parent3a2785797d761c76ad5f4b335eb145c9dbf580b8 (diff)
downloadppe42-gcc-fc29cd44f1c047284849a1c71be3ab840f91a479.tar.gz
ppe42-gcc-fc29cd44f1c047284849a1c71be3ab840f91a479.zip
* decl2.c (generate_ctor_or_dtor_function): Tolerate a
non-existant ssdf_decls array. (finish_file): Call generator_ctor_or_dtor_function when there are static constructors or destructors and no other static initializations. * g++.dg/init/attrib1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64979 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 77b9636a570..88545d46281 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2494,15 +2494,16 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority)
/* Call the static storage duration function with appropriate
arguments. */
- for (i = 0; i < ssdf_decls->elements_used; ++i)
- {
- arguments = tree_cons (NULL_TREE, build_int_2 (priority, 0),
- NULL_TREE);
- arguments = tree_cons (NULL_TREE, build_int_2 (constructor_p, 0),
- arguments);
- finish_expr_stmt (build_function_call (VARRAY_TREE (ssdf_decls, i),
- arguments));
- }
+ if (ssdf_decls)
+ for (i = 0; i < ssdf_decls->elements_used; ++i)
+ {
+ arguments = tree_cons (NULL_TREE, build_int_2 (priority, 0),
+ NULL_TREE);
+ arguments = tree_cons (NULL_TREE, build_int_2 (constructor_p, 0),
+ arguments);
+ finish_expr_stmt (build_function_call (VARRAY_TREE (ssdf_decls, i),
+ arguments));
+ }
/* If we're generating code for the DEFAULT_INIT_PRIORITY, throw in
calls to any functions marked with attributes indicating that
@@ -2510,7 +2511,7 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority)
if (priority == DEFAULT_INIT_PRIORITY)
{
tree fns;
-
+
for (fns = constructor_p ? static_ctors : static_dtors;
fns;
fns = TREE_CHAIN (fns))
@@ -2838,6 +2839,15 @@ finish_file ()
splay_tree_foreach (priority_info_map,
generate_ctor_and_dtor_functions_for_priority,
/*data=*/0);
+ else
+ {
+ if (static_ctors)
+ generate_ctor_or_dtor_function (/*constructor_p=*/true,
+ DEFAULT_INIT_PRIORITY);
+ if (static_dtors)
+ generate_ctor_or_dtor_function (/*constructor_p=*/false,
+ DEFAULT_INIT_PRIORITY);
+ }
/* We're done with the splay-tree now. */
if (priority_info_map)
OpenPOWER on IntegriCloud