diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index fb7265980e5..dab085e2765 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -1245,8 +1245,8 @@ walkconv(Node *n) return; // convert static array to dynamic array - if(isslice(t) && isfixedarray(l->type)) { - if(eqtype(t->type->type, l->type->type->type, 0)) { + if(isslice(t) && isptr[l->type->etype] && isfixedarray(l->type->type)) { + if(eqtype(t->type->type, l->type->type->type->type, 0)) { indir(n, arrayop(n, Erv)); return; } @@ -2707,7 +2707,9 @@ arrayop(Node *n, int top) case OCONV: // arrays2d(old *any, nel int) (ary []any) - t = fixarray(n->left->type); + if(n->left->type == T || !isptr[n->left->type->etype]) + break; + t = fixarray(n->left->type->type); tl = fixarray(n->type); if(t == T || tl == T) break; @@ -2717,39 +2719,20 @@ arrayop(Node *n, int top) a->type = types[TINT]; r = a; - a = nod(OADDR, n->left, N); // old - addrescapes(n->left); - r = list(a, r); + r = list(n->left, r); // old on = syslook("arrays2d", 1); argtype(on, t); // any-1 argtype(on, tl->type); // any-2 r = nod(OCALL, on, r); - walktype(r, top); n->left = r; + walktype(n, top); return n; case OAS: - // arrays2d(old *any, nel int) (ary []any) - t = fixarray(n->right->type->type); - tl = fixarray(n->left->type); - if(t == T || tl == T) - break; - - a = nodintconst(t->bound); // nel - a = nod(OCONV, a, N); - a->type = types[TINT]; - r = a; - - r = list(n->right, r); // old - - on = syslook("arrays2d", 1); - argtype(on, t); // any-1 - argtype(on, tl->type); // any-2 - r = nod(OCALL, on, r); - - walktype(r, top); - n->right = r; + r = nod(OCONV, n->right, N); + r->type = n->left->type; + n->right = arrayop(r, Erv); return n; case OMAKE: diff --git a/src/lib/net/net_darwin.go b/src/lib/net/net_darwin.go index 7e85f089b56..2419f6c6deb 100644 --- a/src/lib/net/net_darwin.go +++ b/src/lib/net/net_darwin.go @@ -48,14 +48,14 @@ func sockaddrToIP(sa1 *syscall.Sockaddr) (p IP, port int, err os.Error) { switch sa1.Family { case syscall.AF_INET: sa := (*syscall.SockaddrInet4)(unsafe.Pointer(sa1)); - a := IP(sa.Addr).To16(); + a := IP(&sa.Addr).To16(); if a == nil { return nil, 0, os.EINVAL } return a, int(sa.Port[0])<<8 + int(sa.Port[1]), nil; case syscall.AF_INET6: sa := (*syscall.SockaddrInet6)(unsafe.Pointer(sa1)); - a := IP(sa.Addr).To16(); + a := IP(&sa.Addr).To16(); if a == nil { return nil, 0, os.EINVAL } diff --git a/src/lib/net/net_linux.go b/src/lib/net/net_linux.go index b6bfe7646c1..9b55f67e6ab 100644 --- a/src/lib/net/net_linux.go +++ b/src/lib/net/net_linux.go @@ -53,14 +53,14 @@ func sockaddrToIP(sa1 *syscall.Sockaddr) (p IP, port int, err os.Error) { switch sa1.Family { case syscall.AF_INET: sa := (*syscall.SockaddrInet4)(unsafe.Pointer(sa1)); - a := IP(sa.Addr).To16(); + a := IP(&sa.Addr).To16(); if a == nil { return nil, 0, os.EINVAL } return a, int(sa.Port[0])<<8 + int(sa.Port[1]), nil; case syscall.AF_INET6: sa := (*syscall.SockaddrInet6)(unsafe.Pointer(sa1)); - a := IP(sa.Addr).To16(); + a := IP(&sa.Addr).To16(); if a == nil { return nil, 0, os.EINVAL } diff --git a/src/lib/sort_test.go b/src/lib/sort_test.go index d6c8f90e968..1747daca6c8 100644 --- a/src/lib/sort_test.go +++ b/src/lib/sort_test.go @@ -18,7 +18,7 @@ var strings = [...]string{"", "Hello", "foo", "bar", "foo", "f00", "%*&^*&^&", " func TestSortIntArray(t *testing.T) { data := ints; - a := IntArray(data); + a := IntArray(&data); sort.Sort(a); if !sort.IsSorted(a) { t.Errorf("sorted %v", ints); @@ -28,7 +28,7 @@ func TestSortIntArray(t *testing.T) { func TestSortFloatArray(t *testing.T) { data := floats; - a := FloatArray(data); + a := FloatArray(&data); sort.Sort(a); if !sort.IsSorted(a) { t.Errorf("sorted %v", floats); @@ -38,7 +38,7 @@ func TestSortFloatArray(t *testing.T) { func TestSortStringArray(t *testing.T) { data := strings; - a := StringArray(data); + a := StringArray(&data); sort.Sort(a); if !sort.IsSorted(a) { t.Errorf("sorted %v", strings); diff --git a/test/bugs/bug146.go b/test/fixedbugs/bug146.go similarity index 100% rename from test/bugs/bug146.go rename to test/fixedbugs/bug146.go diff --git a/test/golden.out b/test/golden.out index 36217cac378..a3ab91b2130 100644 --- a/test/golden.out +++ b/test/golden.out @@ -111,13 +111,6 @@ bugs/bug140.go:6: syntax error near L1 bugs/bug140.go:7: syntax error near L2 BUG should compile -=========== bugs/bug146.go -BUG: errchk: bugs/bug146.go:9: missing expected error: 'invalid' -errchk: bugs/bug146.go: unmatched error messages: -================================================== -bugs/bug146.go:8: invalid conversion: *[1]uint8 to Slice -================================================== - =========== fixedbugs/bug016.go fixedbugs/bug016.go:7: constant -3 overflows uint