Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c458c983
Commit
c458c983
authored
Jan 07, 2009
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[...] bug
R=r OCL=22218 CL=22218
parent
855495ea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
21 deletions
+23
-21
src/cmd/gc/go.h
src/cmd/gc/go.h
+1
-0
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+22
-21
No files found.
src/cmd/gc/go.h
View file @
c458c983
...
...
@@ -836,3 +836,4 @@ void argspace(int32);
Node
*
nodarg
(
Type
*
,
int
);
void
nodconst
(
Node
*
,
Type
*
,
vlong
);
Type
*
deep
(
Type
*
);
Type
*
shallow
(
Type
*
);
src/cmd/gc/walk.c
View file @
c458c983
...
...
@@ -3556,38 +3556,44 @@ arraylit(Node *n)
Iter
saver
;
Type
*
t
;
Node
*
var
,
*
r
,
*
a
,
*
nnew
;
int
idx
,
b
;
int
idx
,
ninit
,
b
;
t
=
n
->
type
;
if
(
t
->
etype
!=
TARRAY
)
fatal
(
"arraylit: not array"
);
// count initializers
ninit
=
0
;
r
=
listfirst
(
&
saver
,
&
n
->
left
);
if
(
r
!=
N
&&
r
->
op
==
OEMPTY
)
r
=
N
;
while
(
r
!=
N
)
{
ninit
++
;
r
=
listnext
(
&
saver
);
}
b
=
t
->
bound
;
if
(
b
==
-
100
)
{
// flag for [...]
b
=
ninit
;
t
=
shallow
(
t
);
t
->
bound
=
b
;
}
var
=
nod
(
OXXX
,
N
,
N
);
tempname
(
var
,
t
);
b
=
t
->
bound
;
if
(
b
<
0
&&
b
!=
-
100
)
{
if
(
b
<
0
)
{
// slice
nnew
=
nod
(
OMAKE
,
N
,
N
);
nnew
->
type
=
t
;
a
=
nod
(
OAS
,
var
,
nnew
);
addtop
=
list
(
addtop
,
a
);
}
if
(
b
>=
0
)
{
idx
=
0
;
r
=
listfirst
(
&
saver
,
&
n
->
left
);
if
(
r
!=
N
&&
r
->
op
==
OEMPTY
)
r
=
N
;
while
(
r
!=
N
)
{
// count initializers
idx
++
;
r
=
listnext
(
&
saver
);
}
}
else
{
// if entire array isnt initialized,
// then clear the array
if
(
idx
<
b
)
{
if
(
ninit
<
b
)
{
a
=
nod
(
OAS
,
var
,
N
);
addtop
=
list
(
addtop
,
a
);
}
...
...
@@ -3606,11 +3612,6 @@ arraylit(Node *n)
idx
++
;
r
=
listnext
(
&
saver
);
}
if
(
b
==
-
100
)
{
// compiler counted closed array
b
=
idx
;
t
->
bound
=
b
;
}
if
(
b
<
0
)
nnew
->
left
=
nodintconst
(
idx
);
return
var
;
...
...
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