aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/gc/typecheck.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/gc/typecheck.c')
-rw-r--r--src/cmd/gc/typecheck.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c
index 108a2d3e9b..86633b86d9 100644
--- a/src/cmd/gc/typecheck.c
+++ b/src/cmd/gc/typecheck.c
@@ -761,6 +761,32 @@ reswitch:
ok |= Etop;
goto ret;
+ case OCOPY:
+ ok |= Erv;
+ args = n->list;
+ if(args == nil || args->next == nil) {
+ yyerror("missing arguments to copy");
+ goto error;
+ }
+ if(args->next->next != nil) {
+ 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)) {
+ yyerror("arguments to copy must be slices");
+ goto error;
+ }
+ if(!eqtype(args->n->type, args->next->n->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:
doconv:
ok |= Erv;