1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:14:40 -07:00

order of evaluation in function args

R=r
OCL=14733
CL=14733
This commit is contained in:
Ken Thompson 2008-09-02 17:12:32 -07:00
parent 9c5669bd0b
commit 0ffacfd995

View File

@ -2392,57 +2392,59 @@ convas(Node *n)
if(n->op != OAS) if(n->op != OAS)
fatal("convas: not OAS %O", n->op); fatal("convas: not OAS %O", n->op);
ullmancalc(n);
l = n->left; l = n->left;
r = n->right; r = n->right;
if(l == N || r == N) if(l == N || r == N)
return n; goto out;
lt = l->type; lt = l->type;
rt = r->type; rt = r->type;
if(lt == T || rt == T) if(lt == T || rt == T)
return n; goto out;
if(n->left->op == OINDEX) if(n->left->op == OINDEX)
if(isptrto(n->left->left->type, TMAP)) { if(isptrto(n->left->left->type, TMAP)) {
*n = *mapop(n, Elv); *n = *mapop(n, Elv);
return n; goto out;
} }
if(n->left->op == OINDEXPTR) if(n->left->op == OINDEXPTR)
if(n->left->left->type->etype == TMAP) { if(n->left->left->type->etype == TMAP) {
*n = *mapop(n, Elv); *n = *mapop(n, Elv);
return n; goto out;
} }
if(n->left->op == OSEND) if(n->left->op == OSEND)
if(n->left->type != T) { if(n->left->type != T) {
*n = *chanop(n, Elv); *n = *chanop(n, Elv);
return n; goto out;
} }
if(eqtype(lt, rt, 0)) if(eqtype(lt, rt, 0))
return n; goto out;
r = isandss(lt, r); r = isandss(lt, r);
if(r != N) { if(r != N) {
n->right = r; n->right = r;
walktype(n, Etop); walktype(n, Etop);
return n; goto out;
} }
if(isptrdarray(lt) && isptrarray(rt)) { if(isptrdarray(lt) && isptrarray(rt)) {
if(!eqtype(lt->type->type, rt->type->type, 0)) if(!eqtype(lt->type->type, rt->type->type, 0))
goto bad; goto bad;
*n = *arrayop(n, Etop); *n = *arrayop(n, Etop);
return n; goto out;
} }
if(ascompat(lt, rt)) if(ascompat(lt, rt))
return n; goto out;
bad: bad:
badtype(n->op, lt, rt); badtype(n->op, lt, rt);
out:
ullmancalc(n);
return n; return n;
} }