OSDN Git Service

PR c++/51318
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / fixedbugs / bug221.go
1 // $G $D/$F.go && $L $F.$A && ./$A.out
2
3 // Copyright 2009 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 // function call arg reordering was picking out 1 call that
8 // didn't need to be in a temporary, but it was picking
9 // out the first call instead of the last call.
10 // http://code.google.com/p/go/issues/detail?id=370
11
12 package main
13
14 var gen = 'a'
15
16 func f(n int) string {
17         s := string(gen) + string(n+'A'-1)
18         gen++
19         return s
20 }
21
22 func g(x, y string) string {
23         return x + y
24 }
25
26 func main() {
27         s := f(1) + f(2)
28         if s != "aAbB" {
29                 println("BUG: bug221a: ", s)
30                 panic("fail")
31         }
32         s = g(f(3), f(4))
33         if s != "cCdD" {
34                 println("BUG: bug221b: ", s)
35                 panic("fail")
36         }
37         s = f(5) + f(6) + f(7) + f(8) + f(9)
38         if s != "eEfFgGhHiI" {
39                 println("BUG: bug221c: ", s)
40                 panic("fail")
41         }
42 }