cmd/compile: remove AllowsGoVersion checks in old typechecker

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>
This commit is contained in:
Cuong Manh Le 2022-03-23 01:20:11 +07:00
parent 489e4882ef
commit 810868c9f6
4 changed files with 5 additions and 27 deletions

View 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)

View 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 {

View 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, ""
}

View 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)