1// errorcheck -0 -d=ssa/phiopt/debug=3 2 3//go:build amd64 || s390x || arm64 4 5// Copyright 2016 The Go Authors. All rights reserved. 6// Use of this source code is governed by a BSD-style 7// license that can be found in the LICENSE file. 8 9package main 10 11//go:noinline 12func f0(a bool) bool { 13 x := false 14 if a { 15 x = true 16 } else { 17 x = false 18 } 19 return x // ERROR "converted OpPhi to Copy$" 20} 21 22//go:noinline 23func f1(a bool) bool { 24 x := false 25 if a { 26 x = false 27 } else { 28 x = true 29 } 30 return x // ERROR "converted OpPhi to Not$" 31} 32 33//go:noinline 34func f2(a, b int) bool { 35 x := true 36 if a == b { 37 x = false 38 } 39 return x // ERROR "converted OpPhi to Not$" 40} 41 42//go:noinline 43func f3(a, b int) bool { 44 x := false 45 if a == b { 46 x = true 47 } 48 return x // ERROR "converted OpPhi to Copy$" 49} 50 51//go:noinline 52func f4(a, b bool) bool { 53 return a || b // ERROR "converted OpPhi to OrB$" 54} 55 56//go:noinline 57func f5or(a int, b bool) bool { 58 var x bool 59 if a == 0 { 60 x = true 61 } else { 62 x = b 63 } 64 return x // ERROR "converted OpPhi to OrB$" 65} 66 67//go:noinline 68func f5and(a int, b bool) bool { 69 var x bool 70 if a == 0 { 71 x = b 72 } else { 73 x = false 74 } 75 return x // ERROR "converted OpPhi to AndB$" 76} 77 78//go:noinline 79func f6or(a int, b bool) bool { 80 x := b 81 if a == 0 { 82 // f6or has side effects so the OpPhi should not be converted. 83 x = f6or(a, b) 84 } 85 return x 86} 87 88//go:noinline 89func f6and(a int, b bool) bool { 90 x := b 91 if a == 0 { 92 // f6and has side effects so the OpPhi should not be converted. 93 x = f6and(a, b) 94 } 95 return x 96} 97 98//go:noinline 99func f7or(a bool, b bool) bool { 100 return a || b // ERROR "converted OpPhi to OrB$" 101} 102 103//go:noinline 104func f7and(a bool, b bool) bool { 105 return a && b // ERROR "converted OpPhi to AndB$" 106} 107 108//go:noinline 109func f8(s string) (string, bool) { 110 neg := false 111 if s[0] == '-' { // ERROR "converted OpPhi to Copy$" 112 neg = true 113 s = s[1:] 114 } 115 return s, neg 116} 117 118var d int 119 120//go:noinline 121func f9(a, b int) bool { 122 c := false 123 if a < 0 { // ERROR "converted OpPhi to Copy$" 124 if b < 0 { 125 d = d + 1 126 } 127 c = true 128 } 129 return c 130} 131 132func main() { 133} 134