]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove t.Broke() deadcode paths
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 18 Mar 2022 17:23:33 +0000 (00:23 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 18 Mar 2022 23:20:41 +0000 (23:20 +0000)
CL 392918 changed t.Broke() to always return false, we can now get rid
of all its deadcode paths.

Updates #51691

Change-Id: I0a2a13def07364e780e4785621690452948e219a
Reviewed-on: https://go-review.googlesource.com/c/go/+/393914
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/typecheck/const.go
src/cmd/compile/internal/typecheck/expr.go
src/cmd/compile/internal/typecheck/func.go
src/cmd/compile/internal/typecheck/stmt.go
src/cmd/compile/internal/typecheck/subr.go
src/cmd/compile/internal/typecheck/typecheck.go
src/cmd/compile/internal/types/alg.go
src/cmd/compile/internal/types/identity.go
src/cmd/compile/internal/types/size.go
src/cmd/compile/internal/types/type.go

index 3be3b8059f7861f39c6be581e5891a1c3bfe2375..311944361a0260f8ddb23613369a1e100c295943 100644 (file)
@@ -199,17 +199,16 @@ func convlit1(n ir.Node, t *types.Type, explicit bool, context func() string) ir
        }
 
        if !n.Diag() {
-               if !t.Broke() {
-                       if explicit {
-                               base.Errorf("cannot convert %L to type %v", n, t)
-                       } else if context != nil {
-                               base.Errorf("cannot use %L as type %v in %s", n, t, context())
-                       } else {
-                               base.Errorf("cannot use %L as type %v", n, t)
-                       }
+               if explicit {
+                       base.Errorf("cannot convert %L to type %v", n, t)
+               } else if context != nil {
+                       base.Errorf("cannot use %L as type %v in %s", n, t, context())
+               } else {
+                       base.Errorf("cannot use %L as type %v", n, t)
                }
                n.SetDiag(true)
        }
+
        n.SetType(nil)
        return n
 }
index e2b95b27c6a93621f1c2d87e49e02db5e73f0cee..7920a9a46c0b69b06629c3b60777f9b7dfbe043a 100644 (file)
@@ -413,7 +413,7 @@ func tcConv(n *ir.ConvExpr) ir.Node {
        }
        op, why := Convertop(n.X.Op() == ir.OLITERAL, t, n.Type())
        if op == ir.OXXX {
-               if !n.Diag() && !n.Type().Broke() && !n.X.Diag() {
+               if !n.Diag() && !n.X.Diag() {
                        base.Errorf("cannot convert %L to type %v%s", n.X, n.Type(), why)
                        n.SetDiag(true)
                }
index 7ab41e63fea957dfab26b6f7a0251425d0dc22b2..0a0b5f5e780d2a1e0c6c41c81f54cb8d41d4a531 100644 (file)
@@ -360,9 +360,7 @@ func tcCall(n *ir.CallExpr, top int) ir.Node {
        l = n.X
        if l.Op() == ir.OTYPE {
                if n.IsDDD {
-                       if !l.Type().Broke() {
-                               base.Errorf("invalid use of ... in type conversion to %v", l.Type())
-                       }
+                       base.Errorf("invalid use of ... in type conversion to %v", l.Type())
                        n.SetDiag(true)
                }
 
index 930d7ce627c9b6fbd102e5935e3539a1bb2d8684..393481d4a9ed4bbd27ca202a1ed7acb6ab4442df 100644 (file)
@@ -309,7 +309,7 @@ func tcGoDefer(n *ir.GoDeferStmt) {
 
        // 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
-       if n.Call.Type() == nil || n.Call.Type().Broke() {
+       if n.Call.Type() == nil {
                return
        }
 
index 311c5858b2c761bedec2dd9db61c8fe3f6991bde..0b46037a3b6a66385ab49d082d28ed53dd545575 100644 (file)
@@ -291,7 +291,7 @@ var dotlist = make([]dlist, 10)
 
 // Convert node n for assignment to type t.
 func assignconvfn(n ir.Node, t *types.Type, context func() string) ir.Node {
-       if n == nil || n.Type() == nil || n.Type().Broke() {
+       if n == nil || n.Type() == nil {
                return n
        }
 
@@ -396,11 +396,6 @@ func Assignop1(src, dst *types.Type) (ir.Op, string) {
                        return ir.OCONVIFACE, ""
                }
 
-               // we'll have complained about this method anyway, suppress spurious messages.
-               if have != nil && have.Sym == missing.Sym && (have.Type.Broke() || missing.Type.Broke()) {
-                       return ir.OCONVIFACE, ""
-               }
-
                var why string
                if isptrto(src, types.TINTER) {
                        why = fmt.Sprintf(":\n\t%v is pointer to interface, not interface", src)
index d94a262a7f8e7c35ef473ce38d8fd59e486f6054..6860c71a7213583c150f75e1d5ece99b075ec7c2 100644 (file)
@@ -413,10 +413,8 @@ func typecheck(n ir.Node, top int) (res ir.Node) {
                }
 
        case top&ctxType == 0 && n.Op() == ir.OTYPE && t != nil:
-               if !n.Type().Broke() {
-                       base.Errorf("type %v is not an expression", n.Type())
-                       n.SetDiag(true)
-               }
+               base.Errorf("type %v is not an expression", n.Type())
+               n.SetDiag(true)
 
        case top&(ctxStmt|ctxExpr) == ctxStmt && !isStmt && t != nil:
                if !n.Diag() {
@@ -1297,10 +1295,6 @@ func typecheckaste(op ir.Op, call ir.Node, isddd bool, tstruct *types.Type, nl i
        lno := base.Pos
        defer func() { base.Pos = lno }()
 
-       if tstruct.Broke() {
-               return
-       }
-
        var n ir.Node
        if len(nl) == 1 {
                n = nl[0]
index f5675c66b4f4ec679e039fc3c26037fe652cad87..c1f93fc1c3b5d9cf59694db0691793abe8b1019c 100644 (file)
@@ -40,9 +40,6 @@ const (
 // If it returns ANOEQ, it also returns the component type of t that
 // makes it incomparable.
 func AlgType(t *Type) (AlgKind, *Type) {
-       if t.Broke() {
-               return AMEM, nil
-       }
        if t.Noalg() {
                return ANOEQ, t
        }
index 60a0f2e7c581a9bbc35165d1b19166dca1690a3f..17555d099bdd6840f299ba1d0886fdddb1d95323 100644 (file)
@@ -39,7 +39,7 @@ func identical(t1, t2 *Type, flags int, assumedEqual map[typePair]struct{}) bool
        if t1 == t2 {
                return true
        }
-       if t1 == nil || t2 == nil || t1.kind != t2.kind || t1.Broke() || t2.Broke() {
+       if t1 == nil || t2 == nil || t1.kind != t2.kind {
                return false
        }
        if t1.sym != nil || t2.sym != nil {
index fb6accdc642f74acf21f57ea663729db2b536428..1ea0516b04a818f2abfaa8d4d4cc0dd34000de2f 100644 (file)
@@ -303,10 +303,6 @@ func findTypeLoop(t *Type, path *[]*Type) bool {
 }
 
 func reportTypeLoop(t *Type) {
-       if t.Broke() {
-               return
-       }
-
        var l []*Type
        if !findTypeLoop(t, &l) {
                base.Fatalf("failed to find type loop for: %v", t)
@@ -362,20 +358,10 @@ func CalcSize(t *Type) {
        }
 
        if CalcSizeDisabled {
-               if t.Broke() {
-                       // break infinite recursion from Fatal call below
-                       return
-               }
                t.SetBroke(true)
                base.Fatalf("width not calculated: %v", t)
        }
 
-       // break infinite recursion if the broken recursive type
-       // is referenced again
-       if t.Broke() && t.width == 0 {
-               return
-       }
-
        // defer CheckSize calls until after we're done
        DeferCheckSize()
 
index 51ce614bd8a70ed2d8240e2dc1509532a9e5314a..c45338be35e852d7d8d21abfa3cb4a605c477e37 100644 (file)
@@ -221,7 +221,6 @@ const (
 )
 
 func (t *Type) NotInHeap() bool  { return t.flags&typeNotInHeap != 0 }
-func (t *Type) Broke() bool      { return false }
 func (t *Type) Noalg() bool      { return t.flags&typeNoalg != 0 }
 func (t *Type) Deferwidth() bool { return t.flags&typeDeferwidth != 0 }
 func (t *Type) Recur() bool      { return t.flags&typeRecur != 0 }
@@ -1785,9 +1784,6 @@ func (t *Type) SetUnderlying(underlying *Type) {
        if underlying.NotInHeap() {
                t.SetNotInHeap(true)
        }
-       if underlying.Broke() {
-               t.SetBroke(true)
-       }
        if underlying.HasTParam() {
                t.SetHasTParam(true)
        }
@@ -1970,9 +1966,6 @@ func NewSignature(pkg *Pkg, recv *Field, tparams, params, results []*Field) *Typ
        funargs := func(fields []*Field, funarg Funarg) *Type {
                s := NewStruct(NoPkg, fields)
                s.StructType().Funarg = funarg
-               if s.Broke() {
-                       t.SetBroke(true)
-               }
                return s
        }
 
@@ -2082,10 +2075,6 @@ func IsReflexive(t *Type) bool {
 // Can this type be stored directly in an interface word?
 // Yes, if the representation is a single pointer.
 func IsDirectIface(t *Type) bool {
-       if t.Broke() {
-               return false
-       }
-
        switch t.Kind() {
        case TPTR:
                // Pointers to notinheap types must be stored indirectly. See issue 42076.