1
0
mirror of https://github.com/golang/go synced 2024-09-24 01:20:13 -06:00

cmd/gc: fix pointer composite literals in exported if statements.

Fixes #4230 (again).

R=rsc, golang-dev, r
CC=golang-dev
https://golang.org/cl/10470043
This commit is contained in:
Rémy Oudompheng 2013-06-23 18:39:07 +02:00
parent fc0b5ef0fd
commit 20ebee2c31
3 changed files with 17 additions and 2 deletions

View 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:

View 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
}

View 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")
}