aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/subr.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/gc/subr.go')
-rw-r--r--src/cmd/compile/internal/gc/subr.go28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go
index d3ba53ff0c..07547df36e 100644
--- a/src/cmd/compile/internal/gc/subr.go
+++ b/src/cmd/compile/internal/gc/subr.go
@@ -689,14 +689,14 @@ func convertop(srcConstant bool, src, dst *types.Type, why *string) Op {
// (a) Disallow (*T) to (*U) where T is go:notinheap but U isn't.
if src.IsPtr() && dst.IsPtr() && dst.Elem().NotInHeap() && !src.Elem().NotInHeap() {
if why != nil {
- *why = fmt.Sprintf(":\n\t%v is go:notinheap, but %v is not", dst.Elem(), src.Elem())
+ *why = fmt.Sprintf(":\n\t%v is incomplete (or unallocatable), but %v is not", dst.Elem(), src.Elem())
}
return OXXX
}
// (b) Disallow string to []T where T is go:notinheap.
if src.IsString() && dst.IsSlice() && dst.Elem().NotInHeap() && (dst.Elem().Etype == types.Bytetype.Etype || dst.Elem().Etype == types.Runetype.Etype) {
if why != nil {
- *why = fmt.Sprintf(":\n\t%v is go:notinheap", dst.Elem())
+ *why = fmt.Sprintf(":\n\t%v is incomplete (or unallocatable)", dst.Elem())
}
return OXXX
}
@@ -928,16 +928,20 @@ func (o Op) IsSlice3() bool {
return false
}
-// slicePtrLen extracts the pointer and length from a slice.
+// backingArrayPtrLen extracts the pointer and length from a slice or string.
// This constructs two nodes referring to n, so n must be a cheapexpr.
-func (n *Node) slicePtrLen() (ptr, len *Node) {
+func (n *Node) backingArrayPtrLen() (ptr, len *Node) {
var init Nodes
c := cheapexpr(n, &init)
if c != n || init.Len() != 0 {
- Fatalf("slicePtrLen not cheap: %v", n)
+ Fatalf("backingArrayPtrLen not cheap: %v", n)
}
ptr = nod(OSPTR, n, nil)
- ptr.Type = n.Type.Elem().PtrTo()
+ if n.Type.IsString() {
+ ptr.Type = types.Types[TUINT8].PtrTo()
+ } else {
+ ptr.Type = n.Type.Elem().PtrTo()
+ }
len = nod(OLEN, n, nil)
len.Type = types.Types[TINT]
return ptr, len
@@ -1615,7 +1619,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym) {
escapeFuncs([]*Node{fn}, false)
Curfn = nil
- funccompile(fn)
+ xtop = append(xtop, fn)
}
func paramNnames(ft *types.Type) []*Node {
@@ -1917,3 +1921,13 @@ func ifaceData(pos src.XPos, n *Node, t *types.Type) *Node {
ind.SetBounded(true)
return ind
}
+
+// typePos returns the position associated with t.
+// This is where t was declared or where it appeared as a type expression.
+func typePos(t *types.Type) src.XPos {
+ n := asNode(t.Nod)
+ if n == nil || !n.Pos.IsKnown() {
+ Fatalf("bad type: %v", t)
+ }
+ return n.Pos
+}