diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-01-17 22:58:01 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-09-27 02:17:34 +0200 |
| commit | 7aeb06b4bff797da4ea85a18738a2fd1f660d744 (patch) | |
| tree | 6955efba6e8474607407b1df654911f1216555c7 /parse.c | |
| parent | 62308ab6a6025f8df926b8af009f68fbebe040b6 (diff) | |
| download | sparse-dev-7aeb06b4bff797da4ea85a18738a2fd1f660d744.tar.gz | |
asm: check earlier that body & constraints are strings
The syntax of extended ASM statements requires that the
bodies & constraints are given via a literal string.
However, at parsing time more general expressions are accepted
and it's checked only at evaluation time if these are effectively
string literals. This has at least two drawbacks:
*) evaluate_asm_statement() is slightly more complicated than
needed, mixing these checks with the real evaluation code
*) in case of error, the diagnostic is issued later than
other syntaxic warnings.
Fix this by checking at parse-time that ASM bodies & constraints
are string literals and not some arbitrary expressions.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -2050,7 +2050,8 @@ static struct token *parse_asm_operands(struct token *token, struct statement *s op->name = token->next->next->ident; token = token->next->next->next; } - token = primary_expression(token->next, &op->constraint); + token = token->next; + token = string_expression(token, &op->constraint, "asm constraint"); token = parens_expression(token, &op->expr, "in asm parameter"); add_expression(inout, op); } while (match_op(token, ',')); @@ -2101,7 +2102,7 @@ static struct token *parse_asm_statement(struct token *token, struct statement * token = token->next; } token = expect(token, '(', "after asm"); - token = parse_expression(token, &stmt->asm_string); + token = string_expression(token, &stmt->asm_string, "inline asm"); if (match_op(token, ':')) token = parse_asm_operands(token, stmt, &stmt->asm_outputs); if (match_op(token, ':')) @@ -2118,7 +2119,7 @@ static struct token *parse_asm_declarator(struct token *token, struct decl_state { struct expression *expr; token = expect(token, '(', "after asm"); - token = parse_expression(token->next, &expr); + token = string_expression(token, &expr, "inline asm"); token = expect(token, ')', "after asm"); return token; } |
