blob: 5c3a1782be149e12401a364b92278308a5e4b9ed [file] [log] [blame]
Rémy Oudompheng81b46f12012-12-17 22:29:43 +01001// 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
Todd Neale3e01222015-10-29 21:45:19 -050013//go:noinline
Rémy Oudompheng81b46f12012-12-17 22:29:43 +010014func F(e interface{}) (int, int) {
Rémy Oudompheng81b46f12012-12-17 22:29:43 +010015 return 3, 7
16}
17
Todd Neale3e01222015-10-29 21:45:19 -050018//go:noinline
Rémy Oudompheng81b46f12012-12-17 22:29:43 +010019func G() (int, int) {
Rémy Oudompheng81b46f12012-12-17 22:29:43 +010020 return 3, 7
21}
22
23func bogus1(d interface{}) (int, int) {
24 switch {
25 default:
26 return F(d)
27 }
28 return 0, 0
29}
30
31func bogus2() (int, int) {
32 switch {
33 default:
34 return F(3)
35 }
36 return 0, 0
37}
38
39func bogus3(d interface{}) (int, int) {
40 switch {
41 default:
42 return G()
43 }
44 return 0, 0
45}
46
47func bogus4() (int, int) {
48 switch {
49 default:
50 return G()
51 }
52 return 0, 0
53}
54
55func check(a, b int) {
56 if a != 3 || b != 7 {
57 println(a, b)
58 panic("a != 3 || b != 7")
59 }
60}
61
62func main() {
63 check(bogus1(42))
64 check(bogus2())
65}