Commit ac006ad1 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: change defaultlit2's force param to bool

Change-Id: I5546c4e8092ef61648cdae9c04288bb7d6f32476
Reviewed-on: https://go-review.googlesource.com/20084
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: default avatarDave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 33c0ef2d
...@@ -1349,7 +1349,7 @@ num: ...@@ -1349,7 +1349,7 @@ num:
// if they're both ideal going in they better // if they're both ideal going in they better
// get the same type going out. // get the same type going out.
// force means must assign concrete (non-ideal) type. // force means must assign concrete (non-ideal) type.
func defaultlit2(lp **Node, rp **Node, force int) { func defaultlit2(lp **Node, rp **Node, force bool) {
l := *lp l := *lp
r := *rp r := *rp
if l.Type == nil || r.Type == nil { if l.Type == nil || r.Type == nil {
...@@ -1365,9 +1365,10 @@ func defaultlit2(lp **Node, rp **Node, force int) { ...@@ -1365,9 +1365,10 @@ func defaultlit2(lp **Node, rp **Node, force int) {
return return
} }
if force == 0 { if !force {
return return
} }
if l.Type.Etype == TBOOL { if l.Type.Etype == TBOOL {
Convlit(lp, Types[TBOOL]) Convlit(lp, Types[TBOOL])
Convlit(rp, Types[TBOOL]) Convlit(rp, Types[TBOOL])
......
...@@ -567,7 +567,7 @@ OpSwitch: ...@@ -567,7 +567,7 @@ OpSwitch:
} }
// ideal mixed with non-ideal // ideal mixed with non-ideal
defaultlit2(&l, &r, 0) defaultlit2(&l, &r, false)
n.Left = l n.Left = l
n.Right = r n.Right = r
...@@ -640,7 +640,7 @@ OpSwitch: ...@@ -640,7 +640,7 @@ OpSwitch:
} }
if t.Etype != TIDEAL && !Eqtype(l.Type, r.Type) { if t.Etype != TIDEAL && !Eqtype(l.Type, r.Type) {
defaultlit2(&l, &r, 1) defaultlit2(&l, &r, true)
if n.Op == OASOP && n.Implicit { if n.Op == OASOP && n.Implicit {
Yyerror("invalid operation: %v (non-numeric type %v)", n, l.Type) Yyerror("invalid operation: %v (non-numeric type %v)", n, l.Type)
n.Type = nil n.Type = nil
...@@ -698,7 +698,7 @@ OpSwitch: ...@@ -698,7 +698,7 @@ OpSwitch:
evconst(n) evconst(n)
t = idealbool t = idealbool
if n.Op != OLITERAL { if n.Op != OLITERAL {
defaultlit2(&l, &r, 1) defaultlit2(&l, &r, true)
n.Left = l n.Left = l
n.Right = r n.Right = r
} }
...@@ -1484,7 +1484,7 @@ OpSwitch: ...@@ -1484,7 +1484,7 @@ OpSwitch:
n.Type = nil n.Type = nil
return return
} }
defaultlit2(&l, &r, 0) defaultlit2(&l, &r, false)
if l.Type == nil || r.Type == nil { if l.Type == nil || r.Type == nil {
n.Type = nil n.Type = nil
return return
......
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