summaryrefslogtreecommitdiff
path: root/test/recover.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2012-03-01 08:24:03 -0800
committerIan Lance Taylor <iant@golang.org>2012-03-01 08:24:03 -0800
commit118df525dd2d9bfb38736288211988ef142eaf3e (patch)
tree4b977c5e81c73399ae1e854915cebcfcb171c72e /test/recover.go
parentee666cc1a44accef9b24834ca8ae0c695df7df05 (diff)
downloadgo-118df525dd2d9bfb38736288211988ef142eaf3e.tar.gz
test: add test of calling recover in a varargs function
gccgo did not handle this correctly. R=golang-dev, rsc CC=golang-dev http://codereview.appspot.com/5714050
Diffstat (limited to 'test/recover.go')
-rw-r--r--test/recover.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/recover.go b/test/recover.go
index d32cfdf3d..eea655ec5 100644
--- a/test/recover.go
+++ b/test/recover.go
@@ -244,3 +244,30 @@ func test7() {
die()
}
}
+
+func varargs(s *int, a ...int) {
+ *s = 0
+ for _, v := range a {
+ *s += v
+ }
+ if recover() != nil {
+ *s += 100
+ }
+}
+
+func test8a() (r int) {
+ defer varargs(&r, 1, 2, 3)
+ panic(0)
+}
+
+func test8b() (r int) {
+ defer varargs(&r, 4, 5, 6)
+ return
+}
+
+func test8() {
+ if test8a() != 106 || test8b() != 15 {
+ println("wrong value")
+ die()
+ }
+}