]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove AllowsGoVersion checks in old typechecker
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 22 Mar 2022 18:20:11 +0000 (01:20 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 23 Mar 2022 19:31:36 +0000 (19:31 +0000)
types2 handles those checks instead.

The only exception is noder.checkEmbed, since when types2
have not known about "//go:embed" pragma yet.

Updates #51691

Change-Id: I74ded03536023fe838f23fa7421e04513f904f66
Reviewed-on: https://go-review.googlesource.com/c/go/+/394556
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/typecheck/expr.go
src/cmd/compile/internal/typecheck/func.go
src/cmd/compile/internal/typecheck/subr.go
src/cmd/compile/internal/types/size.go

index 11e5268feb2f1482201dc405c1028b03ae24ea97..e6adc05a658b5731d2f8bddb3cfb1ca4a31a24fd 100644 (file)
@@ -58,10 +58,6 @@ func tcShift(n, l, r ir.Node) (ir.Node, ir.Node, *types.Type) {
                base.Errorf("invalid operation: %v (shift count type %v, must be integer)", n, r.Type())
                return l, r, nil
        }
-       if t.IsSigned() && !types.AllowsGoVersion(curpkg(), 1, 13) {
-               base.ErrorfVers("go1.13", "invalid operation: %v (signed shift count type %v)", n, r.Type())
-               return l, r, nil
-       }
        t = l.Type()
        if t != nil && t.Kind() != types.TIDEAL && !t.IsInteger() {
                base.Errorf("invalid operation: %v (shift of type %v)", n, t)
index 298af2aeeb7ccd92100e81c82a5c6b81bd4d703c..6bfa7e6d83911eaa2fa684c5cc36b35087dee5a1 100644 (file)
@@ -903,12 +903,6 @@ func tcRecoverFP(n *ir.CallExpr) ir.Node {
 
 // tcUnsafeAdd typechecks an OUNSAFEADD node.
 func tcUnsafeAdd(n *ir.BinaryExpr) *ir.BinaryExpr {
-       if !types.AllowsGoVersion(curpkg(), 1, 17) {
-               base.ErrorfVers("go1.17", "unsafe.Add")
-               n.SetType(nil)
-               return n
-       }
-
        n.X = AssignConv(Expr(n.X), types.Types[types.TUNSAFEPTR], "argument to unsafe.Add")
        n.Y = DefaultLit(Expr(n.Y), types.Types[types.TINT])
        if n.X.Type() == nil || n.Y.Type() == nil {
@@ -925,12 +919,6 @@ func tcUnsafeAdd(n *ir.BinaryExpr) *ir.BinaryExpr {
 
 // tcUnsafeSlice typechecks an OUNSAFESLICE node.
 func tcUnsafeSlice(n *ir.BinaryExpr) *ir.BinaryExpr {
-       if !types.AllowsGoVersion(curpkg(), 1, 17) {
-               base.ErrorfVers("go1.17", "unsafe.Slice")
-               n.SetType(nil)
-               return n
-       }
-
        n.X = Expr(n.X)
        n.Y = Expr(n.Y)
        if n.X.Type() == nil || n.Y.Type() == nil {
index c3759e3e7b4850dc210a73e1b607b0be7f3c738a..4dd95475f0567a7b43944f43faa0c3a657d9ed1d 100644 (file)
@@ -585,9 +585,6 @@ func Convertop(srcConstant bool, src, dst *types.Type) (ir.Op, string) {
        // They must have same element type.
        if src.IsSlice() && dst.IsPtr() && dst.Elem().IsArray() &&
                types.Identical(src.Elem(), dst.Elem().Elem()) {
-               if !types.AllowsGoVersion(curpkg(), 1, 17) {
-                       return ir.OXXX, ":\n\tconversion of slices to array pointers only supported as of -lang=go1.17"
-               }
                return ir.OSLICE2ARRPTR, ""
        }
 
index 6a3a1262f314cf26b5848fc1a735e69508084de7..fc9907b85fa75a25d3a7b99f57f40783506b977e 100644 (file)
@@ -80,7 +80,7 @@ func expandiface(t *Type) {
                switch prev := seen[m.Sym]; {
                case prev == nil:
                        seen[m.Sym] = m
-               case AllowsGoVersion(t.Pkg(), 1, 14) && !explicit && Identical(m.Type, prev.Type):
+               case !explicit && Identical(m.Type, prev.Type):
                        return
                default:
                        base.ErrorfAt(m.Pos, "duplicate method %s", m.Sym.Name)
@@ -127,17 +127,14 @@ func expandiface(t *Type) {
                }
 
                // In 1.18, embedded types can be anything. In Go 1.17, we disallow
-               // embedding anything other than interfaces.
+               // embedding anything other than interfaces. This requirement was caught
+               // by types2 already, so allow non-interface here.
                if !m.Type.IsInterface() {
-                       if AllowsGoVersion(t.Pkg(), 1, 18) {
-                               continue
-                       }
-                       base.FatalfAt(m.Pos, "interface contains embedded non-interface, non-union %v", m.Type)
+                       continue
                }
 
                // Embedded interface: duplicate all methods
-               // (including broken ones, if any) and add to t's
-               // method set.
+               // and add to t's method set.
                for _, t1 := range m.Type.AllMethods().Slice() {
                        f := NewField(m.Pos, t1.Sym, t1.Type)
                        addMethod(f, false)