aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/side-effects-1.c
blob: 8b0034e727b808ffdce16084925e24e3a33e71a2 (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
/* { dg-do run } */
/* { dg-options "-fcilkplus" } */

/* Test that the array index, limit, and stride are evaluated only
   once.  */

int array[1000];

int func1_times = 0;
int func2_times = 0;
int func3_times = 0;
int func1() { func1_times++; return 0; }
int func2() { func2_times++; return 0; }
int func3() { func3_times++; return 0; }

int main()
{
  array[func1() + 11 : func2() + 22 : func3() + 33] = 666;

  if (func1_times != 1
      || func2_times != 1
      || func3_times != 1)
    return 1;

  return 0;
}