From b14a6643dc47104689facd938a0fb254996ddf85 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 1 Mar 2012 08:24:03 -0800 Subject: [PATCH] test: add test of calling recover in a varargs function gccgo did not handle this correctly. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5714050 --- test/recover.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/recover.go b/test/recover.go index d32cfdf3d14..eea655ec578 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() + } +}