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-lang.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-lang.c')
-rw-r--r-- | gcc/c-lang.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/c-lang.c b/gcc/c-lang.c index 8b46b3c..d429bea 100644 --- a/gcc/c-lang.c +++ b/gcc/c-lang.c @@ -127,3 +127,53 @@ GNU_xref_end () { fatal ("GCC does not yet support XREF"); } + +/* called at end of parsing, but before end-of-file processing. */ +void +finish_file () +{ + extern tree static_ctors, static_dtors; + extern tree get_file_function_name (); + extern tree build_function_call PROTO((tree, tree)); + tree void_list_node = build_tree_list (NULL_TREE, void_type_node); +#ifndef ASM_OUTPUT_CONSTRUCTOR + if (static_ctors) + { + tree fnname = get_file_function_name ('I'); + start_function (void_list_node, + build_parse_node (CALL_EXPR, fnname, void_list_node, + NULL_TREE), + 0); + fnname = DECL_ASSEMBLER_NAME (current_function_decl); + store_parm_decls (); + + for (; static_ctors; static_ctors = TREE_CHAIN (static_ctors)) + expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors), + NULL_TREE)); + + finish_function (0); + + assemble_constructor (IDENTIFIER_POINTER (fnname)); + } +#endif +#ifndef ASM_OUTPUT_DESTRUCTOR + if (static_dtors) + { + tree fnname = get_file_function_name ('D'); + start_function (void_list_node, + build_parse_node (CALL_EXPR, fnname, void_list_node, + NULL_TREE), + 0); + fnname = DECL_ASSEMBLER_NAME (current_function_decl); + store_parm_decls (); + + for (; static_dtors; static_dtors = TREE_CHAIN (static_dtors)) + expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors), + NULL_TREE)); + + finish_function (0); + + assemble_destructor (IDENTIFIER_POINTER (fnname)); + } +#endif +} |