]> Cypherpunks repositories - gostls13.git/commitdiff
declared and not used; this time for sure
authorRuss Cox <rsc@golang.org>
Tue, 15 Sep 2009 21:11:43 +0000 (14:11 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 15 Sep 2009 21:11:43 +0000 (14:11 -0700)
R=ken
OCL=34657
CL=34657

src/cmd/gc/gen.c
src/cmd/gc/range.c
src/cmd/gc/typecheck.c
src/cmd/gc/walk.c

index 8c00c58987498d9a5883fc3c384fc393735b4217..b7c2474bf29bf4d197d1c86fda441abe64468fb2 100644 (file)
@@ -48,12 +48,8 @@ allocparams(void)
                }
                if(n->op != ONAME || n->class != PAUTO)
                        continue;
-               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(w >= 100000000)
@@ -447,6 +443,7 @@ cgen_discard(Node *nr)
 
        switch(nr->op) {
        case ONAME:
+               gused(nr);
                break;
 
        // unary
index 3e34906712271c794427c53e72c013e5c96c6885..393dd6426a3fe054efe428b41e75ef8f8c3ad9b8 100644 (file)
@@ -82,7 +82,7 @@ out:
        n->typecheck = 1;
        for(ll=n->list; ll; ll=ll->next)
                if(ll->n->typecheck == 0)
-                       typecheck(&ll->n, Erv);
+                       typecheck(&ll->n, Erv | Easgn);
 }
 
 void
index 308ed90e3374b485e59781c8d906982482c5ba1b..2f2b6f6a133dea065d074ac5402fdd3557d3511d 100644 (file)
@@ -1975,7 +1975,7 @@ out:
        n->typecheck = 1;
        for(ll=n->list; ll; ll=ll->next)
                if(ll->n->typecheck == 0)
-                       typecheck(&ll->n, Erv);
+                       typecheck(&ll->n, Erv | Easgn);
 }
 
 /*
index e66a42ce23bfacbe598f2dfd7d16e9b995b3b39f..7524cecedf6940d5ffb649f819ee17cb4ce87ff1 100644 (file)
@@ -67,6 +67,9 @@ void
 walk(Node *fn)
 {
        char s[50];
+       NodeList *l;
+       Node *n;
+       int lno;
 
        curfn = fn;
        if(debug['W']) {
@@ -77,6 +80,17 @@ walk(Node *fn)
                if(walkret(curfn->nbody))
                        yyerror("function ends without a return statement");
        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)
                return;
        walkstmtlist(curfn->nbody);