]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix pointer composite literals in exported if statements.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Sun, 23 Jun 2013 16:39:07 +0000 (18:39 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Sun, 23 Jun 2013 16:39:07 +0000 (18:39 +0200)
Fixes #4230 (again).

R=rsc, golang-dev, r
CC=golang-dev
https://golang.org/cl/10470043

src/cmd/gc/fmt.c
test/fixedbugs/bug465.dir/a.go
test/fixedbugs/bug465.dir/b.go

index d541c967aff8ed8839c2b90e8501d6c7f40f0591..c7519c97622ea33d6faff321a4b2a9ba213bb456 100644 (file)
@@ -1222,7 +1222,7 @@ exprfmt(Fmt *f, Node *n, int prec)
                }
                if(fmtmode == FExp && ptrlit)
                        // typecheck has overwritten OIND by OTYPE with pointer type.
-                       return fmtprint(f, "&%T{ %,H }", n->right->type->type, n->list);
+                       return fmtprint(f, "(&%T{ %,H })", n->right->type->type, n->list);
                return fmtprint(f, "(%N{ %,H })", n->right, n->list);
 
        case OPTRLIT:
index c5d410de47cddf62e3c06ff0253b4382fb4d7a56..a9a8614bb33d084d934f76684370a73617cd5256 100644 (file)
@@ -59,3 +59,18 @@ func F7() int {
        }
        return 0
 }
+
+func F8() int {
+       if a := (&T{1, 1}); a != nil {
+               return 1
+       }
+       return 0
+}
+
+func F9() int {
+       var a *T
+       if a = (&T{1, 1}); a != nil {
+               return 1
+       }
+       return 0
+}
index 0f4909f4db3ebbf5d0b74be8c14e28ac2ee4a2be..c84c6836d62539666193391131edc2b059d90a04 100644 (file)
@@ -9,7 +9,7 @@ import "./a"
 func main() {
        for _, f := range []func() int{
                a.F1, a.F2, a.F3, a.F4,
-               a.F5, a.F6, a.F7} {
+               a.F5, a.F6, a.F7, a.F8, a.F9} {
                if f() > 1 {
                        panic("f() > 1")
                }