]> Cypherpunks.ru repositories - gostls13.git/blob - test/fixedbugs/issue26495.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / fixedbugs / issue26495.go
1 // run
2
3 // Copyright 2018 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 26495: gccgo produces incorrect order of evaluation
8 // for expressions involving &&, || subexpressions.
9
10 package main
11
12 var i int
13
14 func checkorder(order int) {
15         if i != order {
16                 panic("FAIL: wrong evaluation order")
17         }
18         i++
19 }
20
21 func A() bool              { checkorder(1); return true }
22 func B() bool              { checkorder(2); return true }
23 func C() bool              { checkorder(5); return false }
24 func D() bool              { panic("FAIL: D should not be called") }
25 func E() int               { checkorder(3); return 0 }
26 func F() int               { checkorder(0); return 0 }
27 func G(bool) int           { checkorder(9); return 0 }
28 func H(int, bool, int) int { checkorder(7); return 0 }
29 func I(int) bool           { checkorder(8); return true }
30 func J() int               { checkorder(4); return 0 }
31 func K() int               { checkorder(6); return 0 }
32 func L() int               { checkorder(10); return 0 }
33
34 func main() {
35         _ = F() + G(A() && B() && I(E()+H(J(), C() && D(), K()))) + L()
36 }