Merge from trunk
[official-gcc.git] / gcc / testsuite / go.test / test / fixedbugs / issue5856.go
blob35cadf8c9e74efd968e84f642ab4148a7128ea84
1 // run
3 // Copyright 2013 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.
7 package main
9 import (
10 "fmt"
11 "os"
12 "runtime"
13 "strings"
16 func main() {
17 f()
18 panic("deferred function not run")
21 var x = 1
23 func f() {
24 if x == 0 {
25 return
27 defer g()
28 panic("panic")
31 func g() {
32 _, file, line, _ := runtime.Caller(2)
33 if !strings.HasSuffix(file, "issue5856.go") || line != 28 {
34 fmt.Printf("BUG: defer called from %s:%d, want issue5856.go:28\n", file, line)
35 os.Exit(1)
37 os.Exit(0)