1
0
mirror of https://github.com/golang/go synced 2024-11-25 05:17:57 -07:00

robs wednesday bug

R=r
OCL=15327
CL=15327
This commit is contained in:
Ken Thompson 2008-09-14 17:29:50 -07:00
parent 2119294af9
commit d01a1ec260
3 changed files with 14 additions and 8 deletions

View File

@ -666,6 +666,8 @@ void doimport9(Sym*, Node*);
/* /*
* walk.c * walk.c
*/ */
void addtotop(Node*);
void gettype(Node*, Node*);
void walk(Node*); void walk(Node*);
void walkstate(Node*); void walkstate(Node*);
void walktype(Node*, int); void walktype(Node*, int);

View File

@ -247,20 +247,22 @@ Bvardcl:
dodclvar($$, $2); dodclvar($$, $2);
$$ = nod(OAS, $$, $4); $$ = nod(OAS, $$, $4);
addtotop($$);
} }
| new_name '=' expr | new_name '=' expr
{ {
gettype($3); $$ = nod(OAS, $1, N);
gettype($3, $$);
defaultlit($3); defaultlit($3);
dodclvar($1, $3->type); dodclvar($1, $3->type);
$$ = nod(OAS, $1, $3); $$->right = $3;
} }
constdcl: constdcl:
new_name type '=' expr new_name type '=' expr
{ {
Node *c = treecopy($4); Node *c = treecopy($4);
gettype(c); gettype(c, N);
convlit(c, $2); convlit(c, $2);
dodclconst($1, c); dodclconst($1, c);
@ -270,7 +272,7 @@ constdcl:
| new_name '=' expr | new_name '=' expr
{ {
Node *c = treecopy($3); Node *c = treecopy($3);
gettype(c); gettype(c, N);
dodclconst($1, c); dodclconst($1, c);
lastconst = $3; lastconst = $3;
@ -282,7 +284,7 @@ constdcl1:
| new_name type | new_name type
{ {
Node *c = treecopy(lastconst); Node *c = treecopy(lastconst);
gettype(c); gettype(c, N);
convlit(c, $2); convlit(c, $2);
dodclconst($1, c); dodclconst($1, c);
@ -291,7 +293,7 @@ constdcl1:
| new_name | new_name
{ {
Node *c = treecopy(lastconst); Node *c = treecopy(lastconst);
gettype(c); gettype(c, N);
dodclconst($1, c); dodclconst($1, c);
iota += 1; iota += 1;

View File

@ -76,12 +76,14 @@ addtotop(Node *n)
} }
void void
gettype(Node *n) gettype(Node *n, Node *a)
{ {
if(debug['W']) if(debug['W'])
dump("\nbefore gettype", n); dump("\nbefore gettype", n);
walktype(n, Erv); walktype(n, Erv);
addtotop(n); if(a == N && addtop != N)
fatal("gettype: addtop");
addtotop(a);
if(debug['W']) if(debug['W'])
dump("after gettype", n); dump("after gettype", n);
} }