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
1b1f39eb
Commit
1b1f39eb
authored
Jan 08, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: bug219, bug239, bug240
Fixes #475. R=ken2 CC=golang-dev
https://golang.org/cl/183157
parent
c6f4d686
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
7 deletions
+26
-7
lex.c
src/cmd/gc/lex.c
+22
-6
bug219.go
test/fixedbugs/bug219.go
+3
-0
bug239.go
test/fixedbugs/bug239.go
+0
-0
bug240.go
test/fixedbugs/bug240.go
+1
-1
No files found.
src/cmd/gc/lex.c
View file @
1b1f39eb
...
...
@@ -358,7 +358,6 @@ cannedimports(char *file, char *cp)
curio
.
cp
=
cp
;
curio
.
nlsemi
=
0
;
pkgmyname
=
S
;
typecheckok
=
1
;
incannedimport
=
1
;
}
...
...
@@ -379,6 +378,12 @@ isfrog(int c)
return
0
;
}
typedef
struct
Loophack
Loophack
;
struct
Loophack
{
int
v
;
Loophack
*
next
;
};
static
int32
_yylex
(
void
)
{
...
...
@@ -387,6 +392,8 @@ _yylex(void)
char
*
cp
;
Rune
rune
;
Sym
*
s
;
static
Loophack
*
lstk
;
Loophack
*
h
;
prevlineno
=
lineno
;
...
...
@@ -718,18 +725,27 @@ l0:
* non-parenthesized '{' becomes an LBODY.
* loophack is normally 0.
* a keyword makes it go up to 1.
* parens
increment and decrement when loophack >
0.
* parens
push loophack onto a stack and go back to
0.
* a '{' with loophack == 1 becomes LBODY and disables loophack.
*
* i said it was clumsy.
*/
case
'('
:
if
(
loophack
>
0
)
loophack
++
;
if
(
loophack
||
lstk
!=
nil
)
{
h
=
malloc
(
sizeof
*
h
);
h
->
v
=
loophack
;
h
->
next
=
lstk
;
lstk
=
h
;
loophack
=
0
;
}
goto
lx
;
case
')'
:
if
(
loophack
>
0
)
loophack
--
;
if
(
lstk
!=
nil
)
{
h
=
lstk
;
loophack
=
h
->
v
;
lstk
=
h
->
next
;
free
(
h
);
}
goto
lx
;
case
'{'
:
if
(
loophack
==
1
)
{
...
...
test/bugs/bug219.go
→
test/
fixed
bugs/bug219.go
View file @
1b1f39eb
...
...
@@ -14,6 +14,7 @@ func g1() {
if
x
:=
f
(
func
()
{
if
{}
});
{
_
=
x
;
}
}
...
...
@@ -22,6 +23,7 @@ func g2() {
if
x
:=
f
(
func
()
{
//if {}
});
{
_
=
x
;
}
}
...
...
@@ -31,5 +33,6 @@ func g3() {
if
{}
});
if
{
_
=
x
;
}
}
test/bugs/bug239.go
→
test/
fixed
bugs/bug239.go
View file @
1b1f39eb
File moved
test/bugs/bug240.go
→
test/
fixed
bugs/bug240.go
View file @
1b1f39eb
...
...
@@ -6,7 +6,7 @@
package
main
import
.
"unsafe"
import
.
"unsafe"
// ERROR "not used"
func
main
()
{
var
x
int
...
...
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