aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/decl.cc')
-rw-r--r--gcc/cp/decl.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index b8e1098..e6f75d7 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -9593,6 +9593,9 @@ get_atexit_node (void)
static tree
get_thread_atexit_node (void)
{
+ if (thread_atexit_node)
+ return thread_atexit_node;
+
/* The declaration for `__cxa_thread_atexit' is:
int __cxa_thread_atexit (void (*)(void *), void *, void *) */
@@ -9601,10 +9604,18 @@ get_thread_atexit_node (void)
ptr_type_node, ptr_type_node,
NULL_TREE);
- /* Now, build the function declaration. */
+ /* Now, build the function declaration, as with __cxa_atexit. */
+ unsigned flags = push_abi_namespace ();
tree atexit_fndecl = build_library_fn_ptr ("__cxa_thread_atexit", fn_type,
ECF_LEAF | ECF_NOTHROW);
- return decay_conversion (atexit_fndecl, tf_warning_or_error);
+ DECL_CONTEXT (atexit_fndecl) = FROB_CONTEXT (current_namespace);
+ DECL_SOURCE_LOCATION (atexit_fndecl) = BUILTINS_LOCATION;
+ atexit_fndecl = pushdecl (atexit_fndecl, /*hiding=*/true);
+ pop_abi_namespace (flags);
+ mark_used (atexit_fndecl);
+ thread_atexit_node = decay_conversion (atexit_fndecl, tf_warning_or_error);
+
+ return thread_atexit_node;
}
/* Returns the __dso_handle VAR_DECL. */