]> Cypherpunks repositories - gostls13.git/commitdiff
cmp [] to nil
authorKen Thompson <ken@golang.org>
Fri, 19 Dec 2008 05:33:45 +0000 (21:33 -0800)
committerKen Thompson <ken@golang.org>
Fri, 19 Dec 2008 05:33:45 +0000 (21:33 -0800)
R=r
OCL=21567
CL=21567

src/cmd/6g/cgen.c
src/cmd/gc/const.c
src/cmd/gc/walk.c

index e19fdd11b18fdd9ebe577da76badd434c52c771a..a56ba7223693b462615ed047dcdccfe7163f0a66 100644 (file)
@@ -750,6 +750,20 @@ bgen(Node *n, int true, Prog *to)
                        nr = r;
                }
 
+               if(isdarray(nl->type)) {
+                       a = optoas(a, types[tptr]);
+                       regalloc(&n1, types[tptr], N);
+                       agen(nl, &n1);
+                       n2 = n1;
+                       n2.op = OINDREG;
+                       n2.xoffset = offsetof(Array,array);
+                       nodconst(&tmp, types[tptr], 0);
+                       gins(optoas(OCMP, types[tptr]), &n2, &tmp);
+                       patch(gbranch(a, types[tptr]), to);
+                       regfree(&n1);
+                       break;
+               }
+
                a = optoas(a, nr->type);
 
                if(nr->ullman >= UINF) {
index b903d582d6596a0463fcb23d478aecdc45ecccd2..eefc277a0fdb0411fbe8b469b0f941176f212a6b 100644 (file)
@@ -63,11 +63,17 @@ convlit1(Node *n, Type *t, int conv)
        case Wlitnil:
                if(isptrto(t, TSTRING))
                        goto bad1;
-               if(isptr[et])
-                       break;
-               if(et == TINTER)
+               switch(et) {
+               default:
+                       goto bad1;
+
+               case TPTR32:
+               case TPTR64:
+               case TINTER:
+               case TARRAY:
                        break;
-               goto bad1;
+               }
+               break;
 
        case Wlitstr:
                if(isnilinter(t)) {
index 55fd025f3a3bbf1924e58e0ac13ee5a2ac3eb844..a8f988b049933b2f46acd897f006c1a07abb938b 100644 (file)
@@ -1033,6 +1033,10 @@ loop:
        case ONE:
                if(n->left->type == T)
                        goto ret;
+               if(isdarray(n->left->type)) {
+                       t = types[TBOOL];
+                       break;
+               }
                et = n->left->type->etype;
                if(!okforeq[et])
                        goto badt;