mirror of
https://github.com/golang/go
synced 2024-11-21 17:54:39 -07:00
gc: ... bug
Fixes #1165. R=ken2 CC=golang-dev https://golang.org/cl/2339042
This commit is contained in:
parent
30dd191171
commit
01385b400d
@ -11,7 +11,7 @@ static Node* makenewvar(Type*, NodeList**, Node**);
|
||||
static Node* ascompatee1(int, Node*, Node*, NodeList**);
|
||||
static NodeList* ascompatee(int, NodeList*, NodeList*, NodeList**);
|
||||
static NodeList* ascompatet(int, NodeList*, Type**, int, NodeList**);
|
||||
static NodeList* ascompatte(int, Type**, NodeList*, int, NodeList**);
|
||||
static NodeList* ascompatte(int, int, Type**, NodeList*, int, NodeList**);
|
||||
static Node* convas(Node*, NodeList**);
|
||||
static void heapmoves(void);
|
||||
static NodeList* paramstoheap(Type **argin, int out);
|
||||
@ -513,7 +513,7 @@ walkstmt(Node **np)
|
||||
n->list = reorder3(ll);
|
||||
break;
|
||||
}
|
||||
ll = ascompatte(n->op, getoutarg(curfn->type), n->list, 1, &n->ninit);
|
||||
ll = ascompatte(n->op, 0, getoutarg(curfn->type), n->list, 1, &n->ninit);
|
||||
n->list = ll;
|
||||
break;
|
||||
|
||||
@ -708,7 +708,7 @@ walkexpr(Node **np, NodeList **init)
|
||||
goto ret;
|
||||
walkexpr(&n->left, init);
|
||||
walkexprlist(n->list, init);
|
||||
ll = ascompatte(n->op, getinarg(t), n->list, 0, init);
|
||||
ll = ascompatte(n->op, n->isddd, getinarg(t), n->list, 0, init);
|
||||
n->list = reorder1(ll);
|
||||
goto ret;
|
||||
|
||||
@ -718,7 +718,7 @@ walkexpr(Node **np, NodeList **init)
|
||||
goto ret;
|
||||
walkexpr(&n->left, init);
|
||||
walkexprlist(n->list, init);
|
||||
ll = ascompatte(n->op, getinarg(t), n->list, 0, init);
|
||||
ll = ascompatte(n->op, n->isddd, getinarg(t), n->list, 0, init);
|
||||
n->list = reorder1(ll);
|
||||
if(isselect(n)) {
|
||||
// special prob with selectsend and selectrecv:
|
||||
@ -728,7 +728,7 @@ walkexpr(Node **np, NodeList **init)
|
||||
Node *b;
|
||||
b = nodbool(0);
|
||||
typecheck(&b, Erv);
|
||||
lr = ascompatte(n->op, getoutarg(t), list1(b), 0, init);
|
||||
lr = ascompatte(n->op, 0, getoutarg(t), list1(b), 0, init);
|
||||
n->list = concat(n->list, lr);
|
||||
}
|
||||
goto ret;
|
||||
@ -739,8 +739,8 @@ walkexpr(Node **np, NodeList **init)
|
||||
goto ret;
|
||||
walkexpr(&n->left, init);
|
||||
walkexprlist(n->list, init);
|
||||
ll = ascompatte(n->op, getthis(t), list1(n->left->left), 0, init);
|
||||
lr = ascompatte(n->op, getinarg(t), n->list, 0, init);
|
||||
ll = ascompatte(n->op, 0, getthis(t), list1(n->left->left), 0, init);
|
||||
lr = ascompatte(n->op, n->isddd, getinarg(t), n->list, 0, init);
|
||||
ll = concat(ll, lr);
|
||||
n->left->left = N;
|
||||
ullmancalc(n->left);
|
||||
@ -1599,7 +1599,7 @@ dumpnodetypes(NodeList *l, char *what)
|
||||
* func(expr-list)
|
||||
*/
|
||||
static NodeList*
|
||||
ascompatte(int op, Type **nl, NodeList *lr, int fp, NodeList **init)
|
||||
ascompatte(int op, int isddd, Type **nl, NodeList *lr, int fp, NodeList **init)
|
||||
{
|
||||
Type *l, *ll;
|
||||
Node *r, *a;
|
||||
@ -1654,7 +1654,7 @@ loop:
|
||||
// only if we are assigning a single ddd
|
||||
// argument to a ddd parameter then it is
|
||||
// passed thru unencapsulated
|
||||
if(r != N && lr->next == nil && r->isddd && eqtype(l->type, r->type)) {
|
||||
if(r != N && lr->next == nil && isddd && eqtype(l->type, r->type)) {
|
||||
a = nod(OAS, nodarg(l, fp), r);
|
||||
a = convas(a, init);
|
||||
nn = list(nn, a);
|
||||
|
20
test/ddd.go
20
test/ddd.go
@ -30,10 +30,14 @@ func sumA(args []int) int {
|
||||
return s
|
||||
}
|
||||
|
||||
func sumB(args []int) int { return sum(args...) }
|
||||
|
||||
func sum2(args ...int) int { return 2 * sum(args...) }
|
||||
|
||||
func sum3(args ...int) int { return 3 * sumA(args) }
|
||||
|
||||
func sum4(args ...int) int { return 4 * sumB(args) }
|
||||
|
||||
func intersum(args ...interface{}) int {
|
||||
s := 0
|
||||
for _, v := range args {
|
||||
@ -119,6 +123,22 @@ func main() {
|
||||
println("sum 9", x)
|
||||
panic("fail")
|
||||
}
|
||||
if x := sum4(1, 2, 3); x != 4*6 {
|
||||
println("sum 6", x)
|
||||
panic("fail")
|
||||
}
|
||||
if x := sum4(); x != 4*0 {
|
||||
println("sum 0", x)
|
||||
panic("fail")
|
||||
}
|
||||
if x := sum4(10); x != 4*10 {
|
||||
println("sum 10", x)
|
||||
panic("fail")
|
||||
}
|
||||
if x := sum4(1, 8); x != 4*9 {
|
||||
println("sum 9", x)
|
||||
panic("fail")
|
||||
}
|
||||
if x := intersum(1, 2, 3); x != 6 {
|
||||
println("intersum 6", x)
|
||||
panic("fail")
|
||||
|
Loading…
Reference in New Issue
Block a user