1// run
2
3// Copyright 2012 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// Issue 4518. In some circumstances "return F(...)"
8// where F has multiple returns is miscompiled by 6g due to
9// bold assumptions in componentgen.
10
11package main
12
13func DontInline() {}
14
15func F(e interface{}) (int, int) {
16	DontInline()
17	return 3, 7
18}
19
20func G() (int, int) {
21	DontInline()
22	return 3, 7
23}
24
25func bogus1(d interface{}) (int, int) {
26	switch {
27	default:
28		return F(d)
29	}
30	return 0, 0
31}
32
33func bogus2() (int, int) {
34	switch {
35	default:
36		return F(3)
37	}
38	return 0, 0
39}
40
41func bogus3(d interface{}) (int, int) {
42	switch {
43	default:
44		return G()
45	}
46	return 0, 0
47}
48
49func bogus4() (int, int) {
50	switch {
51	default:
52		return G()
53	}
54	return 0, 0
55}
56
57func check(a, b int) {
58	if a != 3 || b != 7 {
59		println(a, b)
60		panic("a != 3 || b != 7")
61	}
62}
63
64func main() {
65	check(bogus1(42))
66	check(bogus2())
67}
68