Source file test/fixedbugs/issue26426.go

     1  //run
     2  
     3  // Copyright 2018 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  //go:noinline
    10  func f(p *int, v int, q1, q2 *int, r *bool) {
    11  	x := *r
    12  	if x {
    13  		*q1 = 1
    14  	}
    15  	*p = *p + v // This must clobber flags. Otherwise we keep x in a flags register.
    16  	if x {
    17  		*q2 = 1
    18  	}
    19  }
    20  
    21  func main() {
    22  	var p int
    23  	var q1, q2 int
    24  	var b bool
    25  	f(&p, 1, &q1, &q2, &b)
    26  	if q1 != 0 || q2 != 0 {
    27  		panic("bad")
    28  	}
    29  }
    30  

View as plain text