Commit af3b4e59 by Mark Mitchell Committed by Mark Mitchell

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
parent f793a95e
1999-09-30 Mark Mitchell <mark@codesourcery.com> 1999-09-30 Mark Mitchell <mark@codesourcery.com>
* 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 * decl2.c (struct priority_info_s): Remove initialization_sequence
and destruction_sequence. and destruction_sequence.
(start_static_storage_duration_function): Return the body of the (start_static_storage_duration_function): Return the body of the
......
...@@ -1585,9 +1585,10 @@ struct lang_decl_flags ...@@ -1585,9 +1585,10 @@ struct lang_decl_flags
unsigned bitfield : 1; unsigned bitfield : 1;
unsigned defined_in_class : 1; unsigned defined_in_class : 1;
unsigned pending_inline_p : 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; tree context;
union { union {
...@@ -1597,6 +1598,15 @@ struct lang_decl_flags ...@@ -1597,6 +1598,15 @@ struct lang_decl_flags
/* In a NAMESPACE_DECL, this is NAMESPACE_LEVEL. */ /* In a NAMESPACE_DECL, this is NAMESPACE_LEVEL. */
struct binding_level *level; struct binding_level *level;
} u; } 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 struct lang_decl
...@@ -2347,7 +2357,22 @@ extern int flag_new_for_scope; ...@@ -2347,7 +2357,22 @@ extern int flag_new_for_scope;
For example, if a member that would normally be public in a For example, if a member that would normally be public in a
derived class is made protected, then the derived class and the derived class is made protected, then the derived class and the
protected_access_node will appear in the DECL_ACCESS for the node. */ 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. */ /* Accessor macros for C++ template decl nodes. */
......
...@@ -14293,7 +14293,8 @@ lang_mark_tree (t) ...@@ -14293,7 +14293,8 @@ lang_mark_tree (t)
if (ld) if (ld)
{ {
ggc_mark (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); ggc_mark_tree (ld->decl_flags.context);
if (TREE_CODE (t) != NAMESPACE_DECL) if (TREE_CODE (t) != NAMESPACE_DECL)
ggc_mark_tree (ld->decl_flags.u.template_info); ggc_mark_tree (ld->decl_flags.u.template_info);
......
...@@ -625,6 +625,15 @@ dequeue_and_dump (di) ...@@ -625,6 +625,15 @@ dequeue_and_dump (di)
dump_string (di, "operator"); dump_string (di, "operator");
if (DECL_CONV_FN_P (t)) if (DECL_CONV_FN_P (t))
dump_string (di, "conversion"); 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) if (dump_children_p)
dump_child ("body", DECL_SAVED_TREE (t)); dump_child ("body", DECL_SAVED_TREE (t));
} }
......
...@@ -948,6 +948,9 @@ the @code{DECL_REAL_CONTEXT} for @code{f} will be the ...@@ -948,6 +948,9 @@ the @code{DECL_REAL_CONTEXT} for @code{f} will be the
@findex DECL_OVERLOADED_OPERATOR_P @findex DECL_OVERLOADED_OPERATOR_P
@findex DECL_CONV_FN_P @findex DECL_CONV_FN_P
@findex DECL_ARTIFIICIAL @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}: The following macros and functions can be used on a @code{FUNCTION_DECL}:
@ftable @code @ftable @code
...@@ -1006,6 +1009,22 @@ This macro holds if the function is an overloaded operator. ...@@ -1006,6 +1009,22 @@ This macro holds if the function is an overloaded operator.
@item DECL_CONV_FN_P @item DECL_CONV_FN_P
This macro holds if the function is a type-conversion operator. 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 @item DECL_ARTIFICIAL
This macro holds if the function was implicitly generated by the This macro holds if the function was implicitly generated by the
compiler, rather than explicitly declared. In addition to implicitly compiler, rather than explicitly declared. In addition to implicitly
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment