Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
83e976d5
Commit
83e976d5
authored
Apr 30, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug146: array/slice conversion before I left missed conversions
R=ken OCL=28120 CL=28124
parent
bd8e25ca
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
41 deletions
+17
-41
walk.c
src/cmd/gc/walk.c
+10
-27
net_darwin.go
src/lib/net/net_darwin.go
+2
-2
net_linux.go
src/lib/net/net_linux.go
+2
-2
sort_test.go
src/lib/sort_test.go
+3
-3
bug146.go
test/fixedbugs/bug146.go
+0
-0
golden.out
test/golden.out
+0
-7
No files found.
src/cmd/gc/walk.c
View file @
83e976d5
...
...
@@ -1245,8 +1245,8 @@ walkconv(Node *n)
return
;
// convert static array to dynamic array
if
(
isslice
(
t
)
&&
is
fixedarray
(
l
->
type
))
{
if
(
eqtype
(
t
->
type
->
type
,
l
->
type
->
type
->
type
,
0
))
{
if
(
isslice
(
t
)
&&
is
ptr
[
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
:
...
...
src/lib/net/net_darwin.go
View file @
83e976d5
...
...
@@ -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
}
...
...
src/lib/net/net_linux.go
View file @
83e976d5
...
...
@@ -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
}
...
...
src/lib/sort_test.go
View file @
83e976d5
...
...
@@ -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
);
...
...
test/bugs/bug146.go
→
test/
fixed
bugs/bug146.go
View file @
83e976d5
File moved
test/golden.out
View file @
83e976d5
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment