mirror of
https://github.com/golang/go
synced 2024-11-27 00:41:31 -07:00
962d5c997a
This CL updates cmd/compile (including types2) and go/types to report errors about using unsafe.Add and unsafe.Slice when language compatibility is set to Go 1.16 or older. Fixes #46525. Change-Id: I1bfe025a672d9f4b929f443064ad1effd38d0363 Reviewed-on: https://go-review.googlesource.com/c/go/+/324369 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com>
15 lines
409 B
Go
15 lines
409 B
Go
// errorcheck -lang=go1.16
|
|
|
|
// Copyright 2021 The Go Authors. All rights reserved. Use of this
|
|
// source code is governed by a BSD-style license that can be found in
|
|
// the LICENSE file.
|
|
|
|
package p
|
|
|
|
import "unsafe"
|
|
|
|
func main() {
|
|
_ = unsafe.Add(unsafe.Pointer(nil), 0) // ERROR "unsafe.Add requires go1.17 or later"
|
|
_ = unsafe.Slice(new(byte), 1) // ERROR "unsafe.Slice requires go1.17 or later"
|
|
}
|