mirror of
https://github.com/golang/go
synced 2024-11-22 14:15:05 -07: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:
parent
fc0b5ef0fd
commit
20ebee2c31
@ -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:
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user