diff options
author | Jason Merrill <merrill@gnu.org> | 1995-01-14 01:09:01 +0000 |
---|---|---|
committer | Jason Merrill <merrill@gnu.org> | 1995-01-14 01:09:01 +0000 |
commit | 2c5f4139a91db294f1ab34da9bbae585d8c65eb2 (patch) | |
tree | 9af815a0feebeea5b32fc5a358886913ab5dd30e /gcc/c-decl.c | |
parent | 34cd1bd74c2afe5a0e14182e7275836d91ed462d (diff) | |
download | gcc-2c5f4139a91db294f1ab34da9bbae585d8c65eb2.zip gcc-2c5f4139a91db294f1ab34da9bbae585d8c65eb2.tar.gz gcc-2c5f4139a91db294f1ab34da9bbae585d8c65eb2.tar.bz2 |
__attribute__ ((constructor))
From-SVN: r8747
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 |