1
0
mirror of https://github.com/golang/go synced 2024-11-25 15:08:02 -07:00

cmp [] to nil

R=r
OCL=21567
CL=21567
This commit is contained in:
Ken Thompson 2008-12-18 21:33:45 -08:00
parent 78fc888e64
commit dcc064fe94
3 changed files with 28 additions and 4 deletions

View 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) {

View File

@ -63,11 +63,17 @@ convlit1(Node *n, Type *t, int conv)
case Wlitnil:
if(isptrto(t, TSTRING))
goto bad1;
if(isptr[et])
switch(et) {
default:
goto bad1;
case TPTR32:
case TPTR64:
case TINTER:
case TARRAY:
break;
if(et == TINTER)
break;
goto bad1;
}
break;
case Wlitstr:
if(isnilinter(t)) {

View 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;