diff options
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 02ffa99..8243ad7 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -400,6 +400,10 @@ static int keep_next_if_subblocks; static struct binding_level *label_level_chain; +/* Functions called automatically at the beginning and end of execution. */ + +tree static_ctors, static_dtors; + /* Forward declarations. */ static tree grokparms (), grokdeclarator (); @@ -1744,6 +1748,12 @@ duplicate_decls (newdecl, olddecl) if (DECL_SECTION_NAME (newdecl) == NULL_TREE) DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl); + if (TREE_CODE (newdecl) == FUNCTION_DECL) + { + DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl); + DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl); + } + pop_obstacks (); } /* If cannot merge, then use the new type and qualifiers, @@ -6749,6 +6759,25 @@ finish_function (nested) DECL_ARGUMENTS (fndecl) = 0; } + if (DECL_STATIC_CONSTRUCTOR (fndecl)) + { +#ifndef ASM_OUTPUT_CONSTRUCTOR + if (! flag_gnu_linker) + static_ctors = perm_tree_cons (NULL_TREE, fndecl, static_ctors); + else +#endif + assemble_constructor (IDENTIFIER_POINTER (DECL_NAME (fndecl))); + } + if (DECL_STATIC_DESTRUCTOR (fndecl)) + { +#ifndef ASM_OUTPUT_DESTRUCTOR + if (! flag_gnu_linker) + static_dtors = perm_tree_cons (NULL_TREE, fndecl, static_dtors); + else +#endif + assemble_destructor (IDENTIFIER_POINTER (DECL_NAME (fndecl))); + } + if (! nested) { /* Let the error reporting routines know that we're outside a |