aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-05-18 22:26:28 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-05-19 01:25:48 +0200
commit185572dd1d9eb2afb5d3f33000ad149d96b16ec0 (patch)
treebb00d190f3834c556e0bc2e1e2d8be85d42e583c
parent146e6a63e715e0c3e08aacbcaa79ff8930289297 (diff)
downloadsparse-185572dd1d9eb2afb5d3f33000ad149d96b16ec0.tar.gz
attribute: '__tls' is just another 'declaration' modifier
Now that the distinction is made between type modifiers and 'declaration' modifiers, there is no more reasons to parse this attribute differently than other attributes/modifiers. So, use the the generic code for 'declaration modifiers' to parse this attribute. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--parse.c6
-rw-r--r--symbol.h4
2 files changed, 5 insertions, 5 deletions
diff --git a/parse.c b/parse.c
index 9e7b74f9..81b2116f 100644
--- a/parse.c
+++ b/parse.c
@@ -1400,14 +1400,14 @@ static unsigned long decl_modifiers(struct decl_state *ctx)
unsigned long mods = ctx->ctype.modifiers & MOD_DECLARE;
ctx->ctype.modifiers &= ~MOD_DECLARE;
return mod[ctx->storage_class] | (ctx->is_inline ? MOD_INLINE : 0)
- | (ctx->is_tls ? MOD_TLS : 0)
| (ctx->is_ext_visible ? MOD_EXT_VISIBLE : 0) | mods;
}
static void set_storage_class(struct position *pos, struct decl_state *ctx, int class)
{
+ int is_tls = ctx->ctype.modifiers & MOD_TLS;
/* __thread can be used alone, or with extern or static */
- if (ctx->is_tls && (class != SStatic && class != SExtern)) {
+ if (is_tls && (class != SStatic && class != SExtern)) {
sparse_error(*pos, "__thread can only be used alone, or with "
"extern or static");
return;
@@ -1458,7 +1458,7 @@ static struct token *thread_specifier(struct token *next, struct decl_state *ctx
/* This GCC extension can be used alone, or with extern or static */
if (!ctx->storage_class || ctx->storage_class == SStatic
|| ctx->storage_class == SExtern) {
- ctx->is_tls = 1;
+ apply_qualifier(&next->pos, &ctx->ctype, MOD_TLS);
} else {
sparse_error(next->pos, "__thread can only be used alone, or "
"with extern or static");
diff --git a/symbol.h b/symbol.h
index 7241f13d..95f90a5c 100644
--- a/symbol.h
+++ b/symbol.h
@@ -108,7 +108,7 @@ struct decl_state {
struct ident **ident;
struct symbol_op *mode;
unsigned long f_modifiers; // function attributes
- unsigned char prefer_abstract, is_inline, storage_class, is_tls;
+ unsigned char prefer_abstract, is_inline, storage_class;
unsigned char is_ext_visible;
unsigned char autotype;
};
@@ -264,7 +264,7 @@ struct symbol {
/* do not warn when these are duplicated */
#define MOD_DUP_OK (MOD_UNUSED|MOD_GNU_INLINE)
/* must be part of the declared symbol, not its type */
-#define MOD_DECLARE (MOD_STORAGE|MOD_GNU_INLINE|MOD_UNUSED|MOD_PURE|MOD_NORETURN|MOD_EXT_VISIBLE)
+#define MOD_DECLARE (MOD_STORAGE|MOD_TLS|MOD_GNU_INLINE|MOD_UNUSED|MOD_PURE|MOD_NORETURN|MOD_EXT_VISIBLE)