Debian Codegraph @

test/abi/defer_recover_results.go

raw symbols SCIP
1 // run
2
3 // Copyright 2021 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 // Test that when a function recovers from a panic, it
8 // returns the correct results to the caller (in particular,
9 // setting the result registers correctly).
10
11 package main
12
13 type S struct {
14 x uint8
15 y uint16
16 z uint32
17 w float64
18 }
19
20 var a0, b0, c0, d0 = 10, "hello", S{1, 2, 3, 4}, [2]int{111, 222}
21
22 //go:noinline
23 //go:registerparams
24 func F() (a int, b string, _ int, c S, d [2]int) {
25 a, b, c, d = a0, b0, c0, d0
26 defer func() { recover() }()
27 panic("XXX")
28 return
29 }
30
31 func main() {
32 a1, b1, zero, c1, d1 := F()
33 if a1 != a0 || b1 != b0 || c1 != c0 || d1 != d0 || zero != 0 { // unnamed result gets zero value
34 panic("FAIL")
35 }
36 }