From: Mark Mitchell Date: Thu, 30 Sep 1999 17:43:44 +0000 (+0000) Subject: cp-tree.h (lang_decl_flags): Add global_ctor_p and global_dtor_p. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=af3b4e599c01847d050f491fe3e88fc5ce801b71;p=gcc.git cp-tree.h (lang_decl_flags): Add global_ctor_p and global_dtor_p. * cp-tree.h (lang_decl_flags): Add global_ctor_p and global_dtor_p. Add init_priority. (DECL_ACCESS): Adjust accordingly. (DECL_GLOBAL_CTOR_P, DECL_GLOBAL_DTOR_P): New macros. (GLOBAL_INIT_PRIORITY): Likewise. * decl.c (lang_mark_tree): Adjust accordingly. (start_objects): Set DECL_GLOBAL_CTOR_P, DECL_GLOBAL_DTOR_P, and GLOBAL_INIT_PRIORITY. * dump.c (dequeue_and_dump): Print them. * ir.texi: Document them. From-SVN: r29733 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0272a878642..85a03fea03e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,16 @@ 1999-09-30 Mark Mitchell + * cp-tree.h (lang_decl_flags): Add global_ctor_p and + global_dtor_p. Add init_priority. + (DECL_ACCESS): Adjust accordingly. + (DECL_GLOBAL_CTOR_P, DECL_GLOBAL_DTOR_P): New macros. + (GLOBAL_INIT_PRIORITY): Likewise. + * decl.c (lang_mark_tree): Adjust accordingly. + (start_objects): Set DECL_GLOBAL_CTOR_P, DECL_GLOBAL_DTOR_P, + and GLOBAL_INIT_PRIORITY. + * dump.c (dequeue_and_dump): Print them. + * ir.texi: Document them. + * decl2.c (struct priority_info_s): Remove initialization_sequence and destruction_sequence. (start_static_storage_duration_function): Return the body of the diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a3146ddde8f..c5886fc30b4 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1585,9 +1585,10 @@ struct lang_decl_flags unsigned bitfield : 1; unsigned defined_in_class : 1; unsigned pending_inline_p : 1; - unsigned dummy : 5; + unsigned global_ctor_p : 1; + unsigned global_dtor_p : 1; + unsigned dummy : 3; - tree access; tree context; union { @@ -1597,6 +1598,15 @@ struct lang_decl_flags /* In a NAMESPACE_DECL, this is NAMESPACE_LEVEL. */ struct binding_level *level; } u; + + union { + /* This is DECL_ACCESS. */ + tree access; + + /* In a namespace-scope FUNCTION_DECL, this is + GLOBAL_INIT_PRIORITY. */ + int init_priority; + } u2; }; struct lang_decl @@ -2347,7 +2357,22 @@ extern int flag_new_for_scope; For example, if a member that would normally be public in a derived class is made protected, then the derived class and the protected_access_node will appear in the DECL_ACCESS for the node. */ -#define DECL_ACCESS(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.access) +#define DECL_ACCESS(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.u2.access) + +/* Nonzero if the FUNCTION_DECL is a global constructor. */ +#define DECL_GLOBAL_CTOR_P(NODE) \ + (DECL_LANG_SPECIFIC ((NODE))->decl_flags.global_ctor_p) + +/* Nonzero if the FUNCTION_DECL is a global destructor. */ +#define DECL_GLOBAL_DTOR_P(NODE) \ + (DECL_LANG_SPECIFIC ((NODE))->decl_flags.global_dtor_p) + +/* If DECL_GLOBAL_CTOR_P or DECL_GLOBAL_DTOR_P holds, this macro + returns the initialization priority for the function. Constructors + with lower numbers should be run first. Destructors should be run + in the reverse order of constructors. */ +#define GLOBAL_INIT_PRIORITY(NODE) \ + (DECL_LANG_SPECIFIC ((NODE))->decl_flags.u2.init_priority) /* Accessor macros for C++ template decl nodes. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bdbd1e8c8b1..49d80dc9387 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14293,7 +14293,8 @@ lang_mark_tree (t) if (ld) { ggc_mark (ld); - ggc_mark_tree (ld->decl_flags.access); + if (!DECL_GLOBAL_CTOR_P (t) && !DECL_GLOBAL_DTOR_P (t)) + ggc_mark_tree (ld->decl_flags.u2.access); ggc_mark_tree (ld->decl_flags.context); if (TREE_CODE (t) != NAMESPACE_DECL) ggc_mark_tree (ld->decl_flags.u.template_info); diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c index 747e28d9707..7420c972ae0 100644 --- a/gcc/cp/dump.c +++ b/gcc/cp/dump.c @@ -625,6 +625,15 @@ dequeue_and_dump (di) dump_string (di, "operator"); if (DECL_CONV_FN_P (t)) dump_string (di, "conversion"); + if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t)) + { + if (DECL_GLOBAL_CTOR_P (t)) + dump_string (di, "global init"); + if (DECL_GLOBAL_DTOR_P (t)) + dump_string (di, "global fini"); + dump_int (di, "prio", GLOBAL_INIT_PRIORITY (t)); + } + if (dump_children_p) dump_child ("body", DECL_SAVED_TREE (t)); } diff --git a/gcc/cp/ir.texi b/gcc/cp/ir.texi index f85c657d688..2831e3b7037 100644 --- a/gcc/cp/ir.texi +++ b/gcc/cp/ir.texi @@ -948,6 +948,9 @@ the @code{DECL_REAL_CONTEXT} for @code{f} will be the @findex DECL_OVERLOADED_OPERATOR_P @findex DECL_CONV_FN_P @findex DECL_ARTIFIICIAL +@findex DECL_GLOBAL_CTOR_P +@findex DECL_GLOBAL_DTOR_P +@findex GLOBAL_INIT_PRIORITY The following macros and functions can be used on a @code{FUNCTION_DECL}: @ftable @code @@ -1006,6 +1009,22 @@ This macro holds if the function is an overloaded operator. @item DECL_CONV_FN_P This macro holds if the function is a type-conversion operator. +@item DECL_GLOBAL_CTOR_P +This predicate holds if the function is a file-scope initialization +function. + +@item DECL_GLOBAL_DTOR_P +This predicate holds if the function is a file-scope finalization +function. + +@item GLOBAL_INIT_PRIORITY +If either @code{DECL_GLOBAL_CTOR_P} or @code{DECL_GLOBAL_DTOR_P} holds, +then this gives the initialization priority for the function. The +linker will arrange that all functions for which +@code{DECL_GLOBAL_CTOR_P} holds are run in increasing order of priority +before @code{main} is called. When the program exits, all functions for +which @code{DECL_GLOBAL_DTOR_P} holds are run in the reverse order. + @item DECL_ARTIFICIAL This macro holds if the function was implicitly generated by the compiler, rather than explicitly declared. In addition to implicitly