Source file test/prove_constant_folding.go

     1  // errorcheck -0 -d=ssa/prove/debug=2
     2  
     3  //go:build amd64
     4  
     5  // Copyright 2022 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  
     9  package main
    10  
    11  func f0i(x int) int {
    12    if x == 20 {
    13      return x // ERROR "Proved.+is constant 20$"
    14    }
    15  
    16    if (x + 20) == 20 {
    17      return x + 5 // ERROR "Proved.+is constant 0$"
    18    }
    19  
    20    return x / 2
    21  }
    22  
    23  func f0u(x uint) uint {
    24    if x == 20 {
    25      return x // ERROR "Proved.+is constant 20$"
    26    }
    27  
    28    if (x + 20) == 20 {
    29      return x + 5 // ERROR "Proved.+is constant 0$"
    30    }
    31  
    32    return x / 2
    33  }
    34  

View as plain text