diff options
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 960e4cf..b3358c2 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -749,6 +749,8 @@ static tree handle_alias_attribute PARAMS ((tree *, tree, tree, int, bool *)); static tree handle_visibility_attribute PARAMS ((tree *, tree, tree, int, bool *)); +static tree handle_tls_model_attribute PARAMS ((tree *, tree, tree, int, + bool *)); static tree handle_no_instrument_function_attribute PARAMS ((tree *, tree, tree, int, bool *)); @@ -847,6 +849,8 @@ const struct attribute_spec c_common_attribute_table[] = handle_vector_size_attribute }, { "visibility", 1, 1, true, false, false, handle_visibility_attribute }, + { "tls_model", 1, 1, true, false, false, + handle_tls_model_attribute }, { "nonnull", 0, -1, false, true, true, handle_nonnull_attribute }, { "nothrow", 0, 0, true, false, false, @@ -5895,6 +5899,49 @@ handle_visibility_attribute (node, name, args, flags, no_add_attrs) return NULL_TREE; } +/* Handle an "tls_model" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_tls_model_attribute (node, name, args, flags, no_add_attrs) + tree *node; + tree name; + tree args; + int flags ATTRIBUTE_UNUSED; + bool *no_add_attrs; +{ + tree decl = *node; + + if (! DECL_THREAD_LOCAL (decl)) + { + warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); + *no_add_attrs = true; + } + else + { + tree id; + + id = TREE_VALUE (args); + if (TREE_CODE (id) != STRING_CST) + { + error ("tls_model arg not a string"); + *no_add_attrs = true; + return NULL_TREE; + } + if (strcmp (TREE_STRING_POINTER (id), "local-exec") + && strcmp (TREE_STRING_POINTER (id), "initial-exec") + && strcmp (TREE_STRING_POINTER (id), "local-dynamic") + && strcmp (TREE_STRING_POINTER (id), "global-dynamic")) + { + error ("tls_model arg must be one of \"local-exec\", \"initial-exec\", \"local-dynamic\" or \"global-dynamic\""); + *no_add_attrs = true; + return NULL_TREE; + } + } + + return NULL_TREE; +} + /* Handle a "no_instrument_function" attribute; arguments as in struct attribute_spec.handler. */ |