All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] simplify parsing of inline/__tls/__visible
@ 2020-05-18 23:42 Luc Van Oostenryck
  2020-05-18 23:42 ` [PATCH 1/3] attribute: '__tls' is just another 'declaration' modifier Luc Van Oostenryck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-05-18 23:42 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

This is a follow-up of the previous series "improve handling
of function attributes" removinf the special cases that were
needed to parse and handle these 3 specifiers.

Luc Van Oostenryck (3):
  attribute: '__tls' is just another 'declaration' modifier
  attribute: 'inline' is just another 'declaration' modifier
  attribute: 'externally_visible' is just another 'declaration' modifier

 parse.c                    | 26 +++++++-------------------
 symbol.h                   |  5 ++---
 validation/attr-visible.c  |  1 -
 validation/attr-visible2.c |  1 -
 4 files changed, 9 insertions(+), 24 deletions(-)


base-commit: 146e6a63e715e0c3e08aacbcaa79ff8930289297
-- 
2.26.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] attribute: '__tls' is just another 'declaration' modifier
  2020-05-18 23:42 [PATCH 0/3] simplify parsing of inline/__tls/__visible Luc Van Oostenryck
@ 2020-05-18 23:42 ` Luc Van Oostenryck
  2020-05-18 23:42 ` [PATCH 2/3] attribute: 'inline' " Luc Van Oostenryck
  2020-05-18 23:42 ` [PATCH 3/3] attribute: 'externally_visible' " Luc Van Oostenryck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-05-18 23:42 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

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>
---
 parse.c  | 6 +++---
 symbol.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/parse.c b/parse.c
index 9e7b74f98638..81b2116fcf8b 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 7241f13df4e4..95f90a5c33be 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)
 
 
 
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] attribute: 'inline' is just another 'declaration' modifier
  2020-05-18 23:42 [PATCH 0/3] simplify parsing of inline/__tls/__visible Luc Van Oostenryck
  2020-05-18 23:42 ` [PATCH 1/3] attribute: '__tls' is just another 'declaration' modifier Luc Van Oostenryck
@ 2020-05-18 23:42 ` Luc Van Oostenryck
  2020-05-18 23:42 ` [PATCH 3/3] attribute: 'externally_visible' " Luc Van Oostenryck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-05-18 23:42 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

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>
---
 parse.c  | 4 ++--
 symbol.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/parse.c b/parse.c
index 81b2116fcf8b..8e4be227cec1 100644
--- a/parse.c
+++ b/parse.c
@@ -1399,7 +1399,7 @@ 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)
+	return mod[ctx->storage_class]
 		| (ctx->is_ext_visible ? MOD_EXT_VISIBLE : 0) | mods;
 }
 
@@ -1475,7 +1475,7 @@ static struct token *attribute_force(struct token *token, struct symbol *attr, s
 
 static struct token *inline_specifier(struct token *next, struct decl_state *ctx)
 {
-	ctx->is_inline = 1;
+	apply_qualifier(&next->pos, &ctx->ctype, MOD_INLINE);
 	return next;
 }
 
diff --git a/symbol.h b/symbol.h
index 95f90a5c33be..26f92ca79492 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;
+	unsigned char prefer_abstract, 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_TLS|MOD_GNU_INLINE|MOD_UNUSED|MOD_PURE|MOD_NORETURN|MOD_EXT_VISIBLE)
+#define MOD_DECLARE	(MOD_STORAGE|MOD_INLINE|MOD_TLS|MOD_GNU_INLINE|MOD_UNUSED|MOD_PURE|MOD_NORETURN|MOD_EXT_VISIBLE)
 
 
 
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] attribute: 'externally_visible' is just another 'declaration' modifier
  2020-05-18 23:42 [PATCH 0/3] simplify parsing of inline/__tls/__visible Luc Van Oostenryck
  2020-05-18 23:42 ` [PATCH 1/3] attribute: '__tls' is just another 'declaration' modifier Luc Van Oostenryck
  2020-05-18 23:42 ` [PATCH 2/3] attribute: 'inline' " Luc Van Oostenryck
@ 2020-05-18 23:42 ` Luc Van Oostenryck
  2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-05-18 23:42 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

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.
Even more so because this special casing made this attribute
to be ignored when placed after the declarator.

So, use the the generic code for 'declaration modifiers'
to parse this attribute.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 parse.c                    | 18 +++---------------
 symbol.h                   |  1 -
 validation/attr-visible.c  |  1 -
 validation/attr-visible2.c |  1 -
 4 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/parse.c b/parse.c
index 8e4be227cec1..c1a72ae250d3 100644
--- a/parse.c
+++ b/parse.c
@@ -84,7 +84,6 @@ typedef struct token *attr_t(struct token *, struct symbol *,
 static attr_t
 	attribute_packed, attribute_aligned, attribute_modifier,
 	attribute_function,
-	attribute_ext_visible,
 	attribute_bitwise,
 	attribute_address_space, attribute_context,
 	attribute_designated_init,
@@ -389,10 +388,6 @@ static struct symbol_op attr_fun_op = {
 	.attribute = attribute_function,
 };
 
-static struct symbol_op ext_visible_op = {
-	.attribute = attribute_ext_visible,
-};
-
 static struct symbol_op attr_bitwise_op = {
 	.attribute = attribute_bitwise,
 };
@@ -573,6 +568,8 @@ static struct init_keyword {
 	{ "__safe__",	NS_KEYWORD,	MOD_SAFE, 	.op = &attr_mod_op },
 	{ "unused",	NS_KEYWORD,	MOD_UNUSED,	.op = &attr_mod_op },
 	{ "__unused__",	NS_KEYWORD,	MOD_UNUSED,	.op = &attr_mod_op },
+	{ "externally_visible",	NS_KEYWORD, MOD_EXT_VISIBLE,.op = &attr_mod_op },
+	{ "__externally_visible__", NS_KEYWORD,MOD_EXT_VISIBLE,.op = &attr_mod_op },
 	{ "force",	NS_KEYWORD,	.op = &attr_force_op },
 	{ "__force__",	NS_KEYWORD,	.op = &attr_force_op },
 	{ "bitwise",	NS_KEYWORD,	MOD_BITWISE,	.op = &attr_bitwise_op },
@@ -592,8 +589,6 @@ static struct init_keyword {
 	{"__const__",	NS_KEYWORD,	MOD_PURE,	.op = &attr_fun_op },
 	{"gnu_inline",	NS_KEYWORD,	MOD_GNU_INLINE,	.op = &attr_fun_op },
 	{"__gnu_inline__",NS_KEYWORD,	MOD_GNU_INLINE,	.op = &attr_fun_op },
-	{"externally_visible",	NS_KEYWORD,	.op = &ext_visible_op },
-	{"__externally_visible__",	NS_KEYWORD,	.op = &ext_visible_op },
 
 	{ "mode",	NS_KEYWORD,	.op = &mode_op },
 	{ "__mode__",	NS_KEYWORD,	.op = &mode_op },
@@ -1155,12 +1150,6 @@ static struct token *attribute_function(struct token *token, struct symbol *attr
 	return token;
 }
 
-static struct token *attribute_ext_visible(struct token *token, struct symbol *attr, struct decl_state *ctx)
-{
-	ctx->is_ext_visible = 1;
-	return token;
-}
-
 static struct token *attribute_bitwise(struct token *token, struct symbol *attr, struct decl_state *ctx)
 {
 	if (Wbitwise)
@@ -1399,8 +1388,7 @@ 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_ext_visible ? MOD_EXT_VISIBLE : 0) | mods;
+	return mod[ctx->storage_class] | mods;
 }
 
 static void set_storage_class(struct position *pos, struct decl_state *ctx, int class)
diff --git a/symbol.h b/symbol.h
index 26f92ca79492..92ccbddb2c04 100644
--- a/symbol.h
+++ b/symbol.h
@@ -109,7 +109,6 @@ struct decl_state {
 	struct symbol_op *mode;
 	unsigned long f_modifiers;		// function attributes
 	unsigned char prefer_abstract, storage_class;
-	unsigned char is_ext_visible;
 	unsigned char autotype;
 };
 
diff --git a/validation/attr-visible.c b/validation/attr-visible.c
index 38ee857522ca..ce35e4e53ac8 100644
--- a/validation/attr-visible.c
+++ b/validation/attr-visible.c
@@ -9,5 +9,4 @@ int flag __visible;
 /*
  * check-name: attr-visible
  * check-command: sparse -Wdecl $file
- * check-known-to-fail
  */
diff --git a/validation/attr-visible2.c b/validation/attr-visible2.c
index 62949b479aea..989181692107 100644
--- a/validation/attr-visible2.c
+++ b/validation/attr-visible2.c
@@ -6,5 +6,4 @@ int arr[2] __visible;
 /*
  * check-name: attr-visible-after
  * check-command: sparse -Wdecl $file
- * check-known-to-fail
  */
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-18 23:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 23:42 [PATCH 0/3] simplify parsing of inline/__tls/__visible Luc Van Oostenryck
2020-05-18 23:42 ` [PATCH 1/3] attribute: '__tls' is just another 'declaration' modifier Luc Van Oostenryck
2020-05-18 23:42 ` [PATCH 2/3] attribute: 'inline' " Luc Van Oostenryck
2020-05-18 23:42 ` [PATCH 3/3] attribute: 'externally_visible' " Luc Van Oostenryck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.