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
691d7651
Commit
691d7651
authored
Jul 15, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: bug274
R=ken2 CC=golang-dev
https://golang.org/cl/1742044
parent
17f90c68
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
2 deletions
+33
-2
src/cmd/gc/go.h
src/cmd/gc/go.h
+2
-0
src/cmd/gc/go.y
src/cmd/gc/go.y
+25
-2
src/cmd/gc/lex.c
src/cmd/gc/lex.c
+6
-0
test/fixedbugs/bug274.go
test/fixedbugs/bug274.go
+0
-0
No files found.
src/cmd/gc/go.h
View file @
691d7651
...
...
@@ -914,6 +914,8 @@ char* lexname(int lex);
void
mkpackage
(
char
*
pkgname
);
void
unimportfile
(
void
);
int32
yylex
(
void
);
extern
int
yylast
;
extern
int
yyprev
;
/*
* mparith1.c
...
...
src/cmd/gc/go.y
View file @
691d7651
...
...
@@ -515,10 +515,33 @@ switch_body:
}
caseblock:
case
stmt_list
case
{
// If the last token read by the lexer was consumed
// as part of the case, clear it (parser has cleared yychar).
// If the last token read by the lexer was the lookahead
// leave it alone (parser has it cached in yychar).
// This is so that the stmt_list action doesn'
t
look
at
//
the
case
tokens
if
the
stmt_list
is
empty
.
yylast
=
yychar
;
}
stmt_list
{
int
last
;
//
This
is
the
only
place
in
the
language
where
a
statement
//
list
is
not
allowed
to
drop
the
final
semicolon
,
because
//
it
's the only place where a statement list is not followed
// by a closing brace. Handle the error for pedantry.
// Find the final token of the statement list.
// yylast is lookahead; yyprev is last of stmt_list
last = yyprev;
if(last > 0 && last != '
;
' && yychar != '
}
')
yyerror("missing statement after label");
$$ = $1;
$$->nbody = $
2
;
$$->nbody = $
3
;
}
caseblock_list:
...
...
src/cmd/gc/lex.c
View file @
691d7651
...
...
@@ -14,6 +14,8 @@
extern
int
yychar
;
int
windows
;
int
yyprev
;
int
yylast
;
static
void
lexinit
(
void
);
static
void
lexfini
(
void
);
...
...
@@ -1140,6 +1142,10 @@ yylex(void)
curio
.
nlsemi
=
0
;
break
;
}
// Track last two tokens returned by yylex.
yyprev
=
yylast
;
yylast
=
lx
;
return
lx
;
}
...
...
test/bugs/bug274.go
→
test/
fixed
bugs/bug274.go
View file @
691d7651
File moved
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