From: Ken Thompson Date: Fri, 19 Dec 2008 22:26:52 +0000 (-0800) Subject: array compare (except = != nil) are illegal X-Git-Tag: weekly.2009-11-06~2468 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a91a0a6a7a319425d29a47ab7900c432d6f648e4;p=gostls13.git array compare (except = != nil) are illegal R=r OCL=21637 CL=21637 --- diff --git a/src/cmd/6g/cgen.c b/src/cmd/6g/cgen.c index c0a665c072..e735858808 100644 --- a/src/cmd/6g/cgen.c +++ b/src/cmd/6g/cgen.c @@ -751,6 +751,11 @@ bgen(Node *n, int true, Prog *to) } if(isdarray(nl->type)) { + // only valid to cmp darray to literal nil + if((a != OEQ && a != ONE) || nr->op != OLITERAL) { + yyerror("illegal array comparison"); + break; + } a = optoas(a, types[tptr]); regalloc(&n1, types[tptr], N); agen(nl, &n1);