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
6be0f50b
Commit
6be0f50b
authored
Aug 07, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug159
R=ken OCL=32902 CL=32914
parent
c12ccabb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
19 deletions
+27
-19
src/cmd/gc/walk.c
src/cmd/gc/walk.c
+14
-1
test/fixedbugs/bug159.go
test/fixedbugs/bug159.go
+0
-0
test/golden.out
test/golden.out
+0
-4
test/simassign.go
test/simassign.go
+13
-14
No files found.
src/cmd/gc/walk.c
View file @
6be0f50b
...
@@ -1868,6 +1868,7 @@ reorder1(NodeList *all)
...
@@ -1868,6 +1868,7 @@ reorder1(NodeList *all)
* simultaneous assignment. there cannot
* simultaneous assignment. there cannot
* be later use of an earlier lvalue.
* be later use of an earlier lvalue.
*/
*/
int
int
vmatch2
(
Node
*
l
,
Node
*
r
)
vmatch2
(
Node
*
l
,
Node
*
r
)
{
{
...
@@ -1908,7 +1909,18 @@ vmatch1(Node *l, Node *r)
...
@@ -1908,7 +1909,18 @@ vmatch1(Node *l, Node *r)
return
0
;
return
0
;
switch
(
l
->
op
)
{
switch
(
l
->
op
)
{
case
ONAME
:
case
ONAME
:
// match each left with all rights
switch
(
l
->
class
)
{
case
PPARAM
:
case
PPARAMREF
:
case
PAUTO
:
break
;
default:
// assignment to non-stack variable
// must be delayed if right has function calls.
if
(
r
->
ullman
>=
UINF
)
return
1
;
break
;
}
return
vmatch2
(
l
,
r
);
return
vmatch2
(
l
,
r
);
case
OLITERAL
:
case
OLITERAL
:
return
0
;
return
0
;
...
@@ -1937,6 +1949,7 @@ reorder3(NodeList *all)
...
@@ -1937,6 +1949,7 @@ reorder3(NodeList *all)
n2
=
l2
->
n
;
n2
=
l2
->
n
;
if
(
c2
>
c1
)
{
if
(
c2
>
c1
)
{
if
(
vmatch1
(
n1
->
left
,
n2
->
right
))
{
if
(
vmatch1
(
n1
->
left
,
n2
->
right
))
{
// delay assignment to n1->left
q
=
nod
(
OXXX
,
N
,
N
);
q
=
nod
(
OXXX
,
N
,
N
);
tempname
(
q
,
n1
->
right
->
type
);
tempname
(
q
,
n1
->
right
->
type
);
q
=
nod
(
OAS
,
n1
->
left
,
q
);
q
=
nod
(
OAS
,
n1
->
left
,
q
);
...
...
test/bugs/bug159.go
→
test/
fixed
bugs/bug159.go
View file @
6be0f50b
File moved
test/golden.out
View file @
6be0f50b
...
@@ -147,10 +147,6 @@ BUG: compilation succeeds incorrectly
...
@@ -147,10 +147,6 @@ BUG: compilation succeeds incorrectly
=========== bugs/bug136.go
=========== bugs/bug136.go
BUG: errchk: command succeeded unexpectedly
BUG: errchk: command succeeded unexpectedly
=========== bugs/bug159.go
abc: expected 4 5 6 got 4 4 -4
BUG: bug159
=========== bugs/bug162.go
=========== bugs/bug162.go
123
123
BUG: should fail
BUG: should fail
...
...
test/simassign.go
View file @
6be0f50b
...
@@ -11,18 +11,19 @@ var a,b,c,d,e,f,g,h,i int;
...
@@ -11,18 +11,19 @@ var a,b,c,d,e,f,g,h,i int;
func
func
printit
()
printit
()
{
{
print
(
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
"
\n
"
);
print
ln
(
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
);
}
}
func
func
testit
()
bool
testit
(
permuteok
bool
)
bool
{
{
if
a
+
b
+
c
+
d
+
e
+
f
+
g
+
h
+
i
!=
45
{
if
a
+
b
+
c
+
d
+
e
+
f
+
g
+
h
+
i
!=
45
{
print
(
"sum does not add to 45
\n
"
);
print
(
"sum does not add to 45
\n
"
);
printit
();
printit
();
panic
()
;
return
false
;
}
}
return
a
==
1
&&
return
permuteok
||
a
==
1
&&
b
==
2
&&
b
==
2
&&
c
==
3
&&
c
==
3
&&
d
==
4
&&
d
==
4
&&
...
@@ -51,22 +52,19 @@ main()
...
@@ -51,22 +52,19 @@ main()
h
=
8
;
h
=
8
;
i
=
9
;
i
=
9
;
if
!
testit
()
{
panic
(
"init val
\n
"
);
}
if
!
testit
(
false
)
{
panic
(
"init val
\n
"
);
}
for
z
:=
0
;
z
<
100
;
z
++
{
for
z
:=
0
;
z
<
100
;
z
++
{
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
=
b
,
c
,
d
,
a
,
i
,
e
,
f
,
g
,
h
;
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
=
b
,
c
,
d
,
a
,
i
,
e
,
f
,
g
,
h
;
if
testit
()
{
if
!
testit
(
z
%
20
!=
19
)
{
if
z
==
19
{
break
;
}
print
(
"on "
,
z
,
"th iteration
\n
"
);
print
(
"on "
,
z
,
"th iteration
\n
"
);
printit
();
printit
();
panic
();
panic
();
}
}
}
}
if
!
testit
()
{
if
!
testit
(
false
)
{
print
(
"final val
\n
"
);
print
(
"final val
\n
"
);
printit
();
printit
();
panic
();
panic
();
...
@@ -76,8 +74,9 @@ main()
...
@@ -76,8 +74,9 @@ main()
if
a
!=
2
||
b
!=
1
{
if
a
!=
2
||
b
!=
1
{
panic
(
"bad swap"
);
panic
(
"bad swap"
);
}
}
//BUG a, b = swap(swap(a, b));
// if a != 2 || b != 1 {
a
,
b
=
swap
(
swap
(
a
,
b
));
// panic("bad swap");
if
a
!=
2
||
b
!=
1
{
// }
panic
(
"bad swap"
);
}
}
}
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