aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2012-10-08 10:45:37 -0400
committerJason Merrill <jason@gcc.gnu.org>2012-10-08 10:45:37 -0400
commit7c424acd9ae0f2a99ee54511c00f78371279a328 (patch)
treebc70ed3cb42f2f1614f8ad5ac0a05170d55fe604 /gcc/cp/decl.c
parent5b031b9b56c63fbf2a24638e6ccb8da45ce936c1 (diff)
downloadgcc-7c424acd9ae0f2a99ee54511c00f78371279a328.zip
gcc-7c424acd9ae0f2a99ee54511c00f78371279a328.tar.gz
gcc-7c424acd9ae0f2a99ee54511c00f78371279a328.tar.bz2
Allow dynamic initialization of thread_locals.
gcc/cp/ * decl.c: Define tls_aggregates. (expand_static_init): Remove sorry. Add to tls_aggregates. * cp-tree.h: Declare tls_aggregates. * call.c (set_up_extended_ref_temp): Add to tls_aggregates. * decl2.c (var_needs_tls_wrapper): New. (var_defined_without_dynamic_init): New. (get_tls_init_fn, get_tls_wrapper_fn): New. (generate_tls_wrapper, handle_tls_init): New. (cp_write_global_declarations): Call handle_tls_init and enerate_tls_wrapper. * mangle.c (write_guarded_var_name): Split out from.. (mangle_guard_variable): ...here. (mangle_tls_init_fn, mangle_tls_wrapper_fn): Use it. (decl_tls_wrapper_p): New. * semantics.c (finish_id_expression): Replace use of thread_local variable with a call to its wrapper. libiberty/ * cp-demangle.c (d_special_name, d_dump): Handle TH and TW. (d_make_comp, d_print_comp): Likewise. include/ * demangle.h (enum demangle_component_type): Add DEMANGLE_COMPONENT_TLS_INIT and DEMANGLE_COMPONENT_TLS_WRAPPER. From-SVN: r192211
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 7dc13fb..0b936ea 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -169,6 +169,9 @@ tree global_scope_name;
in the TREE_PURPOSE slot. */
tree static_aggregates;
+/* Like static_aggregates, but for thread_local variables. */
+tree tls_aggregates;
+
/* -- end of C++ */
/* A node for the integer constant 2. */
@@ -6838,16 +6841,6 @@ expand_static_init (tree decl, tree init)
return;
}
- if (DECL_THREAD_LOCAL_P (decl) && !DECL_FUNCTION_SCOPE_P (decl))
- {
- /* We haven't implemented dynamic initialization of non-local
- thread-local storage yet. FIXME transform to singleton
- function. */
- sorry ("thread-local variable %qD with dynamic initialization outside "
- "function scope", decl);
- return;
- }
-
if (DECL_FUNCTION_SCOPE_P (decl))
{
/* Emit code to perform this initialization but once. */
@@ -6976,6 +6969,8 @@ expand_static_init (tree decl, tree init)
finish_if_stmt (if_stmt);
}
}
+ else if (DECL_THREAD_LOCAL_P (decl))
+ tls_aggregates = tree_cons (init, decl, tls_aggregates);
else
static_aggregates = tree_cons (init, decl, static_aggregates);
}