]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6g, cmd/8g: simplify calls to gvardef
authorIan Lance Taylor <iant@golang.org>
Wed, 26 Feb 2014 15:37:10 +0000 (07:37 -0800)
committerIan Lance Taylor <iant@golang.org>
Wed, 26 Feb 2014 15:37:10 +0000 (07:37 -0800)
The gvardef function does nothing if n->class == PEXTERN, so
we don't need to test for that before calling it.  This makes
the 6g/8g code more like the 5g code and clarifies that the
cases that do not test for n->class != PEXTERN are not buggy.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/68900044

src/cmd/6g/cgen.c
src/cmd/8g/cgen.c

index e1b5d1140ee8a5d57553b2ddf4ccfdccfa23b9fa..72ab0857e9f0abc26d2fe689d70f7a5184979ce9 100644 (file)
@@ -1389,11 +1389,11 @@ sgen(Node *n, Node *ns, int64 w)
 
        if(n->ullman >= ns->ullman) {
                agenr(n, &nodr, N);
-               if(ns->op == ONAME && ns->class != PEXTERN)
+               if(ns->op == ONAME)
                        gvardef(ns);
                agenr(ns, &nodl, N);
        } else {
-               if(ns->op == ONAME && ns->class != PEXTERN)
+               if(ns->op == ONAME)
                        gvardef(ns);
                agenr(ns, &nodl, N);
                agenr(n, &nodr, N);
@@ -1575,7 +1575,7 @@ componentgen(Node *nr, Node *nl)
        switch(nl->type->etype) {
        case TARRAY:
                // componentgen for arrays.
-               if(nl->op == ONAME && nl->class != PEXTERN)
+               if(nl->op == ONAME)
                        gvardef(nl);
                t = nl->type;
                if(!isslice(t)) {
@@ -1626,7 +1626,7 @@ componentgen(Node *nr, Node *nl)
                goto yes;
 
        case TSTRING:
-               if(nl->op == ONAME && nl->class != PEXTERN)
+               if(nl->op == ONAME)
                        gvardef(nl);
                nodl.xoffset += Array_array;
                nodl.type = ptrto(types[TUINT8]);
@@ -1651,7 +1651,7 @@ componentgen(Node *nr, Node *nl)
                goto yes;
 
        case TINTER:
-               if(nl->op == ONAME && nl->class != PEXTERN)
+               if(nl->op == ONAME)
                        gvardef(nl);
                nodl.xoffset += Array_array;
                nodl.type = ptrto(types[TUINT8]);
@@ -1676,7 +1676,7 @@ componentgen(Node *nr, Node *nl)
                goto yes;
 
        case TSTRUCT:
-               if(nl->op == ONAME && nl->class != PEXTERN)
+               if(nl->op == ONAME)
                        gvardef(nl);
                loffset = nodl.xoffset;
                roffset = nodr.xoffset;
index dc2350f491578ca578e97c79098422edc504abf2..825c360de42acbf1ef9719a379c940eeb71d97e7 100644 (file)
@@ -1384,7 +1384,7 @@ componentgen(Node *nr, Node *nl)
 
        switch(nl->type->etype) {
        case TARRAY:
-               if(nl->op == ONAME && nl->class != PEXTERN)
+               if(nl->op == ONAME)
                        gvardef(nl);
                nodl.xoffset += Array_array;
                nodl.type = ptrto(nl->type->type);
@@ -1419,7 +1419,7 @@ componentgen(Node *nr, Node *nl)
                goto yes;
 
        case TSTRING:
-               if(nl->op == ONAME && nl->class != PEXTERN)
+               if(nl->op == ONAME)
                        gvardef(nl);
                nodl.xoffset += Array_array;
                nodl.type = ptrto(types[TUINT8]);
@@ -1444,7 +1444,7 @@ componentgen(Node *nr, Node *nl)
                goto yes;
 
        case TINTER:
-               if(nl->op == ONAME && nl->class != PEXTERN)
+               if(nl->op == ONAME)
                        gvardef(nl);
                nodl.xoffset += Array_array;
                nodl.type = ptrto(types[TUINT8]);