Commit 836a517f authored by Russ Cox's avatar Russ Cox

gc: fix inlining bug

Fixes #2682.

R=lvd
CC=golang-dev
https://golang.org/cl/5538043
parent f2b51f56
......@@ -1078,7 +1078,9 @@ exprfmt(Fmt *f, Node *n, int prec)
if(n->val.ctype == CTNIL)
n = n->orig; // if this node was a nil decorated with at type, print the original naked nil
if(n->type != types[n->type->etype] && n->type != idealbool && n->type != idealstring) {
if(isptr[n->type->etype])
// Need parens when type begins with what might
// be misinterpreted as a unary operator: * or <-.
if(isptr[n->type->etype] || (n->type->etype == TCHAN && n->type->chan == Crecv))
return fmtprint(f, "(%T)(%V)", n->type, &n->val);
else
return fmtprint(f, "%T(%V)", n->type, &n->val);
......
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Functions that the inliner exported incorrectly.
package one
type file int
func (file *file) isnil() bool { return file == nil }
func (fil *file) isnil2() bool { return fil == nil }
type T int
// Issue 2678
func F1(T *T) bool { return T == nil }
// Issue 2682.
func F2(c chan int) bool { return c == (<-chan int)(nil) }
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Use the functions in one.go so that the inlined
// forms get type-checked.
package two
import _ "./one"
import "./one"
func use() {
one.F1(nil)
one.F2(nil)
}
// $G $D/$F.dir/one.go && $G -ll $D/$F.dir/two.go
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Issue 2678
// -ll flag in command above is to force typecheck on import, needed to trigger the bug.
// fixedbugs/bug392.dir/two.go:3: cannot call non-function *one.file (type one.file)
package ignored
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