]> Cypherpunks repositories - gostls13.git/commitdiff
gc: small fixes for printing.
authorLuuk van Dijk <lvd@golang.org>
Wed, 2 Nov 2011 14:36:33 +0000 (15:36 +0100)
committerLuuk van Dijk <lvd@golang.org>
Wed, 2 Nov 2011 14:36:33 +0000 (15:36 +0100)
mark OADDR inserted by typecheck as implicit
OCOPY takes ->left and ->right, not ->list
OMAKE*'s can all have arguments
precedence for OIND was initalized twice

fixes #2414

R=rsc, dave
CC=golang-dev
https://golang.org/cl/5319065

src/cmd/gc/fmt.c
src/cmd/gc/typecheck.c
test/escape2.go

index 12ea3028270a97981d5e59e28c525665053821fc..9447e9b1eb84c71bd0cee5c70e621dffa3fbe60b 100644 (file)
@@ -921,7 +921,6 @@ static int opprec[] = {
 
        [OINDEXMAP] = 8,
        [OINDEX] = 8,
-       [OIND] = 8,
        [ODOTINTER] = 8,
        [ODOTMETH] = 8,
        [ODOTPTR] = 8,
@@ -1146,6 +1145,7 @@ exprfmt(Fmt *f, Node *n, int prec)
                exprfmt(f, n->left, nprec);
                return fmtprint(f, "[%N]", n->right);
 
+       case OCOPY:
        case OCOMPLEX:
                return fmtprint(f, "%#O(%N, %N)", n->op, n->left, n->right);
 
@@ -1167,7 +1167,6 @@ exprfmt(Fmt *f, Node *n, int prec)
        case OCAP:
        case OCLOSE:
        case OLEN:
-       case OCOPY:
        case OMAKE:
        case ONEW:
        case OPANIC:
@@ -1188,13 +1187,11 @@ exprfmt(Fmt *f, Node *n, int prec)
                        return fmtprint(f, "(%,H...)", n->list);
                return fmtprint(f, "(%,H)", n->list);
 
-       case OMAKESLICE:
-               if(count(n->list) > 2)
-                       return fmtprint(f, "make(%T, %N, %N)", n->type, n->left, n->right);   // count list, but print l/r?
-               return fmtprint(f, "make(%T, %N)", n->type, n->left);
-
        case OMAKEMAP:
        case OMAKECHAN:
+       case OMAKESLICE:
+               if(n->list->next)
+                       return fmtprint(f, "make(%T, %,H)", n->type, n->list->next);
                return fmtprint(f, "make(%T)", n->type);
 
        case OADD:
index 87a8d783583ca45589d5c0f22a639919342cc1fe..d2268e6641f54e41d8ebed50816a8171ab763c9a 100644 (file)
@@ -745,6 +745,7 @@ reswitch:
                defaultlit(&n->right->right, T);
                if(isfixedarray(n->left->type)) {
                        n->left = nod(OADDR, n->left, N);
+                       n->left->implicit = 1;
                        typecheck(&n->left, top);
                }
                if(n->right->left != N) {
index 06ada5aaa0f614ac15f7305d27a61846804eabaf..3f7d6e3a161dbeaf94417a691cf00f4bf83a6f30 100644 (file)
@@ -148,7 +148,7 @@ func (b *Bar2) NoLeak() int { // ERROR "b does not escape"
 }
 
 func (b *Bar2) Leak() []int { // ERROR "leaking param: b"
-       return b.i[:] // ERROR "&b.i escapes to heap"
+       return b.i[:]  // ERROR "b.i escapes to heap"
 }
 
 func (b *Bar2) AlsoNoLeak() []int { // ERROR "b does not escape"
@@ -156,12 +156,12 @@ func (b *Bar2) AlsoNoLeak() []int { // ERROR "b does not escape"
 }
 
 func (b *Bar2) LeakSelf() { // ERROR "leaking param: b"
-       b.ii = b.i[0:4] // ERROR "&b.i escapes to heap"
+       b.ii = b.i[0:4]  // ERROR "b.i escapes to heap"
 }
 
 func (b *Bar2) LeakSelf2() { // ERROR "leaking param: b"
        var buf []int
-       buf = b.i[0:] // ERROR "&b.i escapes to heap"
+       buf = b.i[0:]  // ERROR "b.i escapes to heap"
        b.ii = buf
 }