mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: improve typechecking of OSLICEHEADER nodes
Create a new node for OSLICEHEADER nodes to ensure typechecks are applied. Add nil checks for OSLICEHEADER type and pointer parameters for better error messages when these are not set. Improve formatting of OSLICEHEADER nodes in compiler error messages. Change-Id: Idea8f41bb4beb636f0e1fc381ff8d79b1d44fbae Reviewed-on: https://go-review.googlesource.com/c/146997 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
c5aea7a494
commit
e3e043bea4
3 changed files with 22 additions and 8 deletions
|
|
@ -1351,14 +1351,17 @@ opswitch:
|
|||
argtype = types.Types[TINT]
|
||||
}
|
||||
|
||||
m := nod(OSLICEHEADER, nil, nil)
|
||||
m.Type = t
|
||||
|
||||
fn := syslook(fnname)
|
||||
n.Left = mkcall1(fn, types.Types[TUNSAFEPTR], init, typename(t.Elem()), conv(len, argtype), conv(cap, argtype))
|
||||
n.Left.SetNonNil(true)
|
||||
n.List.Set2(conv(len, types.Types[TINT]), conv(cap, types.Types[TINT]))
|
||||
n.Op = OSLICEHEADER
|
||||
n.Type = t
|
||||
n = typecheck(n, Erv)
|
||||
n = walkexpr(n, init)
|
||||
m.Left = mkcall1(fn, types.Types[TUNSAFEPTR], init, typename(t.Elem()), conv(len, argtype), conv(cap, argtype))
|
||||
m.Left.SetNonNil(true)
|
||||
m.List.Set2(conv(len, types.Types[TINT]), conv(cap, types.Types[TINT]))
|
||||
|
||||
m = typecheck(m, Erv)
|
||||
m = walkexpr(m, init)
|
||||
n = m
|
||||
}
|
||||
|
||||
case ORUNESTR:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue