Commit 9906bfc7 authored by Russ Cox's avatar Russ Cox

6g ninit fixes - fixes the two test cases

i isolated last night.  does not fix rob's
interface-smashing bug.

R=ken
OCL=18698
CL=18698
parent 66c6b13b
...@@ -478,6 +478,8 @@ EXTERN ushort block; // current block number ...@@ -478,6 +478,8 @@ EXTERN ushort block; // current block number
EXTERN Node* retnil; EXTERN Node* retnil;
EXTERN Node* fskel; EXTERN Node* fskel;
EXTERN Node* addtop;
EXTERN char* context; EXTERN char* context;
EXTERN int thechar; EXTERN int thechar;
EXTERN char* thestring; EXTERN char* thestring;
......
...@@ -303,6 +303,9 @@ Bvardcl: ...@@ -303,6 +303,9 @@ Bvardcl:
} }
| new_name_list_r type '=' expr_list | new_name_list_r type '=' expr_list
{ {
if(addtop != N)
fatal("new_name_list_r type '=' expr_list");
$$ = rev($1); $$ = rev($1);
dodclvar($$, $2); dodclvar($$, $2);
...@@ -423,6 +426,9 @@ simple_stmt: ...@@ -423,6 +426,9 @@ simple_stmt:
} }
| exprsym3_list_r LCOLAS expr_list | exprsym3_list_r LCOLAS expr_list
{ {
if(addtop != N)
fatal("exprsym3_list_r LCOLAS expr_list");
$$ = rev($1); $$ = rev($1);
$$ = colas($$, $3); $$ = colas($$, $3);
$$ = nod(OAS, $$, $3); $$ = nod(OAS, $$, $3);
......
...@@ -2417,20 +2417,20 @@ adddot(Node *n) ...@@ -2417,20 +2417,20 @@ adddot(Node *n)
walktype(n->left, Erv); walktype(n->left, Erv);
t = n->left->type; t = n->left->type;
if(t == T) if(t == T)
return n; goto ret;
if(n->right->op != ONAME) if(n->right->op != ONAME)
return n; goto ret;
s = n->right->sym; s = n->right->sym;
if(s == S) if(s == S)
return n; goto ret;
for(d=0; d<nelem(dotlist); d++) { for(d=0; d<nelem(dotlist); d++) {
c = adddot1(s, t, d); c = adddot1(s, t, d);
if(c > 0) if(c > 0)
goto out; goto out;
} }
return n; goto ret;
out: out:
if(c > 1) if(c > 1)
...@@ -2441,6 +2441,9 @@ out: ...@@ -2441,6 +2441,9 @@ out:
n = nod(ODOT, n, n->right); n = nod(ODOT, n, n->right);
n->left->right = newname(dotlist[c].field->sym); n->left->right = newname(dotlist[c].field->sym);
} }
ret:
n->ninit = list(addtop, n->ninit);
addtop = N;
return n; return n;
} }
......
...@@ -8,7 +8,6 @@ static Type* sw1(Node*, Type*); ...@@ -8,7 +8,6 @@ static Type* sw1(Node*, Type*);
static Type* sw2(Node*, Type*); static Type* sw2(Node*, Type*);
static Type* sw3(Node*, Type*); static Type* sw3(Node*, Type*);
static Node* curfn; static Node* curfn;
static Node* addtop;
enum enum
{ {
...@@ -65,6 +64,8 @@ walk(Node *fn) ...@@ -65,6 +64,8 @@ walk(Node *fn)
if(curfn->type->outtuple) if(curfn->type->outtuple)
if(walkret(curfn->nbody)) if(walkret(curfn->nbody))
yyerror("function ends without a return statement"); yyerror("function ends without a return statement");
if(addtop != N)
fatal("addtop in walk");
walkstate(curfn->nbody); walkstate(curfn->nbody);
if(debug['W']) { if(debug['W']) {
snprint(s, sizeof(s), "after %S", curfn->nname->sym); snprint(s, sizeof(s), "after %S", curfn->nname->sym);
...@@ -1544,6 +1545,9 @@ walkdot(Node *n) ...@@ -1544,6 +1545,9 @@ walkdot(Node *n)
{ {
Type *t; Type *t;
addtop = list(addtop, n->ninit);
n->ninit = N;
if(n->left == N || n->right == N) if(n->left == N || n->right == N)
return; return;
switch(n->op) { switch(n->op) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment