Commit 20ebee2c authored by Rémy Oudompheng's avatar Rémy Oudompheng

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
parent fc0b5ef0
......@@ -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")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment