linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 04/10] attribute: remove argument 'keywords' from handle_attributes()
Date: Sun,  9 Aug 2020 22:53:23 +0200	[thread overview]
Message-ID: <20200809205329.42811-5-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200809205329.42811-1-luc.vanoostenryck@gmail.com>

Now that the asm names are handled in handle_asm(), the 'keywords'
argument of handle_attributes() is no more needed since it always
must be 'KW_ATTRIBUTE'.

So, remove this argument.

Note: this is preparation work to later make the distinction between
      function/variable/type/label/... attributes.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 parse.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/parse.c b/parse.c
index 73ec579cfa7f..ec675f20ef01 100644
--- a/parse.c
+++ b/parse.c
@@ -49,7 +49,7 @@ struct symbol_list *function_computed_target_list;
 struct statement_list *function_computed_goto_list;
 
 static struct token *statement(struct token *token, struct statement **tree);
-static struct token *handle_attributes(struct token *token, struct decl_state *ctx, unsigned int keywords);
+static struct token *handle_attributes(struct token *token, struct decl_state *ctx);
 
 typedef struct token *declarator_t(struct token *, struct decl_state *);
 static declarator_t
@@ -756,7 +756,7 @@ static struct token *struct_union_enum_specifier(enum type type,
 	struct symbol *sym;
 	struct position *repos;
 
-	token = handle_attributes(token, ctx, KW_ATTRIBUTE);
+	token = handle_attributes(token, ctx);
 	if (token_type(token) == TOKEN_IDENT) {
 		sym = lookup_symbol(token->ident, NS_STRUCT);
 		if (!sym ||
@@ -956,7 +956,7 @@ static struct token *parse_enum_declaration(struct token *token, struct symbol *
 		struct symbol *sym;
 
 		// FIXME: only 'deprecated' should be accepted
-		next = handle_attributes(next, &ctx, KW_ATTRIBUTE);
+		next = handle_attributes(next, &ctx);
 
 		if (match_op(next, '=')) {
 			next = constant_expression(next->next, &expr);
@@ -1805,7 +1805,7 @@ static struct token *skip_attributes(struct token *token)
 	return token;
 }
 
-static struct token *handle_attributes(struct token *token, struct decl_state *ctx, unsigned int keywords)
+static struct token *handle_attributes(struct token *token, struct decl_state *ctx)
 {
 	struct symbol *keyword;
 	for (;;) {
@@ -1814,7 +1814,7 @@ static struct token *handle_attributes(struct token *token, struct decl_state *c
 		keyword = lookup_keyword(token->ident, NS_KEYWORD | NS_TYPEDEF);
 		if (!keyword || keyword->type != SYM_KEYWORD)
 			break;
-		if (!(keyword->op->type & keywords))
+		if (!(keyword->op->type & KW_ATTRIBUTE))
 			break;
 		token = keyword->op->declarator(token->next, ctx);
 	}
@@ -1903,8 +1903,7 @@ static struct token *direct_declarator(struct token *token, struct decl_state *c
 	    is_nested(token, &next, ctx->prefer_abstract)) {
 		struct symbol *base_type = ctype->base_type;
 		if (token->next != next)
-			next = handle_attributes(token->next, ctx,
-						  KW_ATTRIBUTE);
+			next = handle_attributes(token->next, ctx);
 		token = declarator(next, ctx);
 		token = expect(token, ')', "in nested declarator");
 		while (ctype->base_type != base_type)
@@ -2027,7 +2026,7 @@ static struct token *declaration_list(struct token *token, struct symbol_list **
 		if (match_op(token, ':'))
 			token = handle_bitfield(token, &ctx);
 
-		token = handle_attributes(token, &ctx, KW_ATTRIBUTE);
+		token = handle_attributes(token, &ctx);
 		apply_modifiers(token->pos, &ctx);
 
 		decl->ctype = ctx.ctype;
@@ -2067,7 +2066,7 @@ static struct token *parameter_declaration(struct token *token, struct symbol *s
 	token = declaration_specifiers(token, &ctx);
 	ctx.ident = &sym->ident;
 	token = declarator(token, &ctx);
-	token = handle_attributes(token, &ctx, KW_ATTRIBUTE);
+	token = handle_attributes(token, &ctx);
 	apply_modifiers(token->pos, &ctx);
 	sym->ctype = ctx.ctype;
 	sym->ctype.modifiers |= decl_modifiers(&ctx);
@@ -2567,7 +2566,7 @@ static struct token *handle_label_attributes(struct token *token, struct symbol
 {
 	struct decl_state ctx = { };
 
-	token = handle_attributes(token, &ctx, KW_ATTRIBUTE);
+	token = handle_attributes(token, &ctx);
 	label->label_modifiers = ctx.ctype.modifiers;
 	return token;
 }
@@ -3028,7 +3027,7 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis
 	saved = ctx.ctype;
 	token = declarator(token, &ctx);
 	token = handle_asm_name(token, &ctx);
-	token = handle_attributes(token, &ctx, KW_ATTRIBUTE);
+	token = handle_attributes(token, &ctx);
 	apply_modifiers(token->pos, &ctx);
 
 	decl->ctype = ctx.ctype;
@@ -3150,10 +3149,10 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis
 		ident = NULL;
 		decl = alloc_symbol(token->pos, SYM_NODE);
 		ctx.ctype = saved;
-		token = handle_attributes(token, &ctx, KW_ATTRIBUTE);
+		token = handle_attributes(token, &ctx);
 		token = declarator(token, &ctx);
 		token = handle_asm_name(token, &ctx);
-		token = handle_attributes(token, &ctx, KW_ATTRIBUTE);
+		token = handle_attributes(token, &ctx);
 		apply_modifiers(token->pos, &ctx);
 		decl->ctype = ctx.ctype;
 		decl->ctype.modifiers |= mod;
-- 
2.28.0


  parent reply	other threads:[~2020-08-09 20:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-09 20:53 [PATCH 00/10] separate parsing of asm-names from attributes Luc Van Oostenryck
2020-08-09 20:53 ` [PATCH 01/10] use lookup_keyword() for qualifiers Luc Van Oostenryck
2020-08-09 20:53 ` [PATCH 02/10] attribute: split handle_asm_name() from handle_attributes() Luc Van Oostenryck
2020-08-09 20:53 ` [PATCH 03/10] attribute: fold parse_asm_declarator() into handle_asm_name() Luc Van Oostenryck
2020-08-09 20:53 ` Luc Van Oostenryck [this message]
2020-08-09 20:53 ` [PATCH 05/10] attribute: directly use attribute_specifier() to handle attributes Luc Van Oostenryck
2020-08-09 20:53 ` [PATCH 06/10] attribute: factorize matching of '__attribute__' Luc Van Oostenryck
2020-08-09 20:53 ` [PATCH 07/10] attribute: no need to lookup '__attribute__' in NS_KEYWORD Luc Van Oostenryck
2020-08-09 20:53 ` [PATCH 08/10] testing for SYM_KEYWORD is unneeded for lookup_keyword() Luc Van Oostenryck
2020-08-09 20:53 ` [PATCH 09/10] testing for sym->op " Luc Van Oostenryck
2020-08-09 20:53 ` [PATCH 10/10] keyword type is a bitmask and must be tested so Luc Van Oostenryck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200809205329.42811-5-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).