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
59914723
Commit
59914723
authored
Sep 15, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
declared and not used error, but disabled.
fix some bugs involving _. R=ken OCL=34621 CL=34621
parent
f3a33bca
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
6 deletions
+20
-6
gen.c
src/cmd/gc/gen.c
+7
-3
go.h
src/cmd/gc/go.h
+1
-0
go.y
src/cmd/gc/go.y
+2
-0
typecheck.c
src/cmd/gc/typecheck.c
+7
-3
walk.c
src/cmd/gc/walk.c
+3
-0
No files found.
src/cmd/gc/gen.c
View file @
59914723
...
...
@@ -26,6 +26,7 @@ allocparams(void)
Node
*
n
;
uint32
w
;
Sym
*
s
;
int
lno
;
if
(
stksize
<
0
)
fatal
(
"allocparams not during code generation"
);
...
...
@@ -35,6 +36,7 @@ allocparams(void)
* slots for all automatics.
* allocated starting at -w down.
*/
lno
=
lineno
;
for
(
l
=
curfn
->
dcl
;
l
;
l
=
l
->
next
)
{
n
=
l
->
n
;
if
(
n
->
op
==
ONAME
&&
n
->
class
==
PHEAP
-
1
)
{
...
...
@@ -46,19 +48,21 @@ allocparams(void)
}
if
(
n
->
op
!=
ONAME
||
n
->
class
!=
PAUTO
)
continue
;
typecheck
(
&
n
,
Erv
);
// only needed for unused variables
lineno
=
n
->
lineno
;
typecheck
(
&
n
,
Erv
|
Easgn
);
// only needed for unused variables
if
(
n
->
type
==
T
)
continue
;
// if(!n->used && n->sym->name[0] != '&')
// yyerror("%S declared and not used", n->sym);
dowidth
(
n
->
type
);
w
=
n
->
type
->
width
;
if
(
n
->
class
&
PHEAP
)
w
=
widthptr
;
if
(
w
>=
100000000
)
fatal
(
"bad width"
);
stksize
+=
w
;
stksize
=
rnd
(
stksize
,
w
);
n
->
xoffset
=
-
stksize
;
}
lineno
=
lno
;
}
void
...
...
src/cmd/gc/go.h
View file @
59914723
...
...
@@ -201,6 +201,7 @@ struct Node
uchar
local
;
uchar
initorder
;
uchar
dodata
;
// compile literal assignment as data statement
uchar
used
;
// most nodes
Node
*
left
;
...
...
src/cmd/gc/go.y
View file @
59914723
...
...
@@ -456,6 +456,7 @@ case:
if(typesw != N && typesw->right != N && (n=typesw->right->left) != N) {
// type switch - declare variable
n = newname(n->sym);
n->used = 1; // TODO(rsc): better job here
declare(n, dclcontext);
$$->nname = n;
}
...
...
@@ -488,6 +489,7 @@ case:
if(typesw != N && typesw->right != N && (n=typesw->right->left) != N) {
// type switch - declare variable
n = newname(n->sym);
n->used = 1; // TODO(rsc): better job here
declare(n, dclcontext);
$$->nname = n;
}
...
...
src/cmd/gc/typecheck.c
View file @
59914723
...
...
@@ -112,9 +112,13 @@ reswitch:
ok
|=
Ecall
;
goto
ret
;
}
if
(
isblank
(
n
)
&&
!
(
top
&
Easgn
))
{
yyerror
(
"cannot use _ as value"
);
goto
error
;
if
(
!
(
top
&
Easgn
))
{
// not a write to the variable
if
(
isblank
(
n
))
{
yyerror
(
"cannot use _ as value"
);
goto
error
;
}
n
->
used
=
1
;
}
ok
|=
Erv
;
goto
ret
;
...
...
src/cmd/gc/walk.c
View file @
59914723
...
...
@@ -1771,6 +1771,9 @@ convas(Node *n, NodeList **init)
if
(
lt
==
T
||
rt
==
T
)
goto
out
;
if
(
isblank
(
n
->
left
))
goto
out
;
if
(
n
->
left
->
op
==
OINDEXMAP
)
{
n
=
mkcall1
(
mapfn
(
"mapassign1"
,
n
->
left
->
left
->
type
),
T
,
init
,
n
->
left
->
left
,
n
->
left
->
right
,
n
->
right
);
...
...
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