Commit f09887cd authored by Shenghou Ma's avatar Shenghou Ma Committed by Minux Ma

cmd/internal/gc: do not show original expression for constants in export data

Fixes #10066.

Change-Id: I43c423793dd094989e921e163a06b12181a35719
Signed-off-by: default avatarShenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/6750
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarChris Manghane <cmang@golang.org>
parent 1fff4fbe
...@@ -1143,12 +1143,17 @@ func exprfmt(n *Node, prec int) string { ...@@ -1143,12 +1143,17 @@ func exprfmt(n *Node, prec int) string {
return f return f
case OLITERAL: // this is a bit of a mess case OLITERAL: // this is a bit of a mess
if fmtmode == FErr {
if n.Orig != nil && n.Orig != n { if n.Orig != nil && n.Orig != n {
return exprfmt(n.Orig, prec) return exprfmt(n.Orig, prec)
} }
if fmtmode == FErr && n.Sym != nil { if n.Sym != nil {
return fmt.Sprintf("%v", Sconv(n.Sym, 0)) return fmt.Sprintf("%v", Sconv(n.Sym, 0))
} }
}
if n.Val.Ctype == CTNIL && n.Orig != nil && n.Orig != n {
return exprfmt(n.Orig, prec)
}
if n.Type != nil && n.Type != Types[n.Type.Etype] && n.Type != idealbool && n.Type != idealstring { if n.Type != nil && n.Type != Types[n.Type.Etype] && n.Type != idealbool && n.Type != idealstring {
// Need parens when type begins with what might // Need parens when type begins with what might
// be misinterpreted as a unary operator: * or <-. // be misinterpreted as a unary operator: * or <-.
......
package a
import "log"
func Do() {
Do2()
}
func Do2() {
println(log.Ldate | log.Ltime | log.Lshortfile)
}
package b
import "./a"
func test() {
a.Do()
}
// compiledir
// Copyright 2015 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 10066: constants are printed in the original form
// in export data. This is the opposite of issue 9076.
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