aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2025-09-05 15:40:51 -0700
committerH.J. Lu <hjl.tools@gmail.com>2025-09-08 14:11:17 -0700
commit8cad8f94b450be9b73d07bdeef7fa1778d3f2b96 (patch)
treeb35dde8279217c060771115c3d547ed245af125a /gcc
parentd199a9c7c5034d0eddb3380a58342a5bcbe6febd (diff)
downloadgcc-8cad8f94b450be9b73d07bdeef7fa1778d3f2b96.zip
gcc-8cad8f94b450be9b73d07bdeef7fa1778d3f2b96.tar.gz
gcc-8cad8f94b450be9b73d07bdeef7fa1778d3f2b96.tar.bz2
c: Update TLS model after processing a TLS variable
Set a tentative TLS model in grokvardecl and update TLS mode with the default TLS access model after a TLS variable has been fully processed if the default TLS access model is stronger. gcc/c/ PR c/107419 * c-decl.cc (c_decl_attributes): Update TLS model with the default TLS access model if the default TLS access model is stronger. (grokdeclarator): Set a tentative TLS model which will be updated by c_decl_attributes later. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/c-decl.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 589abf4..62a0545 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -5582,7 +5582,16 @@ c_decl_attributes (tree *node, tree attributes, int flags)
tree last_decl = lookup_last_decl (*node);
if (last_decl == error_mark_node)
last_decl = NULL_TREE;
- return decl_attributes (node, attributes, flags, last_decl);
+ tree attr = decl_attributes (node, attributes, flags, last_decl);
+ if (VAR_P (*node) && DECL_THREAD_LOCAL_P (*node))
+ {
+ // tls_model attribute can set a stronger TLS access model.
+ tls_model model = DECL_TLS_MODEL (*node);
+ tls_model default_model = decl_default_tls_model (*node);
+ if (default_model > model)
+ set_decl_tls_model (*node, default_model);
+ }
+ return attr;
}
@@ -8181,8 +8190,11 @@ grokdeclarator (const struct c_declarator *declarator,
TREE_PUBLIC (decl) = extern_ref;
}
+ // NB: Set a tentative TLS model to avoid tls_model attribute
+ // warnings due to lack of thread storage duration. It will
+ // be updated by c_decl_attributes later.
if (threadp)
- set_decl_tls_model (decl, decl_default_tls_model (decl));
+ set_decl_tls_model (decl, TLS_MODEL_REAL);
}
if ((storage_class == csc_extern