Commit dcc064fe authored by Ken Thompson's avatar Ken Thompson

cmp [] to nil

R=r
OCL=21567
CL=21567
parent 78fc888e
...@@ -750,6 +750,20 @@ bgen(Node *n, int true, Prog *to) ...@@ -750,6 +750,20 @@ bgen(Node *n, int true, Prog *to)
nr = r; 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); a = optoas(a, nr->type);
if(nr->ullman >= UINF) { if(nr->ullman >= UINF) {
......
...@@ -63,11 +63,17 @@ convlit1(Node *n, Type *t, int conv) ...@@ -63,11 +63,17 @@ convlit1(Node *n, Type *t, int conv)
case Wlitnil: case Wlitnil:
if(isptrto(t, TSTRING)) if(isptrto(t, TSTRING))
goto bad1; goto bad1;
if(isptr[et]) switch(et) {
default:
goto bad1;
case TPTR32:
case TPTR64:
case TINTER:
case TARRAY:
break; break;
if(et == TINTER) }
break; break;
goto bad1;
case Wlitstr: case Wlitstr:
if(isnilinter(t)) { if(isnilinter(t)) {
......
...@@ -1033,6 +1033,10 @@ loop: ...@@ -1033,6 +1033,10 @@ loop:
case ONE: case ONE:
if(n->left->type == T) if(n->left->type == T)
goto ret; goto ret;
if(isdarray(n->left->type)) {
t = types[TBOOL];
break;
}
et = n->left->type->etype; et = n->left->type->etype;
if(!okforeq[et]) if(!okforeq[et])
goto badt; goto badt;
......
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