All of lore.kernel.org
 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 03/10] attribute: fold parse_asm_declarator() into handle_asm_name()
Date: Sun,  9 Aug 2020 22:53:22 +0200	[thread overview]
Message-ID: <20200809205329.42811-4-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200809205329.42811-1-luc.vanoostenryck@gmail.com>

An asm name is not really a declarator, it must only be placed
*after* a declarator and is directly handled by handle_asm_name().
It's thus not needed and possibly confusing to treat it like a
generic declarator.

So, fold parse_asm_declarator() into handle_asm_name() and remove it.

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

diff --git a/parse.c b/parse.c
index cf897e5d2804..73ec579cfa7f 100644
--- a/parse.c
+++ b/parse.c
@@ -54,7 +54,7 @@ static struct token *handle_attributes(struct token *token, struct decl_state *c
 typedef struct token *declarator_t(struct token *, struct decl_state *);
 static declarator_t
 	struct_specifier, union_specifier, enum_specifier,
-	attribute_specifier, typeof_specifier, parse_asm_declarator,
+	attribute_specifier, typeof_specifier,
 	typedef_specifier, inline_specifier, auto_specifier,
 	register_specifier, static_specifier, extern_specifier,
 	thread_specifier, const_qualifier, volatile_qualifier;
@@ -363,7 +363,6 @@ static struct symbol_op range_op = {
 
 static struct symbol_op asm_op = {
 	.type = KW_ASM,
-	.declarator = parse_asm_declarator,
 	.statement = parse_asm_statement,
 	.toplevel = toplevel_asm_declaration,
 };
@@ -1744,6 +1743,7 @@ static struct token *declarator(struct token *token, struct decl_state *ctx);
 
 static struct token *handle_asm_name(struct token *token, struct decl_state *ctx)
 {
+	struct expression *expr;
 	struct symbol *keyword;
 
 	if (token_type(token) != TOKEN_IDENT)
@@ -1753,7 +1753,12 @@ static struct token *handle_asm_name(struct token *token, struct decl_state *ctx
 		return token;
 	if (!(keyword->op->type & KW_ASM))
 		return token;
-	return keyword->op->declarator(token->next, ctx);
+
+	token = token->next;
+	token = expect(token, '(', "after asm");
+	token = string_expression(token, &expr, "asm name");
+	token = expect(token, ')', "after asm");
+	return token;
 }
 
 static struct token *skip_attribute(struct token *token)
@@ -2181,15 +2186,6 @@ static struct token *parse_asm_statement(struct token *token, struct statement *
 	return expect(token, ';', "at end of asm-statement");
 }
 
-static struct token *parse_asm_declarator(struct token *token, struct decl_state *ctx)
-{
-	struct expression *expr;
-	token = expect(token, '(', "after asm");
-	token = string_expression(token, &expr, "inline asm");
-	token = expect(token, ')', "after asm");
-	return token;
-}
-
 static struct token *parse_static_assert(struct token *token, struct symbol_list **unused)
 {
 	struct expression *cond = NULL, *message = NULL;
-- 
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 ` Luc Van Oostenryck [this message]
2020-08-09 20:53 ` [PATCH 04/10] attribute: remove argument 'keywords' " Luc Van Oostenryck
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-4-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 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.