parser: fix multiple output modifiers in asm (#10347)
parent
751b1cffd3
commit
9553c5a4e6
|
@ -1577,7 +1577,7 @@ pub fn (expr Expr) is_expr() bool {
|
|||
|
||||
pub fn (expr Expr) is_lit() bool {
|
||||
return match expr {
|
||||
BoolLiteral, StringLiteral, IntegerLiteral { true }
|
||||
BoolLiteral, CharLiteral, StringLiteral, IntegerLiteral { true }
|
||||
else { false }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1558,9 +1558,11 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) (string, token.Position) {
|
|||
return '', pos
|
||||
}
|
||||
else {
|
||||
if !expr.is_lit() {
|
||||
c.error('unexpected expression `$expr.type_name()`', expr.position())
|
||||
}
|
||||
}
|
||||
}
|
||||
if explicit_lock_needed {
|
||||
c.error('`$to_lock` is `shared` and needs explicit lock for `$expr.type_name()`',
|
||||
pos)
|
||||
|
|
|
@ -1411,7 +1411,7 @@ fn (mut p Parser) asm_ios(output bool) []ast.AsmIO {
|
|||
if mut expr is ast.ParExpr {
|
||||
expr = expr.expr
|
||||
} else {
|
||||
p.error('asm in/output must be incolsed in brackets $expr.type_name()')
|
||||
p.error('asm in/output must be incolsed in brackets')
|
||||
}
|
||||
mut alias := ''
|
||||
if p.tok.kind == .key_as {
|
||||
|
|
|
@ -352,6 +352,9 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr {
|
|||
|
||||
pub fn (mut p Parser) expr_with_left(left ast.Expr, precedence int, is_stmt_ident bool) ast.Expr {
|
||||
mut node := left
|
||||
if p.inside_asm && p.prev_tok.position().line_nr < p.tok.position().line_nr {
|
||||
return node
|
||||
}
|
||||
// Infix
|
||||
for precedence < p.tok.precedence() {
|
||||
if p.tok.kind == .dot {
|
||||
|
|
|
@ -169,4 +169,17 @@ fn test_flag_output() {
|
|||
; r (zero)
|
||||
}
|
||||
assert out
|
||||
|
||||
mut maybe_four := 4
|
||||
mut four := 4
|
||||
asm amd64 {
|
||||
subl four, maybe_four
|
||||
testl four, maybe_four
|
||||
movl maybe_four, 9
|
||||
; +m (maybe_four)
|
||||
+r (four)
|
||||
=@ccz (out)
|
||||
}
|
||||
assert out
|
||||
assert maybe_four == 9
|
||||
}
|
||||
|
|
|
@ -151,4 +151,17 @@ fn test_flag_output() {
|
|||
; r (zero)
|
||||
}
|
||||
assert out
|
||||
|
||||
mut maybe_four := 4
|
||||
mut four := 4
|
||||
asm amd64 {
|
||||
subl four, maybe_four
|
||||
testl four, maybe_four
|
||||
movl maybe_four, 9
|
||||
; +m (maybe_four)
|
||||
+r (four)
|
||||
=@ccz (out)
|
||||
}
|
||||
assert out
|
||||
assert maybe_four == 9
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue