aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5a644d7..9fabde7 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2523,8 +2523,12 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
}
if (VAR_P (newdecl)
- && DECL_THREAD_LOCAL_P (newdecl))
- set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
+ && CP_DECL_THREAD_LOCAL_P (newdecl))
+ {
+ CP_DECL_THREAD_LOCAL_P (olddecl) = true;
+ if (!processing_template_decl)
+ set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
+ }
}
DECL_UID (olddecl) = olddecl_uid;
@@ -2702,14 +2706,14 @@ redeclaration_error_message (tree newdecl, tree olddecl)
return NULL;
}
else if (VAR_P (newdecl)
- && DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl)
+ && CP_DECL_THREAD_LOCAL_P (newdecl) != CP_DECL_THREAD_LOCAL_P (olddecl)
&& (! DECL_LANG_SPECIFIC (olddecl)
|| ! CP_DECL_THREADPRIVATE_P (olddecl)
- || DECL_THREAD_LOCAL_P (newdecl)))
+ || CP_DECL_THREAD_LOCAL_P (newdecl)))
{
/* Only variables can be thread-local, and all declarations must
agree on this property. */
- if (DECL_THREAD_LOCAL_P (newdecl))
+ if (CP_DECL_THREAD_LOCAL_P (newdecl))
return G_("thread-local declaration of %q#D follows "
"non-thread-local declaration");
else
@@ -4859,7 +4863,7 @@ start_decl (const cp_declarator *declarator,
&& DECL_DECLARED_CONSTEXPR_P (current_function_decl))
{
bool ok = false;
- if (DECL_THREAD_LOCAL_P (decl))
+ if (CP_DECL_THREAD_LOCAL_P (decl))
error ("%qD declared %<thread_local%> in %<constexpr%> function",
decl);
else if (TREE_STATIC (decl))
@@ -7056,7 +7060,7 @@ register_dtor_fn (tree decl)
function to do the cleanup. */
dso_parm = (flag_use_cxa_atexit
&& !targetm.cxx.use_atexit_for_cxa_atexit ());
- ob_parm = (DECL_THREAD_LOCAL_P (decl) || dso_parm);
+ ob_parm = (CP_DECL_THREAD_LOCAL_P (decl) || dso_parm);
use_dtor = ob_parm && CLASS_TYPE_P (type);
if (use_dtor)
{
@@ -7099,7 +7103,7 @@ register_dtor_fn (tree decl)
mark_used (cleanup);
cleanup = build_address (cleanup);
- if (DECL_THREAD_LOCAL_P (decl))
+ if (CP_DECL_THREAD_LOCAL_P (decl))
atex_node = get_thread_atexit_node ();
else
atex_node = get_atexit_node ();
@@ -7139,7 +7143,7 @@ register_dtor_fn (tree decl)
if (ob_parm)
{
- if (!DECL_THREAD_LOCAL_P (decl)
+ if (!CP_DECL_THREAD_LOCAL_P (decl)
&& targetm.cxx.use_aeabi_atexit ())
{
arg1 = cleanup;
@@ -7179,7 +7183,7 @@ expand_static_init (tree decl, tree init)
return;
}
- if (DECL_THREAD_LOCAL_P (decl) && DECL_GNU_TLS_P (decl)
+ if (CP_DECL_THREAD_LOCAL_P (decl) && DECL_GNU_TLS_P (decl)
&& !DECL_FUNCTION_SCOPE_P (decl))
{
if (init)
@@ -7208,7 +7212,7 @@ expand_static_init (tree decl, tree init)
tree flag, begin;
/* We don't need thread-safety code for thread-local vars. */
bool thread_guard = (flag_threadsafe_statics
- && !DECL_THREAD_LOCAL_P (decl));
+ && !CP_DECL_THREAD_LOCAL_P (decl));
/* Emit code to perform this initialization but once. This code
looks like:
@@ -7321,7 +7325,7 @@ expand_static_init (tree decl, tree init)
finish_then_clause (if_stmt);
finish_if_stmt (if_stmt);
}
- else if (DECL_THREAD_LOCAL_P (decl))
+ else if (CP_DECL_THREAD_LOCAL_P (decl))
tls_aggregates = tree_cons (init, decl, tls_aggregates);
else
static_aggregates = tree_cons (init, decl, static_aggregates);
@@ -8182,9 +8186,13 @@ grokvardecl (tree type,
if (decl_spec_seq_has_spec_p (declspecs, ds_thread))
{
if (DECL_EXTERNAL (decl) || TREE_STATIC (decl))
- set_decl_tls_model (decl, decl_default_tls_model (decl));
+ {
+ CP_DECL_THREAD_LOCAL_P (decl) = true;
+ if (!processing_template_decl)
+ set_decl_tls_model (decl, decl_default_tls_model (decl));
+ }
if (declspecs->gnu_thread_keyword_p)
- DECL_GNU_TLS_P (decl) = true;
+ SET_DECL_GNU_TLS_P (decl);
}
/* If the type of the decl has no linkage, make sure that we'll
@@ -10857,9 +10865,11 @@ grokdeclarator (const cp_declarator *declarator,
if (thread_p)
{
- set_decl_tls_model (decl, decl_default_tls_model (decl));
+ CP_DECL_THREAD_LOCAL_P (decl) = true;
+ if (!processing_template_decl)
+ set_decl_tls_model (decl, decl_default_tls_model (decl));
if (declspecs->gnu_thread_keyword_p)
- DECL_GNU_TLS_P (decl) = true;
+ SET_DECL_GNU_TLS_P (decl);
}
if (constexpr_p && !initialized)