codekingpro/portable-devtools
114k
1// errorcheck -0 -d=ssa/phiopt/debug=32 3//go:build amd64 || s390x || arm644 5// Copyright 2016 The Go Authors. All rights reserved.6// Use of this source code is governed by a BSD-style7// license that can be found in the LICENSE file.8 9package main10 11//go:noinline12func f0(a bool) bool {13 x := false14 if a {15 x = true16 } else {17 x = false18 }19 return x // ERROR "converted OpPhi to Copy$"20}21 22//go:noinline23func f1(a bool) bool {24 x := false25 if a {26 x = false27 } else {28 x = true29 }30 return x // ERROR "converted OpPhi to Not$"31}32 33//go:noinline34func f2(a, b int) bool {35 x := true36 if a == b {37 x = false38 }39 return x // ERROR "converted OpPhi to Not$"40}41 42//go:noinline43func f3(a, b int) bool {44 x := false45 if a == b {46 x = true47 }48 return x // ERROR "converted OpPhi to Copy$"49}50 51//go:noinline52func f4(a, b bool) bool {53 return a || b // ERROR "converted OpPhi to OrB$"54}55 56//go:noinline57func f5or(a int, b bool) bool {58 var x bool59 if a == 0 {60 x = true61 } else {62 x = b63 }64 return x // ERROR "converted OpPhi to OrB$"65}66 67//go:noinline68func f5and(a int, b bool) bool {69 var x bool70 if a == 0 {71 x = b72 } else {73 x = false74 }75 return x // ERROR "converted OpPhi to AndB$"76}77 78//go:noinline79func f6or(a int, b bool) bool {80 x := b81 if a == 0 {82 // f6or has side effects so the OpPhi should not be converted.83 x = f6or(a, b)84 }85 return x86}87 88//go:noinline89func f6and(a int, b bool) bool {90 x := b91 if a == 0 {92 // f6and has side effects so the OpPhi should not be converted.93 x = f6and(a, b)94 }95 return x96}97 98//go:noinline99func f7or(a bool, b bool) bool {100 return a || b // ERROR "converted OpPhi to OrB$"101}102 103//go:noinline104func f7and(a bool, b bool) bool {105 return a && b // ERROR "converted OpPhi to AndB$"106}107 108//go:noinline109func f8(s string) (string, bool) {110 neg := false111 if s[0] == '-' { // ERROR "converted OpPhi to Copy$"112 neg = true113 s = s[1:]114 }115 return s, neg116}117 118var d int119 120//go:noinline121func f9(a, b int) bool {122 c := false123 if a < 0 { // ERROR "converted OpPhi to Copy$"124 if b < 0 {125 d = d + 1126 }127 c = true128 }129 return c130}131 132//go:noinline133func f10and(a bool, b bool) bool {134 var x bool135 if a {136 x = b137 } else {138 x = a139 }140 return x // ERROR "converted OpPhi to AndB$"141}142 143//go:noinline144func f11or(a bool, b bool) bool {145 var x bool146 if a {147 x = a148 } else {149 x = b150 }151 return x // ERROR "converted OpPhi to OrB$"152}153 154func main() {155}156 