]> Cypherpunks repositories - gostls13.git/commitdiff
robs wednesday bug
authorKen Thompson <ken@golang.org>
Mon, 15 Sep 2008 00:29:50 +0000 (17:29 -0700)
committerKen Thompson <ken@golang.org>
Mon, 15 Sep 2008 00:29:50 +0000 (17:29 -0700)
R=r
OCL=15327
CL=15327

src/cmd/gc/go.h
src/cmd/gc/go.y
src/cmd/gc/walk.c

index e36eece2806c724e5fecc03ef8ab937e4f97b0cb..1d776d4813a9906c72cb3c3a94576857dccee2c5 100644 (file)
@@ -666,6 +666,8 @@ void        doimport9(Sym*, Node*);
 /*
  *     walk.c
  */
+void   addtotop(Node*);
+void   gettype(Node*, Node*);
 void   walk(Node*);
 void   walkstate(Node*);
 void   walktype(Node*, int);
index 15c56370d04cfaebbe687ee801fa76c7f72f238f..9d05bf43dd0ea4a48e3ee6c4b399e1a3afcb9fd4 100644 (file)
@@ -247,20 +247,22 @@ Bvardcl:
                dodclvar($$, $2);
 
                $$ = nod(OAS, $$, $4);
+               addtotop($$);
        }
 |      new_name '=' expr
        {
-               gettype($3);
+               $$ = nod(OAS, $1, N);
+               gettype($3, $$);
                defaultlit($3);
                dodclvar($1, $3->type);
-               $$ = nod(OAS, $1, $3);
+               $$->right = $3;
        }
 
 constdcl:
        new_name type '=' expr
        {
                Node *c = treecopy($4);
-               gettype(c);
+               gettype(c, N);
                convlit(c, $2);
                dodclconst($1, c);
 
@@ -270,7 +272,7 @@ constdcl:
 |      new_name '=' expr
        {
                Node *c = treecopy($3);
-               gettype(c);
+               gettype(c, N);
                dodclconst($1, c);
 
                lastconst = $3;
@@ -282,7 +284,7 @@ constdcl1:
 |      new_name type
        {
                Node *c = treecopy(lastconst);
-               gettype(c);
+               gettype(c, N);
                convlit(c, $2);
                dodclconst($1, c);
 
@@ -291,7 +293,7 @@ constdcl1:
 |      new_name
        {
                Node *c = treecopy(lastconst);
-               gettype(c);
+               gettype(c, N);
                dodclconst($1, c);
 
                iota += 1;
index 2975149b731e48f9980b8e844a98f5ce321e0be1..503f9260e55efba52f448520dcdb338fb6de1458 100644 (file)
@@ -76,12 +76,14 @@ addtotop(Node *n)
 }
 
 void
-gettype(Node *n)
+gettype(Node *n, Node *a)
 {
        if(debug['W'])
                dump("\nbefore gettype", n);
        walktype(n, Erv);
-       addtotop(n);
+       if(a == N && addtop != N)
+               fatal("gettype: addtop");
+       addtotop(a);
        if(debug['W'])
                dump("after gettype", n);
 }