Commit 83e976d5 authored by Russ Cox's avatar Russ Cox

bug146: array/slice conversion before I left missed conversions

R=ken
OCL=28120
CL=28124
parent bd8e25ca
......@@ -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:
......
......@@ -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
}
......
......@@ -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
}
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment