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
10package main
11
12var i int
13
14func checkorder(order int) {
15	if i != order {
16		panic("FAIL: wrong evaluation order")
17	}
18	i++
19}
20
21func A() bool              { checkorder(1); return true }
22func B() bool              { checkorder(2); return true }
23func C() bool              { checkorder(5); return false }
24func D() bool              { panic("FAIL: D should not be called") }
25func E() int               { checkorder(3); return 0 }
26func F() int               { checkorder(0); return 0 }
27func G(bool) int           { checkorder(9); return 0 }
28func H(int, bool, int) int { checkorder(7); return 0 }
29func I(int) bool           { checkorder(8); return true }
30func J() int               { checkorder(4); return 0 }
31func K() int               { checkorder(6); return 0 }
32func L() int               { checkorder(10); return 0 }
33
34func main() {
35	_ = F() + G(A() && B() && I(E()+H(J(), C() && D(), K()))) + L()
36}
37