Commit 1484270a authored by Yury Smolsky's avatar Yury Smolsky Committed by Brad Fitzpatrick

test: restore tests for the reject unsafe code option

Tests in test/safe were neglected after moving to the run.go
framework. This change restores them.

These tests are skipped for go/types via -+ option.

Fixes #25668

Change-Id: I8fe26574a76fa7afa8664c467d7c2e6334f1bba9
Reviewed-on: https://go-review.googlesource.com/124660Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 43704759
// $G $D/pkg.go && pack grc pkg.a pkg.$A 2> /dev/null && rm pkg.$A && errchk $G -I . -u $D/main.go
// rm -f pkg.a
// Copyright 2012 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 ignored
// $G $D/pkg.go && pack grcS pkg.a pkg.$A 2> /dev/null && rm pkg.$A && $G -I . -u $D/main.go
// rm -f pkg.a
// Copyright 2012 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 ignored
// true // errorcheck -u -+
// Copyright 2012 The Go Authors. All rights reserved. // Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Check that we cannot import a package that uses "unsafe" internally
// when -u is supplied.
package main package main
// can't use local path with -u, use -I. instead import "syscall" // ERROR "import unsafe package"
import "pkg" // ERROR "import unsafe package"
func main() { func main() {
print(pkg.Float32bits(1.0)) print(syscall.Environ())
} }
// true // errorcheck -u -+
// Copyright 2012 The Go Authors. All rights reserved. // Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// a package that uses unsafe on the inside but not in it's api // Check that we cannot import the "unsafe" package when -u is supplied.
package pkg package a
import "unsafe" import "unsafe" // ERROR "import package unsafe"
// this should be inlinable
func Float32bits(f float32) uint32 { func Float32bits(f float32) uint32 {
return *(*uint32)(unsafe.Pointer(&f)) return *(*uint32)(unsafe.Pointer(&f))
} }
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