Source file test/abi/f_ret_z_not.go

     1  // run
     2  
     3  //go:build !wasm
     4  // +build !wasm
     5  
     6  // Copyright 2021 The Go Authors. All rights reserved.
     7  // Use of this source code is governed by a BSD-style
     8  // license that can be found in the LICENSE file.
     9  
    10  // wasm is excluded because the compiler chatter about register abi pragma ends up
    11  // on stdout, and causes the expected output to not match.
    12  
    13  package main
    14  
    15  import "fmt"
    16  
    17  type Z struct {
    18  }
    19  
    20  type NZ struct {
    21  	x, y int
    22  }
    23  
    24  //go:noinline
    25  func f(x, y int) (Z, NZ, Z) {
    26  	var z Z
    27  	return z, NZ{x, y}, z
    28  }
    29  
    30  //go:noinline
    31  func g() (Z, NZ, Z) {
    32  	a, b, c := f(3, 4)
    33  	return c, b, a
    34  }
    35  
    36  func main() {
    37  	_, b, _ := g()
    38  	fmt.Println(b.x + b.y)
    39  }
    40  

View as plain text