From: Ken Thompson Date: Wed, 18 Nov 2009 06:00:59 +0000 (-0800) Subject: allow copy to be used without a return value X-Git-Tag: weekly.2009-12-07~234 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=01c2de0c150eda1433a83ca73f5c0d89bb398606;p=gostls13.git allow copy to be used without a return value R=rsc https://golang.org/cl/156060 --- diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 86633b86d9..3e88237859 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -762,7 +762,7 @@ reswitch: goto ret; case OCOPY: - ok |= Erv; + ok |= Etop|Erv; args = n->list; if(args == nil || args->next == nil) { yyerror("missing arguments to copy"); @@ -772,19 +772,19 @@ reswitch: yyerror("too many arguments to copy"); goto error; } - typecheck(&args->n, Erv); - typecheck(&args->next->n, Erv); - if(!isslice(args->n->type) || !isslice(args->next->n->type)) { + n->left = args->n; + n->right = args->next->n; + n->type = types[TINT]; + typecheck(&n->left, Erv); + typecheck(&n->right, Erv); + if(!isslice(n->left->type) || !isslice(n->right->type)) { yyerror("arguments to copy must be slices"); goto error; } - if(!eqtype(args->n->type, args->next->n->type)) { + if(!eqtype(n->left->type, n->right->type)) { yyerror("arguments to copy must be slices of the same type"); goto error; } - n->left = args->n; - n->right = args->next->n; - n->type = types[TINT]; goto ret; case OCONV: