]> Cypherpunks.ru repositories - gostls13.git/blob - test/abi/fibish.go
b72f1322deb11ca26a5f460b7c98f50098cb30fd
[gostls13.git] / test / abi / fibish.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 package main
11
12 import "fmt"
13
14 // Test that register results are correctly returned (and passed)
15
16 //go:registerparams
17 //go:noinline
18 func f(x int) (int, int) {
19
20         if x < 3 {
21                 return 0, x
22         }
23
24         a, b := f(x - 2)
25         c, d := f(x - 1)
26         return a + d, b + c
27 }
28
29 func main() {
30         x := 40
31         a, b := f(x)
32         fmt.Printf("f(%d)=%d,%d\n", x, a, b)
33 }