mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix nested amp (#6402)
This commit is contained in:
parent
69c592e0d6
commit
f59b771c76
@ -1921,6 +1921,7 @@ fn (mut g Gen) expr(node ast.Expr) {
|
||||
// &Foo(0) => ((Foo*)0)
|
||||
g.out.go_back(1)
|
||||
}
|
||||
g.is_amp = false
|
||||
sym := g.table.get_type_symbol(node.typ)
|
||||
if sym.kind == .string && !node.typ.is_ptr() {
|
||||
// `string(x)` needs `tos()`, but not `&string(x)
|
||||
@ -1950,14 +1951,8 @@ fn (mut g Gen) expr(node ast.Expr) {
|
||||
g.expr(node.expr)
|
||||
g.write('))')
|
||||
} else {
|
||||
// styp := g.table.Type_to_str(it.typ)
|
||||
styp := g.typ(node.typ)
|
||||
// g.write('($styp)(')
|
||||
g.write('(($styp)(')
|
||||
// if g.is_amp {
|
||||
// g.write('*')
|
||||
// }
|
||||
// g.write(')(')
|
||||
g.expr(node.expr)
|
||||
if node.expr is ast.IntegerLiteral &&
|
||||
node.typ in [table.u64_type, table.u32_type, table.u16_type] {
|
||||
|
@ -1061,6 +1061,10 @@ pub fn (mut p Parser) name_expr() ast.Expr {
|
||||
// Handle `&Foo(0)`
|
||||
to_typ = to_typ.to_ptr()
|
||||
}
|
||||
// this prevents inner casts to also have an `&`
|
||||
// example: &Foo(malloc(int(num)))
|
||||
// without the next line int would result in int*
|
||||
p.is_amp = false
|
||||
p.check(.lpar)
|
||||
mut expr := ast.Expr{}
|
||||
mut arg := ast.Expr{}
|
||||
|
@ -340,7 +340,7 @@ fn (mut p Parser) prefix_expr() ast.PrefixExpr {
|
||||
p.next()
|
||||
mut right := if op == .minus { p.expr(token.Precedence.call) } else { p.expr(token.Precedence.prefix) }
|
||||
p.is_amp = false
|
||||
if mut right is ast.CastExpr {
|
||||
if right is ast.CastExpr {
|
||||
right.in_prexpr = true
|
||||
}
|
||||
mut or_stmts := []ast.Stmt{}
|
||||
|
Loading…
Reference in New Issue
Block a user