aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-01-18 04:07:42 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-09-27 02:51:37 +0200
commitaa510823d308bcf27b8dc58ae8f4c13963a0bbcd (patch)
tree6acc0ceeab90e0656edb962799f9c11e30617af0
parent4bee9b6dcb6dfcc2799d29ff7e5d42c6637b1f4d (diff)
downloadsparse-aa510823d308bcf27b8dc58ae8f4c13963a0bbcd.tar.gz
asm: missing evaluation of asm statements
The operands of extended ASM need to have their type evaluated, exactly like any other expression. So, add the missing evaluation of ASM operands. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--evaluate.c18
-rw-r--r--validation/eval/asm-memop.c1
2 files changed, 18 insertions, 1 deletions
diff --git a/evaluate.c b/evaluate.c
index f0f9b4b3..4f7efc48 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -3579,6 +3579,22 @@ static void verify_input_constraint(struct asm_operand *op)
expression_error(expr, "input constraint with assignment (\"%s\")", constraint);
}
+static void evaluate_asm_memop(struct asm_operand *op)
+{
+ if (op->is_memory) {
+ struct expression *expr = op->expr;
+ struct expression *addr;
+
+ // implicit addressof
+ addr = alloc_expression(expr->pos, EXPR_PREOP);
+ addr->op = '&';
+ addr->unop = expr;
+
+ evaluate_addressof(addr);
+ op->expr = addr;
+ }
+}
+
static void evaluate_asm_statement(struct statement *stmt)
{
struct expression *expr;
@@ -3604,6 +3620,7 @@ static void evaluate_asm_statement(struct statement *stmt)
if (!lvalue_expression(expr))
warning(expr->pos, "asm output is not an lvalue");
evaluate_assign_to(expr, expr->ctype);
+ evaluate_asm_memop(op);
} END_FOR_EACH_PTR(op);
FOR_EACH_PTR(stmt->asm_inputs, op) {
@@ -3618,6 +3635,7 @@ static void evaluate_asm_statement(struct statement *stmt)
/* Expression */
if (!evaluate_expression(op->expr))
return;
+ evaluate_asm_memop(op);
} END_FOR_EACH_PTR(op);
FOR_EACH_PTR(stmt->asm_clobbers, expr) {
diff --git a/validation/eval/asm-memop.c b/validation/eval/asm-memop.c
index 9bbb3a30..33ba0e5a 100644
--- a/validation/eval/asm-memop.c
+++ b/validation/eval/asm-memop.c
@@ -9,7 +9,6 @@ void fo3(int *p) { asm volatile ("op %0" :: "m" (*p)); }
/*
* check-name: eval-asm-memop
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-start
fo0: