diff options
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index ec567a5451d..a84dea67f30 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. */ |