fix some bugs involving _.
R=ken
OCL=34621
CL=34621
Node *n;
uint32 w;
Sym *s;
+ int lno;
if(stksize < 0)
fatal("allocparams not during code generation");
* 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) {
}
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
uchar local;
uchar initorder;
uchar dodata; // compile literal assignment as data statement
+ uchar used;
// most nodes
Node* left;
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;
}
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;
}
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;
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);