aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/eval-order10.C
blob: 02719b7e81010b465f3e9f89fa9cf9f2cb3cd510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// PR c++/82959
// { dg-do run }
// { dg-additional-options -fstrong-eval-order }

struct A {};

void operator && (const A x, const A) {}
void operator || (const A x, const A) {}
void operator , (const A x, const A) {}

int i;

A f () { if (i != 0) __builtin_abort (); i = 1; return A (); }
A g () { if (i != 1) __builtin_abort (); i = 2; return A (); }

int
main ()
{
  f () && g ();
  if (i != 2) __builtin_abort ();
  i = 0;
  f () || g ();
  if (i != 2) __builtin_abort ();
  i = 0;
  f (), g ();
  if (i != 2) __builtin_abort ();
}