mirror of
https://github.com/golang/go
synced 2024-11-23 01:30:02 -07:00
b2fd76ab8d
Most of the test cases in the test directory use the new go:build syntax already. Convert the rest. In general, try to place the build constraint line below the test directive comment in more places. For #41184. For #60268. Change-Id: I11c41a0642a8a26dc2eda1406da908645bbc005b Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/536236 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
134 lines
2.0 KiB
Go
134 lines
2.0 KiB
Go
// errorcheck -0 -d=ssa/phiopt/debug=3
|
|
|
|
//go:build amd64 || s390x || arm64
|
|
|
|
// Copyright 2016 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 main
|
|
|
|
//go:noinline
|
|
func f0(a bool) bool {
|
|
x := false
|
|
if a {
|
|
x = true
|
|
} else {
|
|
x = false
|
|
}
|
|
return x // ERROR "converted OpPhi to Copy$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f1(a bool) bool {
|
|
x := false
|
|
if a {
|
|
x = false
|
|
} else {
|
|
x = true
|
|
}
|
|
return x // ERROR "converted OpPhi to Not$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f2(a, b int) bool {
|
|
x := true
|
|
if a == b {
|
|
x = false
|
|
}
|
|
return x // ERROR "converted OpPhi to Not$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f3(a, b int) bool {
|
|
x := false
|
|
if a == b {
|
|
x = true
|
|
}
|
|
return x // ERROR "converted OpPhi to Copy$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f4(a, b bool) bool {
|
|
return a || b // ERROR "converted OpPhi to OrB$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f5or(a int, b bool) bool {
|
|
var x bool
|
|
if a == 0 {
|
|
x = true
|
|
} else {
|
|
x = b
|
|
}
|
|
return x // ERROR "converted OpPhi to OrB$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f5and(a int, b bool) bool {
|
|
var x bool
|
|
if a == 0 {
|
|
x = b
|
|
} else {
|
|
x = false
|
|
}
|
|
return x // ERROR "converted OpPhi to AndB$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f6or(a int, b bool) bool {
|
|
x := b
|
|
if a == 0 {
|
|
// f6or has side effects so the OpPhi should not be converted.
|
|
x = f6or(a, b)
|
|
}
|
|
return x
|
|
}
|
|
|
|
//go:noinline
|
|
func f6and(a int, b bool) bool {
|
|
x := b
|
|
if a == 0 {
|
|
// f6and has side effects so the OpPhi should not be converted.
|
|
x = f6and(a, b)
|
|
}
|
|
return x
|
|
}
|
|
|
|
//go:noinline
|
|
func f7or(a bool, b bool) bool {
|
|
return a || b // ERROR "converted OpPhi to OrB$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f7and(a bool, b bool) bool {
|
|
return a && b // ERROR "converted OpPhi to AndB$"
|
|
}
|
|
|
|
//go:noinline
|
|
func f8(s string) (string, bool) {
|
|
neg := false
|
|
if s[0] == '-' { // ERROR "converted OpPhi to Copy$"
|
|
neg = true
|
|
s = s[1:]
|
|
}
|
|
return s, neg
|
|
}
|
|
|
|
var d int
|
|
|
|
//go:noinline
|
|
func f9(a, b int) bool {
|
|
c := false
|
|
if a < 0 { // ERROR "converted OpPhi to Copy$"
|
|
if b < 0 {
|
|
d = d + 1
|
|
}
|
|
c = true
|
|
}
|
|
return c
|
|
}
|
|
|
|
func main() {
|
|
}
|