Commit 8937780c authored by Dave Cheney's avatar Dave Cheney

cmd/compile/internal/gc: convert Type.Broke into a bool

Convert Type.Broke from a uint8 to a boolean

This change passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I44e7548c71b00467e36576bdf62933c42555a21a
Reviewed-on: https://go-review.googlesource.com/14307
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarHåvard Haugen <havard.haugen@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 8712e186
...@@ -129,8 +129,8 @@ func dowidth(t *Type) { ...@@ -129,8 +129,8 @@ func dowidth(t *Type) {
if t.Width == -2 { if t.Width == -2 {
lno := int(lineno) lno := int(lineno)
lineno = int32(t.Lineno) lineno = int32(t.Lineno)
if t.Broke == 0 { if !t.Broke {
t.Broke = 1 t.Broke = true
Yyerror("invalid recursive type %v", t) Yyerror("invalid recursive type %v", t)
} }
...@@ -141,7 +141,7 @@ func dowidth(t *Type) { ...@@ -141,7 +141,7 @@ func dowidth(t *Type) {
// break infinite recursion if the broken recursive type // break infinite recursion if the broken recursive type
// is referenced again // is referenced again
if t.Broke != 0 && t.Width == 0 { if t.Broke && t.Width == 0 {
return return
} }
...@@ -233,7 +233,7 @@ func dowidth(t *Type) { ...@@ -233,7 +233,7 @@ func dowidth(t *Type) {
checkwidth(t.Down) checkwidth(t.Down)
case TFORW: // should have been filled in case TFORW: // should have been filled in
if t.Broke == 0 { if !t.Broke {
Yyerror("invalid recursive type %v", t) Yyerror("invalid recursive type %v", t)
} }
w = 1 // anything will do w = 1 // anything will do
...@@ -272,9 +272,9 @@ func dowidth(t *Type) { ...@@ -272,9 +272,9 @@ func dowidth(t *Type) {
checkwidth(t.Type) checkwidth(t.Type)
t.Align = uint8(Widthptr) t.Align = uint8(Widthptr)
} else if t.Bound == -100 { } else if t.Bound == -100 {
if t.Broke == 0 { if !t.Broke {
Yyerror("use of [...] array outside of array literal") Yyerror("use of [...] array outside of array literal")
t.Broke = 1 t.Broke = true
} }
} else { } else {
Fatalf("dowidth %v", t) // probably [...]T Fatalf("dowidth %v", t) // probably [...]T
......
...@@ -292,7 +292,7 @@ func convlit1(np **Node, t *Type, explicit bool) { ...@@ -292,7 +292,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
bad: bad:
if n.Diag == 0 { if n.Diag == 0 {
if t.Broke == 0 { if !t.Broke {
Yyerror("cannot convert %v to type %v", n, t) Yyerror("cannot convert %v to type %v", n, t)
} }
n.Diag = 1 n.Diag = 1
......
...@@ -834,7 +834,7 @@ func structfield(n *Node) *Type { ...@@ -834,7 +834,7 @@ func structfield(n *Node) *Type {
f.Type = n.Type f.Type = n.Type
if f.Type == nil { if f.Type == nil {
f.Broke = 1 f.Broke = true
} }
switch n.Val().Ctype() { switch n.Val().Ctype() {
...@@ -894,16 +894,16 @@ func tostruct(l *NodeList) *Type { ...@@ -894,16 +894,16 @@ func tostruct(l *NodeList) *Type {
tp = &f.Down tp = &f.Down
} }
for f := t.Type; f != nil && t.Broke == 0; f = f.Down { for f := t.Type; f != nil && !t.Broke; f = f.Down {
if f.Broke != 0 { if f.Broke {
t.Broke = 1 t.Broke = true
} }
} }
uniqgen++ uniqgen++
checkdupfields(t.Type, "field") checkdupfields(t.Type, "field")
if t.Broke == 0 { if !t.Broke {
checkwidth(t) checkwidth(t)
} }
...@@ -929,9 +929,9 @@ func tofunargs(l *NodeList) *Type { ...@@ -929,9 +929,9 @@ func tofunargs(l *NodeList) *Type {
tp = &f.Down tp = &f.Down
} }
for f := t.Type; f != nil && t.Broke == 0; f = f.Down { for f := t.Type; f != nil && !t.Broke; f = f.Down {
if f.Broke != 0 { if f.Broke {
t.Broke = 1 t.Broke = true
} }
} }
...@@ -984,11 +984,11 @@ func interfacefield(n *Node) *Type { ...@@ -984,11 +984,11 @@ func interfacefield(n *Node) *Type {
case TFORW: case TFORW:
Yyerror("interface type loop involving %v", n.Type) Yyerror("interface type loop involving %v", n.Type)
f.Broke = 1 f.Broke = true
default: default:
Yyerror("interface contains embedded non-interface %v", n.Type) Yyerror("interface contains embedded non-interface %v", n.Type)
f.Broke = 1 f.Broke = true
} }
} }
} }
...@@ -998,7 +998,7 @@ func interfacefield(n *Node) *Type { ...@@ -998,7 +998,7 @@ func interfacefield(n *Node) *Type {
f.Type = n.Type f.Type = n.Type
if f.Type == nil { if f.Type == nil {
f.Broke = 1 f.Broke = true
} }
lineno = int32(lno) lineno = int32(lno)
...@@ -1034,9 +1034,9 @@ func tointerface(l *NodeList) *Type { ...@@ -1034,9 +1034,9 @@ func tointerface(l *NodeList) *Type {
} }
} }
for f := t.Type; f != nil && t.Broke == 0; f = f.Down { for f := t.Type; f != nil && !t.Broke; f = f.Down {
if f.Broke != 0 { if f.Broke {
t.Broke = 1 t.Broke = true
} }
} }
...@@ -1224,8 +1224,8 @@ func functype(this *Node, in *NodeList, out *NodeList) *Type { ...@@ -1224,8 +1224,8 @@ func functype(this *Node, in *NodeList, out *NodeList) *Type {
checkdupfields(t.Type.Down.Type, "argument") checkdupfields(t.Type.Down.Type, "argument")
checkdupfields(t.Type.Down.Down.Type, "argument") checkdupfields(t.Type.Down.Down.Type, "argument")
if t.Type.Broke != 0 || t.Type.Down.Broke != 0 || t.Type.Down.Down.Broke != 0 { if t.Type.Broke || t.Type.Down.Broke || t.Type.Down.Down.Broke {
t.Broke = 1 t.Broke = true
} }
if this != nil { if this != nil {
...@@ -1383,7 +1383,7 @@ func addmethod(sf *Sym, t *Type, local bool, nointerface bool) { ...@@ -1383,7 +1383,7 @@ func addmethod(sf *Sym, t *Type, local bool, nointerface bool) {
t = t.Type t = t.Type
} }
if t.Broke != 0 { // rely on typecheck having complained before if t.Broke { // rely on typecheck having complained before
return return
} }
if t.Sym == nil { if t.Sym == nil {
......
...@@ -165,8 +165,8 @@ type Type struct { ...@@ -165,8 +165,8 @@ type Type struct {
Copyany uint8 Copyany uint8
Local bool // created in this file Local bool // created in this file
Deferwidth uint8 Deferwidth uint8
Broke uint8 // broken type definition. Broke bool // broken type definition.
Isddd bool // TFIELD is ... argument Isddd bool // TFIELD is ... argument
Align uint8 Align uint8
Haspointers uint8 // 0 unknown, 1 no, 2 yes Haspointers uint8 // 0 unknown, 1 no, 2 yes
......
...@@ -426,7 +426,7 @@ func algtype1(t *Type, bad **Type) int { ...@@ -426,7 +426,7 @@ func algtype1(t *Type, bad **Type) int {
if bad != nil { if bad != nil {
*bad = nil *bad = nil
} }
if t.Broke != 0 { if t.Broke {
return AMEM return AMEM
} }
if t.Noalg != 0 { if t.Noalg != 0 {
...@@ -1133,7 +1133,7 @@ func assignop(src *Type, dst *Type, why *string) int { ...@@ -1133,7 +1133,7 @@ func assignop(src *Type, dst *Type, why *string) int {
} }
// we'll have complained about this method anyway, suppress spurious messages. // we'll have complained about this method anyway, suppress spurious messages.
if have != nil && have.Sym == missing.Sym && (have.Type.Broke != 0 || missing.Type.Broke != 0) { if have != nil && have.Sym == missing.Sym && (have.Type.Broke || missing.Type.Broke) {
return OCONVIFACE return OCONVIFACE
} }
...@@ -1317,7 +1317,7 @@ func assignconv(n *Node, t *Type, context string) *Node { ...@@ -1317,7 +1317,7 @@ func assignconv(n *Node, t *Type, context string) *Node {
// Convert node n for assignment to type t. // Convert node n for assignment to type t.
func assignconvfn(n *Node, t *Type, context func() string) *Node { func assignconvfn(n *Node, t *Type, context func() string) *Node {
if n == nil || n.Type == nil || n.Type.Broke != 0 { if n == nil || n.Type == nil || n.Type.Broke {
return n return n
} }
......
...@@ -153,9 +153,9 @@ func typecheckswitch(n *Node) { ...@@ -153,9 +153,9 @@ func typecheckswitch(n *Node) {
// reset to original type // reset to original type
ll.N = n.Left.Right ll.N = n.Left.Right
case ll.N.Type.Etype != TINTER && t.Etype == TINTER && !implements(ll.N.Type, t, &missing, &have, &ptr): case ll.N.Type.Etype != TINTER && t.Etype == TINTER && !implements(ll.N.Type, t, &missing, &have, &ptr):
if have != nil && missing.Broke == 0 && have.Broke == 0 { if have != nil && !missing.Broke && !have.Broke {
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%v\n\twant %v%v", Nconv(n.Left.Right, obj.FmtLong), ll.N.Type, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort), missing.Sym, Tconv(missing.Type, obj.FmtShort)) Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%v\n\twant %v%v", Nconv(n.Left.Right, obj.FmtLong), ll.N.Type, missing.Sym, have.Sym, Tconv(have.Type, obj.FmtShort), missing.Sym, Tconv(missing.Type, obj.FmtShort))
} else if missing.Broke == 0 { } else if !missing.Broke {
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (missing %v method)", Nconv(n.Left.Right, obj.FmtLong), ll.N.Type, missing.Sym) Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (missing %v method)", Nconv(n.Left.Right, obj.FmtLong), ll.N.Type, missing.Sym)
} }
} }
......
...@@ -348,7 +348,7 @@ OpSwitch: ...@@ -348,7 +348,7 @@ OpSwitch:
} else if l.Op == ODDD { } else if l.Op == ODDD {
t.Bound = -100 // to be filled in t.Bound = -100 // to be filled in
if top&Ecomplit == 0 && n.Diag == 0 { if top&Ecomplit == 0 && n.Diag == 0 {
t.Broke = 1 t.Broke = true
n.Diag = 1 n.Diag = 1
Yyerror("use of [...] array outside of array literal") Yyerror("use of [...] array outside of array literal")
} }
...@@ -430,7 +430,7 @@ OpSwitch: ...@@ -430,7 +430,7 @@ OpSwitch:
ok |= Etype ok |= Etype
n.Op = OTYPE n.Op = OTYPE
n.Type = tostruct(n.List) n.Type = tostruct(n.List)
if n.Type == nil || n.Type.Broke != 0 { if n.Type == nil || n.Type.Broke {
n.Type = nil n.Type = nil
return return
} }
...@@ -1286,7 +1286,7 @@ OpSwitch: ...@@ -1286,7 +1286,7 @@ OpSwitch:
l = n.Left l = n.Left
if l.Op == OTYPE { if l.Op == OTYPE {
if n.Isddd || l.Type.Bound == -100 { if n.Isddd || l.Type.Bound == -100 {
if l.Type.Broke == 0 { if !l.Type.Broke {
Yyerror("invalid use of ... in type conversion to %v", l.Type) Yyerror("invalid use of ... in type conversion to %v", l.Type)
} }
n.Diag = 1 n.Diag = 1
...@@ -1753,7 +1753,7 @@ OpSwitch: ...@@ -1753,7 +1753,7 @@ OpSwitch:
var why string var why string
n.Op = uint8(convertop(t, n.Type, &why)) n.Op = uint8(convertop(t, n.Type, &why))
if (n.Op) == 0 { if (n.Op) == 0 {
if n.Diag == 0 && n.Type.Broke == 0 { if n.Diag == 0 && !n.Type.Broke {
Yyerror("cannot convert %v to type %v%s", Nconv(n.Left, obj.FmtLong), n.Type, why) Yyerror("cannot convert %v to type %v%s", Nconv(n.Left, obj.FmtLong), n.Type, why)
n.Diag = 1 n.Diag = 1
} }
...@@ -2307,7 +2307,7 @@ func checkdefergo(n *Node) { ...@@ -2307,7 +2307,7 @@ func checkdefergo(n *Node) {
// type is broken or missing, most likely a method call on a broken type // type is broken or missing, most likely a method call on a broken type
// we will warn about the broken type elsewhere. no need to emit a potentially confusing error // we will warn about the broken type elsewhere. no need to emit a potentially confusing error
if n.Left.Type == nil || n.Left.Type.Broke != 0 { if n.Left.Type == nil || n.Left.Type.Broke {
return return
} }
...@@ -2627,7 +2627,7 @@ func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList, ...@@ -2627,7 +2627,7 @@ func typecheckaste(op int, call *Node, isddd bool, tstruct *Type, nl *NodeList,
lno := int(lineno) lno := int(lineno)
if tstruct.Broke != 0 { if tstruct.Broke {
goto out goto out
} }
...@@ -3804,7 +3804,7 @@ func typecheckdef(n *Node) *Node { ...@@ -3804,7 +3804,7 @@ func typecheckdef(n *Node) *Node {
if n.Type.Etype == TFORW && nerrors > nerrors0 { if n.Type.Etype == TFORW && nerrors > nerrors0 {
// Something went wrong during type-checking, // Something went wrong during type-checking,
// but it was reported. Silence future errors. // but it was reported. Silence future errors.
n.Type.Broke = 1 n.Type.Broke = true
} }
if Curfn != nil { if Curfn != nil {
......
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