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
a1564865
Commit
a1564865
authored
Oct 20, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug196
R=ken OCL=35905 CL=35905
parent
62c4818e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
16 deletions
+32
-16
go.h
src/cmd/gc/go.h
+1
-0
subr.c
src/cmd/gc/subr.c
+28
-1
walk.c
src/cmd/gc/walk.c
+3
-10
bug196.go
test/fixedbugs/bug196.go
+0
-0
golden.out
test/golden.out
+0
-5
No files found.
src/cmd/gc/go.h
View file @
a1564865
...
...
@@ -847,6 +847,7 @@ Node* staticname(Type*);
int
iscomposite
(
Type
*
);
Node
*
callnew
(
Type
*
);
Node
*
saferef
(
Node
*
,
NodeList
**
);
Node
*
safeval
(
Node
*
,
NodeList
**
);
int
is64
(
Type
*
);
int
noconv
(
Type
*
,
Type
*
);
NodeList
*
list1
(
Node
*
);
...
...
src/cmd/gc/subr.c
View file @
a1564865
...
...
@@ -2346,7 +2346,7 @@ staticname(Type *t)
}
/*
* return side effect-free n, appending side effects to init.
* return side effect-free
, assignable
n, appending side effects to init.
*/
Node
*
saferef
(
Node
*
n
,
NodeList
**
init
)
...
...
@@ -2387,6 +2387,33 @@ saferef(Node *n, NodeList **init)
return
N
;
}
/*
* return side effect-free n, appending side effects to init.
*/
Node
*
safeval
(
Node
*
n
,
NodeList
**
init
)
{
Node
*
l
;
Node
*
r
;
Node
*
a
;
// is this a local variable or a dot of a local variable?
for
(
l
=
n
;
l
->
op
==
ODOT
;
l
=
l
->
left
)
if
(
l
->
left
->
type
!=
T
&&
isptr
[
l
->
left
->
type
->
etype
])
goto
copy
;
if
(
l
->
op
==
ONAME
&&
(
l
->
class
==
PAUTO
||
l
->
class
==
PPARAM
))
return
n
;
copy:
l
=
nod
(
OXXX
,
N
,
N
);
tempname
(
l
,
n
->
type
);
a
=
nod
(
OAS
,
l
,
n
);
typecheck
(
&
a
,
Etop
);
walkexpr
(
&
a
,
init
);
*
init
=
list
(
*
init
,
a
);
return
l
;
}
void
setmaxarg
(
Type
*
t
)
{
...
...
src/cmd/gc/walk.c
View file @
a1564865
...
...
@@ -1592,7 +1592,6 @@ Node*
mapop
(
Node
*
n
,
NodeList
**
init
)
{
Node
*
r
,
*
a
;
Type
*
t
;
r
=
n
;
switch
(
n
->
op
)
{
...
...
@@ -1601,16 +1600,10 @@ mapop(Node *n, NodeList **init)
case
OASOP
:
// rewrite map[index] op= right
// into tmpi := index; map[tmpi] = map[tmpi] op right
// TODO(rsc): does this double-evaluate map?
t
=
n
->
left
->
left
->
type
;
a
=
nod
(
OXXX
,
N
,
N
);
tempname
(
a
,
t
->
down
);
// tmpi
r
=
nod
(
OAS
,
a
,
n
->
left
->
right
);
// tmpi := index
n
->
left
->
right
=
a
;
// m[tmpi]
typecheck
(
&
r
,
Etop
);
walkexpr
(
&
r
,
init
);
*
init
=
list
(
*
init
,
r
);
// make it ok to double-evaluate map[tmpi]
n
->
left
->
left
=
safeval
(
n
->
left
->
left
,
init
);
n
->
left
->
right
=
safeval
(
n
->
left
->
right
,
init
);
a
=
nod
(
OXXX
,
N
,
N
);
*
a
=
*
n
->
left
;
// copy of map[tmpi]
...
...
test/bugs/bug196.go
→
test/
fixed
bugs/bug196.go
View file @
a1564865
File moved
test/golden.out
View file @
a1564865
...
...
@@ -146,8 +146,3 @@ BUG: should fail
=========== bugs/bug193.go
BUG: errchk: bugs/bug193.go:14: missing expected error: 'shift'
=========== bugs/bug196.go
too many calls: 5
panic PC=xxx
BUG: bug196
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