Fixes #19576.
Change-Id: I11034fb08e989f6eb7d54bde873b92804223598d
Reviewed-on: https://go-review.googlesource.com/38291
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
yyerror("go:nosplit and go:systemstack cannot be combined")
}
f.Func.Pragma = pragma
- lineno = makePos(fun.Pos().Base(), fun.EndLine, 0)
+ lineno = Ctxt.PosTable.XPos(fun.Rbrace)
f.Func.Endlineno = lineno
funcbody(f)
l[i] = p.wrapname(expr.ElemList[i], e)
}
n.List.Set(l)
- lineno = makePos(expr.Pos().Base(), expr.EndLine, 0)
+ lineno = Ctxt.PosTable.XPos(expr.Rbrace)
return n
case *syntax.KeyValueExpr:
return p.nod(expr, OKEY, p.expr(expr.Key), p.wrapname(expr.Value, p.expr(expr.Value)))
case *syntax.FuncLit:
closurehdr(p.typeExpr(expr.Type))
body := p.stmts(expr.Body)
- lineno = makePos(expr.Pos().Base(), expr.EndLine, 0)
+ lineno = Ctxt.PosTable.XPos(expr.Rbrace)
return p.setlineno(expr, closurebody(body))
case *syntax.ParenExpr:
return p.nod(expr, OPAREN, p.expr(expr.X), nil)
// func Receiver Name Type { Body }
// func Receiver Name Type
FuncDecl struct {
- Attr map[string]bool // go:attr map
- Recv *Field // nil means regular function
- Name *Name
- Type *FuncType
- Body []Stmt // nil means no body (forward declaration)
- Pragma Pragma // TODO(mdempsky): Cleaner solution.
- EndLine uint // TODO(mdempsky): Cleaner solution.
+ Attr map[string]bool // go:attr map
+ Recv *Field // nil means regular function
+ Name *Name
+ Type *FuncType
+ Body []Stmt // nil means no body (forward declaration)
+ Pragma Pragma // TODO(mdempsky): Cleaner solution.
+ Rbrace src.Pos // TODO(mdempsky): Cleaner solution.
decl
}
)
CompositeLit struct {
Type Expr // nil means no literal type
ElemList []Expr
- NKeys int // number of elements with keys
- EndLine uint // TODO(mdempsky): Cleaner solution.
+ NKeys int // number of elements with keys
+ Rbrace src.Pos // TODO(mdempsky): Cleaner solution.
expr
}
// func Type { Body }
FuncLit struct {
- Type *FuncType
- Body []Stmt
- EndLine uint // TODO(mdempsky): Cleaner solution.
+ Type *FuncType
+ Body []Stmt
+ Rbrace src.Pos // TODO(mdempsky): Cleaner solution.
expr
}
f.Name = p.name()
f.Type = p.funcType()
- f.Body = p.funcBody()
+ if p.got(_Lbrace) {
+ f.Body = p.funcBody()
+ f.Rbrace = p.pos()
+ p.want(_Rbrace)
+ }
f.Pragma = p.pragma
- f.EndLine = p.line
// TODO(gri) deal with function properties
// if noescape && body != nil {
pos := p.pos()
p.next()
t := p.funcType()
- if p.tok == _Lbrace {
- p.fnest++
+ if p.got(_Lbrace) {
p.xnest++
f := new(FuncLit)
f.pos = pos
f.Type = t
f.Body = p.funcBody()
- f.EndLine = p.line
+ f.Rbrace = p.pos()
+ p.want(_Rbrace)
p.xnest--
- p.fnest--
return f
}
return t
}
}
- x.EndLine = p.line
+ x.Rbrace = p.pos()
p.xnest--
p.want(_Rbrace)
defer p.trace("funcBody")()
}
- if p.got(_Lbrace) {
- p.fnest++
- body := p.stmtList()
- p.fnest--
- p.want(_Rbrace)
- if body == nil {
- body = []Stmt{new(EmptyStmt)}
- }
- return body
- }
+ p.fnest++
+ body := p.stmtList()
+ p.fnest--
- return nil
+ if body == nil {
+ body = []Stmt{new(EmptyStmt)}
+ }
+ return body
}
// Result = Parameters | Type .