aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-15 14:34:42 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-25 23:19:12 +0200
commite31f8759b06c20a0e1c26ef94bdb8950326e243e (patch)
tree60cb422e3602c2c7d264f0e02c8c234a858a592f
parentc6b40f4538f8fb3c55ef65f31808b8905a375b6e (diff)
downloadsparse-e31f8759b06c20a0e1c26ef94bdb8950326e243e.tar.gz
attribute: fold parse_asm_declarator() into handle_asm_name()
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>
-rw-r--r--parse.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/parse.c b/parse.c
index cf897e5d..73ec579c 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;