]> Cypherpunks repositories - gostls13.git/commitdiff
6g ninit fixes - fixes the two test cases
authorRuss Cox <rsc@golang.org>
Thu, 6 Nov 2008 21:31:13 +0000 (13:31 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 6 Nov 2008 21:31:13 +0000 (13:31 -0800)
i isolated last night.  does not fix rob's
interface-smashing bug.

R=ken
OCL=18698
CL=18698

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

index 7e4e22c87b62ee45d885ad75d8ed7edbeb279389..acb311b4e73f6189894f98fdf1e30df351b0376a 100644 (file)
@@ -478,6 +478,8 @@ EXTERN      ushort  block;                  // current block number
 EXTERN Node*   retnil;
 EXTERN Node*   fskel;
 
+EXTERN Node*   addtop;
+
 EXTERN char*   context;
 EXTERN int     thechar;
 EXTERN char*   thestring;
index 0fbe0c173983676ece069a52361367c07b88c5b3..861f4fb29d9e447b3edb36e53b7dc24bbc07beba 100644 (file)
@@ -303,6 +303,9 @@ Bvardcl:
        }
 |      new_name_list_r type '=' expr_list
        {
+               if(addtop != N)
+                       fatal("new_name_list_r type '=' expr_list");
+
                $$ = rev($1);
                dodclvar($$, $2);
 
@@ -423,6 +426,9 @@ simple_stmt:
        }
 |      exprsym3_list_r LCOLAS expr_list
        {
+               if(addtop != N)
+                       fatal("exprsym3_list_r LCOLAS expr_list");
+
                $$ = rev($1);
                $$ = colas($$, $3);
                $$ = nod(OAS, $$, $3);
index d5ef43c28e5ee39ed06ce63fc9af5ad1a03d1f72..ddf0560c3843a510c0129592f1100bdf68f319bf 100644 (file)
@@ -2417,20 +2417,20 @@ adddot(Node *n)
        walktype(n->left, Erv);
        t = n->left->type;
        if(t == T)
-               return n;
+               goto ret;
 
        if(n->right->op != ONAME)
-               return n;
+               goto ret;
        s = n->right->sym;
        if(s == S)
-               return n;
+               goto ret;
 
        for(d=0; d<nelem(dotlist); d++) {
                c = adddot1(s, t, d);
                if(c > 0)
                        goto out;
        }
-       return n;
+       goto ret;
 
 out:
        if(c > 1)
@@ -2441,6 +2441,9 @@ out:
                n = nod(ODOT, n, n->right);
                n->left->right = newname(dotlist[c].field->sym);
        }
+ret:
+       n->ninit = list(addtop, n->ninit);
+       addtop = N;
        return n;
 }
 
index 130a5ece279c3198136e9c49037b82713a3aba7d..42eb037e74dd32f7f0d5fa6cfb43b65167980414 100644 (file)
@@ -8,7 +8,6 @@ static  Type*   sw1(Node*, Type*);
 static Type*   sw2(Node*, Type*);
 static Type*   sw3(Node*, Type*);
 static Node*   curfn;
-static Node*   addtop;
 
 enum
 {
@@ -65,6 +64,8 @@ walk(Node *fn)
        if(curfn->type->outtuple)
                if(walkret(curfn->nbody))
                        yyerror("function ends without a return statement");
+       if(addtop != N)
+               fatal("addtop in walk");
        walkstate(curfn->nbody);
        if(debug['W']) {
                snprint(s, sizeof(s), "after %S", curfn->nname->sym);
@@ -1544,6 +1545,9 @@ walkdot(Node *n)
 {
        Type *t;
 
+       addtop = list(addtop, n->ninit);
+       n->ninit = N;
+
        if(n->left == N || n->right == N)
                return;
        switch(n->op) {