]> Cypherpunks repositories - gostls13.git/commitdiff
array compare (except = != nil) are illegal
authorKen Thompson <ken@golang.org>
Fri, 19 Dec 2008 22:26:52 +0000 (14:26 -0800)
committerKen Thompson <ken@golang.org>
Fri, 19 Dec 2008 22:26:52 +0000 (14:26 -0800)
R=r
OCL=21637
CL=21637

src/cmd/6g/cgen.c

index c0a665c072e4fc7a4469e4290789fd68436d87e2..e7358588081797cf987dd87f065d3d4926938133 100644 (file)
@@ -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);