Commit 1c9e4b35 authored by Russ Cox's avatar Russ Cox

declared and not used; this time for sure

R=ken
OCL=34657
CL=34657
parent 67ab1b9f
...@@ -48,12 +48,8 @@ allocparams(void) ...@@ -48,12 +48,8 @@ allocparams(void)
} }
if(n->op != ONAME || n->class != PAUTO) if(n->op != ONAME || n->class != PAUTO)
continue; continue;
lineno = n->lineno;
typecheck(&n, Erv | Easgn); // only needed for unused variables
if(n->type == T) if(n->type == T)
continue; continue;
// if(!n->used && n->sym->name[0] != '&')
// yyerror("%S declared and not used", n->sym);
dowidth(n->type); dowidth(n->type);
w = n->type->width; w = n->type->width;
if(w >= 100000000) if(w >= 100000000)
...@@ -447,6 +443,7 @@ cgen_discard(Node *nr) ...@@ -447,6 +443,7 @@ cgen_discard(Node *nr)
switch(nr->op) { switch(nr->op) {
case ONAME: case ONAME:
gused(nr);
break; break;
// unary // unary
......
...@@ -82,7 +82,7 @@ out: ...@@ -82,7 +82,7 @@ out:
n->typecheck = 1; n->typecheck = 1;
for(ll=n->list; ll; ll=ll->next) for(ll=n->list; ll; ll=ll->next)
if(ll->n->typecheck == 0) if(ll->n->typecheck == 0)
typecheck(&ll->n, Erv); typecheck(&ll->n, Erv | Easgn);
} }
void void
......
...@@ -1975,7 +1975,7 @@ out: ...@@ -1975,7 +1975,7 @@ out:
n->typecheck = 1; n->typecheck = 1;
for(ll=n->list; ll; ll=ll->next) for(ll=n->list; ll; ll=ll->next)
if(ll->n->typecheck == 0) if(ll->n->typecheck == 0)
typecheck(&ll->n, Erv); typecheck(&ll->n, Erv | Easgn);
} }
/* /*
......
...@@ -67,6 +67,9 @@ void ...@@ -67,6 +67,9 @@ void
walk(Node *fn) walk(Node *fn)
{ {
char s[50]; char s[50];
NodeList *l;
Node *n;
int lno;
curfn = fn; curfn = fn;
if(debug['W']) { if(debug['W']) {
...@@ -77,6 +80,17 @@ walk(Node *fn) ...@@ -77,6 +80,17 @@ walk(Node *fn)
if(walkret(curfn->nbody)) if(walkret(curfn->nbody))
yyerror("function ends without a return statement"); yyerror("function ends without a return statement");
typechecklist(curfn->nbody, Etop); typechecklist(curfn->nbody, Etop);
lno = lineno;
for(l=fn->dcl; l; l=l->next) {
n = l->n;
if(n->op != ONAME || n->class != PAUTO)
continue;
lineno = n->lineno;
typecheck(&n, Erv | Easgn); // only needed for unused variables
if(!n->used && n->sym->name[0] != '&')
yyerror("%S declared and not used", n->sym);
}
lineno = lno;
if(nerrors != 0) if(nerrors != 0)
return; return;
walkstmtlist(curfn->nbody); walkstmtlist(curfn->nbody);
......
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