mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-20 03:44:19 +08:00
arm64-asm.c: reject invalid operands in parse_operand()
Previously, parse_operand() would silently accept any unrecognized token and pass it to asm_expr() as an immediate, causing typos like: add x0, x1, xyz ; 'xyz' is not a valid register to be silently assembled as a symbol reference instead of erroring. Now, if a token is not a register, condition code, or valid immediate prefix (#, :, @, $), an error is emitted for identifier tokens. This implements fail-fast behavior for invalid operands, making it easier to catch typos and mistakes in assembly code.
This commit is contained in:
parent
95c17cae64
commit
a1bf1d187d
10
arm64-asm.c
10
arm64-asm.c
@ -258,9 +258,15 @@ static void parse_operand(TCCState *s1, Operand *op)
|
||||
/* Immediate or address expression */
|
||||
if (tok == '#' || tok == ':' || tok == '@' || tok == '$') {
|
||||
next();
|
||||
asm_expr(s1, &op->e);
|
||||
op->type = OP_IM;
|
||||
} else if (tok >= TOK_IDENT) {
|
||||
tcc_error("invalid operand '%s'", get_tok_str(tok, &tokc));
|
||||
op->type = OP_IM;
|
||||
} else {
|
||||
asm_expr(s1, &op->e);
|
||||
op->type = OP_IM;
|
||||
}
|
||||
asm_expr(s1, &op->e);
|
||||
op->type = OP_IM;
|
||||
}
|
||||
|
||||
/* Parse address operand in brackets [xn, ...] */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user