Merge from trunk
[official-gcc.git] / gcc / testsuite / go.test / test / func8.go
blob13051802ecdcdae043aad275a7096b85297263bd
1 // run
3 // Copyright 2011 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 // Test evaluation order.
9 package main
11 var calledf int
13 func f() int {
14 calledf++
15 return 0
18 func g() int {
19 return calledf
22 var xy string
24 func x() bool {
25 for false {
26 } // no inlining
27 xy += "x"
28 return false
31 func y() string {
32 for false {
33 } // no inlining
34 xy += "y"
35 return "abc"
38 func main() {
39 if f() == g() {
40 panic("wrong f,g order")
43 if x() == (y() == "abc") {
44 panic("wrong compare")
46 if xy != "xy" {
47 panic("wrong x,y order")