commit 4447dcf380a08f74bf5b91fd84d7013cbbb34ee8 Author: Aldy Hernandez Date: Wed Mar 20 16:47:02 2013 -0500 Add new test to verify that the array index, limit, and stride are only evaluated once. diff --git a/gcc/testsuite/gcc.dg/cilk-plus/array_notation/execute/side-effects-1.c b/gcc/testsuite/gcc.dg/cilk-plus/array_notation/execute/side-effects-1.c new file mode 100644 index 0000000..1845862 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/array_notation/execute/side-effects-1.c @@ -0,0 +1,23 @@ +/* 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) + abort(); + + return 0; +}