diff --git a/src/cmd/compile/internal/gc/const.go b/src/cmd/compile/internal/gc/const.go index 4d52d091b0..1d67e5fd10 100644 --- a/src/cmd/compile/internal/gc/const.go +++ b/src/cmd/compile/internal/gc/const.go @@ -12,7 +12,7 @@ import ( ) // Ctype describes the constant kind of an "ideal" (untyped) constant. -type Ctype int8 +type Ctype uint8 const ( CTxxx Ctype = iota @@ -297,7 +297,7 @@ func convlit1(n *Node, t *types.Type, explicit bool, reuse canReuseNode) *Node { ct := consttype(n) var et types.EType - if ct < 0 { + if ct == 0 { goto bad } @@ -591,7 +591,7 @@ func tostr(v Val) Val { func consttype(n *Node) Ctype { if n == nil || n.Op != OLITERAL { - return -1 + return 0 } return n.Val().Ctype() } @@ -693,7 +693,7 @@ func evconst(n *Node) { if nl == nil || nl.Type == nil { return } - if consttype(nl) < 0 { + if consttype(nl) == 0 { return } wl := nl.Type.Etype @@ -840,7 +840,7 @@ func evconst(n *Node) { if nr.Type == nil { return } - if consttype(nr) < 0 { + if consttype(nr) == 0 { return } wr = nr.Type.Etype diff --git a/src/cmd/compile/internal/gc/order.go b/src/cmd/compile/internal/gc/order.go index c555a5eabc..fdee8b89a5 100644 --- a/src/cmd/compile/internal/gc/order.go +++ b/src/cmd/compile/internal/gc/order.go @@ -187,7 +187,7 @@ func isaddrokay(n *Node) bool { // The result of orderaddrtemp MUST be assigned back to n, e.g. // n.Left = orderaddrtemp(n.Left, order) func orderaddrtemp(n *Node, order *Order) *Node { - if consttype(n) >= 0 { + if consttype(n) > 0 { // TODO: expand this to all static composite literal nodes? n = defaultlit(n, nil) dowidth(n.Type) diff --git a/src/cmd/compile/internal/gc/swt.go b/src/cmd/compile/internal/gc/swt.go index b97e68f60c..31d018b152 100644 --- a/src/cmd/compile/internal/gc/swt.go +++ b/src/cmd/compile/internal/gc/swt.go @@ -257,7 +257,7 @@ func (s *exprSwitch) walk(sw *Node) { var cas []*Node if s.kind == switchKindTrue || s.kind == switchKindFalse { s.exprname = nodbool(s.kind == switchKindTrue) - } else if consttype(cond) >= 0 { + } else if consttype(cond) > 0 { // leave constants to enable dead code elimination (issue 9608) s.exprname = cond } else { @@ -607,12 +607,7 @@ func checkDupExprCases(exprname *Node, clauses []*Node) { // case GOARCH == "arm" && GOARM == "5": // case GOARCH == "arm": // which would both evaluate to false for non-ARM compiles. - if ct := consttype(n); ct < 0 || ct == CTBOOL { - continue - } - // If the value has no type, we have - // already printed an error about it. - if n.Type == nil { + if ct := consttype(n); ct == 0 || ct == CTBOOL { continue } @@ -637,12 +632,7 @@ func checkDupExprCases(exprname *Node, clauses []*Node) { seen := make(map[typeVal]*Node) for _, ncase := range clauses { for _, n := range ncase.List.Slice() { - if ct := consttype(n); ct < 0 || ct == CTBOOL { - continue - } - // If the value has no type, we have - // already printed an error about it. - if n.Type == nil { + if ct := consttype(n); ct == 0 || ct == CTBOOL { continue } tv := typeVal{