)
// Ctype describes the constant kind of an "ideal" (untyped) constant.
-type Ctype int8
+type Ctype uint8
const (
CTxxx Ctype = iota
ct := consttype(n)
var et types.EType
- if ct < 0 {
+ if ct == 0 {
goto bad
}
func consttype(n *Node) Ctype {
if n == nil || n.Op != OLITERAL {
- return -1
+ return 0
}
return n.Val().Ctype()
}
if nl == nil || nl.Type == nil {
return
}
- if consttype(nl) < 0 {
+ if consttype(nl) == 0 {
return
}
wl := nl.Type.Etype
if nr.Type == nil {
return
}
- if consttype(nr) < 0 {
+ if consttype(nr) == 0 {
return
}
wr = nr.Type.Etype
// 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)
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 {
// 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
}
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{