aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2007-02-26 21:14:24 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2007-02-26 21:14:24 +0000
commit57a4c089e23551d96817d080a2fce4f9e6408343 (patch)
tree57f11202334c7de856e122ac7abb9d371c2ac950 /gcc/c-decl.c
parent7276d368253cf2ba1d171f49dc21d90a1b897de7 (diff)
downloadgcc-57a4c089e23551d96817d080a2fce4f9e6408343.zip
gcc-57a4c089e23551d96817d080a2fce4f9e6408343.tar.gz
gcc-57a4c089e23551d96817d080a2fce4f9e6408343.tar.bz2
c-decl.c (static_ctors): Move to c-common.c.
* c-decl.c (static_ctors): Move to c-common.c. (static_dtors): Likewise. (finish_function): Use c_record_cdtor_fn. (build_cdtor): Move to c-common.c. (c_write_global_declarations): Use c_build_cdtor_fns. * c-common.h (static_ctors): Declare. (static_dtors): Likewise. (c_record_cdtor_fn): Likewise. (c_build_cdtor_fns): Likewise. * c-common.c (static_ctors): New variable. (static_dtors): Likewise. (c_record_cdtor_fn): New function. (build_cdtor): Move from c-decl.c (c_build_cdtor_fns): New function. * semantics.c (expand_or_defer_fn): Call c_record_cdtor_fn. * decl2.c (cp_write_gloabl_declarations): Call c_build_cdtor_fns. From-SVN: r122341
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c42
1 files changed, 6 insertions, 36 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index ec567a5..a84dea6 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -411,11 +411,6 @@ static bool keep_next_level_flag;
static bool next_is_function_body;
-/* Functions called automatically at the beginning and end of execution. */
-
-static GTY(()) tree static_ctors;
-static GTY(()) tree static_dtors;
-
/* Forward declarations. */
static tree lookup_name_in_scope (tree, struct c_scope *);
static tree c_make_fname_decl (tree, int);
@@ -6776,14 +6771,9 @@ finish_function (void)
info for the epilogue. */
cfun->function_end_locus = input_location;
- /* If we don't have ctors/dtors sections, and this is a static
- constructor or destructor, it must be recorded now. */
- if (DECL_STATIC_CONSTRUCTOR (fndecl)
- && !targetm.have_ctors_dtors)
- static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors);
- if (DECL_STATIC_DESTRUCTOR (fndecl)
- && !targetm.have_ctors_dtors)
- static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors);
+ /* Keep track of functions declared with the "constructor" and
+ "destructor" attribute. */
+ c_record_cdtor_fn (fndecl);
/* Finalize the ELF visibility for the function. */
c_determine_visibility (fndecl);
@@ -7812,24 +7802,6 @@ finish_declspecs (struct c_declspecs *specs)
return specs;
}
-/* Synthesize a function which calls all the global ctors or global
- dtors in this file. This is only used for targets which do not
- support .ctors/.dtors sections. FIXME: Migrate into cgraph. */
-static void
-build_cdtor (int method_type, tree cdtors)
-{
- tree body = 0;
-
- if (!cdtors)
- return;
-
- for (; cdtors; cdtors = TREE_CHAIN (cdtors))
- append_to_statement_list (build_function_call (TREE_VALUE (cdtors), 0),
- &body);
-
- cgraph_build_static_cdtor (method_type, body, DEFAULT_INIT_PRIORITY);
-}
-
/* A subroutine of c_write_global_declarations. Perform final processing
on one file scope's declarations (or the external scope's declarations),
GLOBALS. */
@@ -7923,11 +7895,9 @@ c_write_global_declarations (void)
c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
c_write_global_declarations_1 (BLOCK_VARS (ext_block));
- /* Generate functions to call static constructors and destructors
- for targets that do not support .ctors/.dtors sections. These
- functions have magic names which are detected by collect2. */
- build_cdtor ('I', static_ctors); static_ctors = 0;
- build_cdtor ('D', static_dtors); static_dtors = 0;
+ /* Call functions declared with the "constructor" or "destructor"
+ attribute. */
+ c_build_cdtor_fns ();
/* We're done parsing; proceed to optimize and emit assembly.
FIXME: shouldn't be the front end's responsibility to call this. */