diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN')
45 files changed, 2105 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c new file mode 100644 index 000000000..4bf85b5ca --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/an-if.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#if HAVE_IO +#include <stdio.h> +#endif +#include <assert.h> + +const int n = 8; + +float x[8], y[8], z[8]; + +int main() { + int i = 0; + float x_sum =0; + for(i=1; i<=5; i+=4 ) { + x[0:n] = 3; + y[0:n] = i; + z[0:n] = 0; +#if HAVE_IO + printf("x\ty\tz\n"); + for( size_t k=0; k<n; ++k ) { + printf("%g\t%g\t%g\n",x[k],y[k],z[k]); + } + x_sum = __sec_reduce_add (x[0:n]); + printf("sec_reduce_add (x[0:n]) = %6.3f\n", x_sum); +#endif + assert( __sec_reduce_add(x[0:n])==3*n ); + assert( __sec_reduce_add(y[0:n])==i*n ); + assert( __sec_reduce_add(z[0:n])==0 ); + + if (x[0:n] >= y[0:n]) { + z[0:n] = x[0:n] - y[0:n]; + } else { + z[0:n] = x[0:n] + y[0:n]; + } +#if HAVE_IO + printf("x\ty\tz\n"); + for( size_t k=0; k<n; ++k ) { + printf("%g\t%g\t%g\n",x[k],y[k],z[k]); + } +#endif + assert( __sec_reduce_add(x[0:n])==3*n ); + assert( __sec_reduce_add(y[0:n])==i*n ); + assert( __sec_reduce_add(z[0:n])==(3>=i?3-i:3+i)*n ); + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test1.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test1.c new file mode 100644 index 000000000..282a55d6f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test1.c @@ -0,0 +1,84 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#include <stdlib.h> + +int main2 (char **argv); + +int main(void) +{ + int x = 0; + const char *array[] = {"a.out", "5"}; + x = main2 ((char **)array); + return x; +} + +int main2 (char **argv) +{ + int array[10], ii = 0, x = 2, z= 0 , y = 0 ; + for (ii = 0; ii < 10; ii++) + array[ii] = 10; + + array[0:10:1] = 15; + + for (ii = 0; ii < 10; ii++) + if (array[ii] != 15) + return 5; + array[0:5:2] = 20; + + for (ii = 0; ii < 10; ii += 2) + if (array[ii] != 20) + return 4; + + + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + + array[x:5:z] = 50; + + for (ii = x; ii < 10; ii += z) + if (array[ii] != 50) + return 3; + + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + y = 10-atoi(argv[1]); + + array[x:y:z] = 505; + for (ii = x; ii < 10; ii += z) + if (array[ii] != 505) + return 4; + + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + y = 10-atoi(argv[1]); + + array[x:y:((10-atoi(argv[1]))/atoi(argv[1]))] = 25; + + for (ii = x; ii < 10; ii += z) + if (array[ii] != 25) + return 5; + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + y = 10-atoi(argv[1]); + + array[atoi(argv[1]):(10-atoi(argv[1])):((10-atoi(argv[1]))/atoi(argv[1]))] = + 1400; + for (ii = x; ii < 10; ii += z) + if (array[ii] != 1400) + return 6; + + + array[atoi("5"):5:1] = 5555; + + for (ii = atoi ("5"); ii < 10; ii++) + if (array[ii] != 5555) + return 7; + + + array[atoi("5"):atoi("5"):atoi("1")] = 9999; + for (ii = atoi ("5"); ii < (atoi ("5") + atoi ("5")); ii += atoi ("1")) + if (array[ii] != 9999) + return 8; + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test2.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test2.c new file mode 100644 index 000000000..60f2de283 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test2.c @@ -0,0 +1,128 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#include <stdlib.h> +int main2 (char **argv); +int main(void) +{ + int x = 0; + const char *array[] = {"a.out", "5"}; + x = main2 ((char **)array); + return x; +} + + +int main2(char **argv) +{ + int array[10], array2[10], ii = 0, x = 2, z= 0 , y = 0 ; + + for (ii = 0; ii < 10; ii++) + { + array[ii] = 10; + array2[ii] = 5000000; + } + + array2[0:10:1] = array[0:10:1]; + + for (ii = 0; ii < 10; ii++) + if (array2[ii] != array[ii]) + return 1; + + for (ii = 0; ii < 10; ii++) + { + array[ii] = 10; + array2[ii] = 5000000; + } + + array2[0:5:2] = array[0:5:2]; + + for (ii = 0; ii < 10; ii += 2) + if (array[ii] != array2[ii]) + return 2; + + for (ii = 0; ii < 10; ii++) + { + array[ii] = 10; + array2[ii] = 5000000; + } + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + + array2[x:5:z] = array[x:5:z]; + + for (ii = x; ii < 5; ii += z) + if (array2[ii] != array[ii]) + return 3; + + for (ii = 0; ii < 10; ii++) + { + array[ii] = 500; + array2[ii] = 1000000; + } + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + y = 10-atoi(argv[1]); + + array2[x:y:z] = array[x:y:z]; + for (ii = x; ii < 10; ii = ii + z) + if (array2[ii] != array[ii]) + return 4; + + for (ii = 0; ii < 10; ii++) + { + array[ii] = 500; + array2[ii] = 1000000; + } + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + y = 10-atoi(argv[1]); + + array[x:y:((10-atoi(argv[1]))/atoi(argv[1]))] = + array2[x:y:((10-atoi(argv[1]))/atoi(argv[1]))]; + + for (ii = x; ii < 10; ii += z) + if (array[ii] != array2[ii]) + return 5; + + + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + y = 10-atoi(argv[1]); + + for (ii = 0; ii < 10; ii++) + { + array[ii] = 500; + array2[ii] = 1000000; + } + + array[atoi(argv[1]):(10-atoi(argv[1])):((10-atoi(argv[1]))/atoi(argv[1]))] = + array2[atoi(argv[1]):(10-atoi(argv[1])):((10-atoi(argv[1]))/atoi(argv[1]))]; + for (ii = x; ii < 10; ii += z) + if (array[ii] != array2[ii]) + return 6; + + for (ii = 0; ii < 10; ii++) + { + array[ii] = 4; + array2[ii] = 2; + } + + array[atoi("5"):5:1] = array2[atoi("5"):5:1]; + + for (ii = atoi ("5"); ii < 10; ii++) + if (array[ii] != array2[ii]) + return (7); + + for (ii = 0; ii < 10; ii++) + { + array[ii] = 5; + array2[ii] = 1; + } + array[atoi("5"):atoi("5"):atoi("1")] = array2[atoi("5"):atoi("5"):atoi("1")]; + + for (ii = 5; ii < 10; ii++) + if (array2[ii] != array[ii]) + return 8; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test_ND.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test_ND.c new file mode 100644 index 000000000..e89bbab26 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/array_test_ND.c @@ -0,0 +1,102 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#include <stdlib.h> +int main2(char **argv); +int main(void) +{ + int x = 0; + const char *array[] = {"a.out", "10", "15"}; + x = main2 ((char **)array); + return x; +} + +int main2(char **argv) +{ + int array[10][15], ii = 0, jj = 0,x = 0, z= 1 , y = 10 ; + int array_2[10][15]; + int argc = 3; + __asm volatile ("" : "+r" (argc)); + + for (ii = 0; ii < 10; ii++) { + for (jj = 0; jj< 15; jj++) { + array[ii][jj] = ii+jj; + array_2[ii][jj] = 0; + } + } + array_2[0:5:2][0:5:3] = array[0:5:2][0:5:3] + 1 + 5 + array[0][5] + x; + + for (ii = 0; ii < 10; ii += 2) + { + for (jj = 0; jj < 15; jj += 3) + { + if (array_2[ii][jj] != array[ii][jj] + 1 + 5 + array[0][5] + x) + return 2; + } + } + + + for (ii = 0; ii < 10; ii++) { + for (jj = 0; jj< 15; jj++) { + array[ii][jj] = ii+jj; + array_2[ii][jj] = 0; + } + } + x = atoi(argv[1]); + y = atoi(argv[2]); + array_2[0:x:1][0:y:1] = array[0:x:1][0:y:1] + x + y + array[0:x:1][0:y:1]; + + for (ii = 0; ii < x; ii++) + { + for (jj = 0; jj < y; jj++) + { + if (array_2[ii][jj] != array[ii][jj] + x + y + array[ii][jj]) + return 3; + } + } + + for (ii = 0; ii < 10; ii++) { + for (jj = 0; jj< 15; jj++) { + array[ii][jj] = ii+jj; + array_2[ii][jj] = 0; + } + } + x = atoi(argv[1]); + y = atoi(argv[2]); + z = (20- atoi (argv[1]))/atoi(argv[1]); + /* (20-10)/10 evaluates to 1 all the time :-). */ + array_2[0:x:z][0:y:z] = array[0:x:z][0:y:z] + array[0:x:z][0:y:z] + y + z; + + for (ii = 0; ii < x; ii += z) + { + for (jj = 0; jj < y; jj += z) + { + if (array_2[ii][jj] != array[ii][jj] + array[ii][jj] + y + z) + return 4; + } + } + + + + for (ii = 0; ii < 10; ii++) { + for (jj = 0; jj< 15; jj++) { + array[ii][jj] = ii+jj; + array_2[ii][jj] = 0; + } + } + x = argc-3; + y = 20-atoi(argv[1]); + z = (20- atoi (argv[1]))/atoi(argv[1]); + /* (20-10)/10 evaluates to 1 all the time :-). */ + array_2[(argc-3):(20-atoi(argv[1])):(20-atoi(argv[1]))/atoi(argv[1])][(argc-3):(30-atoi(argv[2])): ((30-atoi(argv[2]))/atoi(argv[2]))] = array[(argc-3):20-atoi(argv[1]):(20-atoi(argv[1]))/atoi(argv[1])][(argc-3):(30-atoi(argv[2])): (30-atoi(argv[2]))/atoi(argv[2])] + array[(argc-3):20-atoi(argv[1]):(20-atoi(argv[1]))/atoi(argv[1])][(argc-3):(30-atoi(argv[2])): (30-atoi(argv[2]))/atoi(argv[2])] * array[(argc-3):20-atoi(argv[1]):(20-atoi(argv[1]))/atoi(argv[1])][(argc-3):(30-atoi(argv[2])): (30-atoi(argv[2]))/atoi(argv[2])]; + + for (ii = 0; ii < 10; ii++) + { + for (jj = 0; jj < 15; jj++) + { + if (array_2[ii][jj] != array[ii][jj] + array[ii][jj] * array[ii][jj]) + return 5; + } + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_custom.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_custom.c new file mode 100644 index 000000000..0f066d4a6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_custom.c @@ -0,0 +1,69 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#define NUMBER 100 +#if HAVE_IO +#include <stdio.h> +#endif +/* #include <stdlib.h> */ + +double my_func (double x, double y) +{ + if (x > y) + return x; + else + return y; +} + + +/* char __sec_reduce_add (int *); */ +int main(void) +{ + int ii,array[NUMBER], y = 0, y_int = 0, array2[NUMBER]; + double x, yy, array3[NUMBER], array4[NUMBER]; + double max_value = 0.000, min_value = 0.000, add_value, mul_value = 1.00; + int max_index = 0, min_index = 0; + for (ii = 0; ii < NUMBER; ii++) + { + array[ii] = 1+ii; + array2[ii]= 2; + } + + for (ii = 0; ii < NUMBER; ii++) + { + if (ii%2 && ii) + array3[ii] = (double)(1.0000/(double)ii); + else + array3[ii] = (double) ii + 0.10; + array4[ii] = (double) (1.00000/ (double)(ii+1)); + } + + /* array[:] = 5; */ + x = __sec_reduce (0, array3[:] * array4[:], my_func); + y = __sec_reduce_max_ind ( array3[:] * array4[:]); + + /* Initialize it to the first variable. */ + max_value = array3[0] * array4[0]; + for (ii = 0; ii < NUMBER; ii++) + if (array3[ii] * array4[ii] > max_value) { + max_value = array3[ii] * array4[ii]; + max_index = ii; + } + + + +#if HAVE_IO + for (ii = 0; ii < NUMBER; ii++) + printf("%5.3f ", array3[ii] * array4[ii]); + printf("\n"); + printf("Max = %5.3f\t Max Index = %2d\n", x, y); +#endif + + if (x != max_value) + return 1; + + if (y != max_index) + return 2; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_mutating.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_mutating.c new file mode 100644 index 000000000..e01fbb1b3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_mutating.c @@ -0,0 +1,69 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#define NUMBER 100 +#if HAVE_IO +#include <stdio.h> +#endif +/* #include <stdlib.h> */ + +void my_func (double *x, double y) +{ + if (*x < y) + *x = y; +} + + +int main(void) +{ + int ii,array[NUMBER], y = 0, y_int = 0, array2[NUMBER]; + double x = 0.000, yy, array3[NUMBER], array4[NUMBER]; + double max_value = 0.000, min_value = 0.000, add_value, mul_value = 1.00; + int max_index = 0, min_index = 0; +#if 1 + for (ii = 0; ii < NUMBER; ii++) + { + array[ii] = 1+ii; + array2[ii]= 2; + } + + for (ii = 0; ii < NUMBER; ii++) + { + if (ii%2 && ii) + array3[ii] = (double)(1.0000/(double)ii); + else + array3[ii] = (double) ii + 0.10; + array4[ii] = (double) (1.00000/ (double)(ii+1)); + } +#endif + /* array[:] = 5; */ + __sec_reduce_mutating (&x, array3[:] * array4[:], my_func); +#if 1 + y = __sec_reduce_max_ind ( array3[:] * array4[:]); + + /* Initialize it to the first variable. */ + max_value = array3[0] * array4[0]; + for (ii = 0; ii < NUMBER; ii++) + if (array3[ii] * array4[ii] > max_value) { + max_index = ii; + } + + for (ii = 0; ii < NUMBER; ii++) + my_func (&max_value, array3[ii] * array4[ii]); + +#if HAVE_IO + for (ii = 0; ii < NUMBER; ii++) + printf("%5.3f ", array3[ii] * array4[ii]); + printf("\n"); + printf("Max = %5.3f\t Max Index = %2d\n", x, y); + printf("Max = %5.3f\t Max Index = %2d\n", max_value, max_index); +#endif + + if (x != max_value) + return 1; + + if (y != max_index) + return 2; +#endif + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_func_double.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_func_double.c new file mode 100644 index 000000000..0c05994ee --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_func_double.c @@ -0,0 +1,124 @@ +#if HAVE_IO +#include <stdio.h> +#endif +/* #include <stdlib.h> */ + +/* char __sec_reduce_add (int *); */ +int main(void) +{ + int ii,array[10], y = 0, y_int = 0, array2[10]; + double x, yy, array3[10], array4[10]; + double max_value = 0.000, min_value = 0.000, add_value, mul_value = 1.00; + int max_index = 0, min_index = 0; + for (ii = 0; ii < 10; ii++) + { + array[ii] = 1+ii; + array2[ii]= 2; + } + + for (ii = 0; ii < 10; ii++) + { + if (ii%2 && ii) + array3[ii] = (double)(1.0000/(double)ii); + else + array3[ii] = (double) ii + 0.10; + array4[ii] = (double) (1.00000/ (double)(ii+1)); + } + + /* array[:] = 5; */ + x = __sec_reduce_max (array3[:] * array4[:]); + y = __sec_reduce_max_ind ( array3[:] * array4[:]); + + /* Initialize it to the first variable. */ + max_value = array3[0] * array4[0]; + for (ii = 0; ii < 10; ii++) + if (array3[ii] * array4[ii] > max_value) { + max_value = array3[ii] * array4[ii]; + max_index = ii; + } + + + +#if HAVE_IO + for (ii = 0; ii < 10; ii++) + printf("%5.3f ", array3[ii] * array4[ii]); + printf("\n"); + printf("Max = %5.3f\t Max Index = %2d\n", x, y); +#endif + + if (x != max_value) + return 1; + + if (y != max_index) + return 2; + + x = __sec_reduce_min (array3[:] * array4[:]); + y = __sec_reduce_min_ind ( array3[:] * array4[:]); +#if HAVE_IO + for (ii = 0; ii < 10; ii++) + printf("%5.3f ", array3[ii] * array4[ii]); + printf("\n"); + printf("Min = %5.3f\t Min Index = %2d\n", x, y); +#endif + + /* Initialize it to the first variable. */ + min_value = array3[0] * array4[0]; + for (ii = 0; ii < 10; ii++) + if (array3[ii] * array4[ii] < min_value) { + min_value = array3[ii] * array4[ii]; + min_index = ii; + } + + if (x != min_value) + return 3; + if (y != min_index) + return 4; + + x = __sec_reduce_add (array3[:] * array4[:]); + yy = __sec_reduce_mul ( array3[:] * array4[:]); +#if HAVE_IO + for (ii = 0; ii < 10; ii++) + printf("%5.3f ", array3[ii] * array4[ii]); + printf("\n"); + printf("Add = %5.3f\t Mul = %f\n", x, yy); +#endif + + /* Initialize it to the first variable. */ + add_value = 0.0000; + mul_value = 1.0000; + for (ii = 0; ii < 10; ii++) + { + add_value += (array3[ii] * array4[ii]); + mul_value *= (array3[ii] * array4[ii]); + } + + if (x != add_value) + return 5; + if (yy != mul_value) + return 6; + + for (ii = 0; ii < 10; ii++) + { + if (ii%2 && ii) + array3[ii] = (double)(1.0000/(double)ii); + else + array3[ii] = (double) ii + 0.00; + array4[ii] = (double) (1.00000/ (double)(ii+1)); + } + y_int = __sec_reduce_any_zero (array3[:] * array4[:]); + y = __sec_reduce_all_zero ( array3[:] * array4[:]); + + if (y_int != 1) + return 7; + + if (y != 0) + return 8; + +#if HAVE_IO + for (ii = 0; ii < 10; ii++) + printf("%5.3f ", array3[ii] * array4[ii]); + printf("\n"); + printf("Any Zeros = %d\t All Zeros = %d\n", y_int, y); +#endif + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_func_double2.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_func_double2.c new file mode 100644 index 000000000..65549121b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_func_double2.c @@ -0,0 +1,77 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#define NUMBER 100 +#if HAVE_IO +#include <stdio.h> +#endif + +int main(void) +{ + int argc = 1; + int ii,array[NUMBER], y = 0, y_int = 0, array2[NUMBER], y_int2=0, y2=0; + double x, yy, array3[NUMBER], array4[NUMBER]; + int all_zero, all_nonzero, any_zero, any_nonzero; + for (ii = 0; ii < NUMBER; ii++) + { + array[ii] = 0; + array2[ii] = 5; + if (ii%2 && ii) + array3[ii] = (double)(1.0000/(double)ii); + else + array3[ii] = (double) ii + 0.00; + array4[ii] = (double) (1.00000/ (double)(ii+1)); + } + __asm volatile ("" : "+r" (argc)); + y_int = __sec_reduce_any_nonzero (array3[:] + array[4]); + y_int2 = __sec_reduce_any_zero (array3[:] + array[4]); + y = __sec_reduce_all_nonzero ((array3[:] + array4[:]) * (argc-1)); + y2 = __sec_reduce_all_zero ((array3[:] + array4[:]) * (argc-1)); + + any_zero = 0; + any_nonzero = 0; + for (ii = 0; ii < NUMBER; ii++) + { + if ((array3[ii] + array[4]) == 0) + any_zero = 1; + else + any_nonzero = 1; + } + + if (any_nonzero != y_int) + return 1; + if (any_zero != y_int2) + return 2; + + + all_zero = 0; + all_nonzero = 0; + for (ii = 0; ii < NUMBER; ii++) + { + if (((array3[ii] + array4[ii]) * (argc-1)) == 0) + all_zero = 1; + else + all_nonzero = 1; + } + + if (y != all_nonzero) + return 3; + if (all_zero != y2) + return 4; + + +#if HAVE_IO + for (ii = 0; ii < NUMBER; ii++) { + printf("%5.3f ", array3[ii] +array4[ii]); + } + printf("\n"); + for (ii = 0; ii < NUMBER; ii++) { + printf("%5.3f ", (array3[ii] + array4[ii]) * (argc-1)); + } + printf("\n"); + printf("Any Non-zeros (1st line) = %d\t All non-zeros (1st line) = %d\n", + y_int, y); + printf("Any zeros (2nd line) = %d\t All zeros (2nd line) = %d\n", y_int2, y2); +#endif + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/comma_exp.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/comma_exp.c new file mode 100644 index 000000000..845d916ab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/comma_exp.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#include <stdlib.h> + +int main2 (char **argv); +int main(void) +{ + int x = 0; + const char *array[] = {"a.out", "5"}; + x = main2 ((char **)array); + return x; +} + +int main2 (char **argv) +{ + int argc = 2; + int array[10], array2[10], ii = 0, x = 2, z= 0 , y = 0 ; + __asm volatile ("" : "+r" (argc)); + for (ii = 0; ii < 10; ii++) + array[ii] = 10; + + for (ii = 0; ii < 10; ii++) + array2[ii] = 1; + + array[0:10:1] = (array[:], 15); + + for (ii = 0; ii < 10; ii++) + if (array[ii] != 15) + return 1; + array[0:5:2] = (argc+2, 20); + + for (ii = 0; ii < 10; ii += 2) + if (array[ii] != 20) + return 2; + + + x = atoi(argv[1]); + z = (10-atoi(argv[1]))/atoi(argv[1]); + + array[x:5:z] = 50; + + array[:] = (atoi(argv[1]), (array2[0:10]+5)); + + for (ii = 0; ii < 10; ii++) + if (array[ii] != 6) + return (3); + + array[:] = (atoi(argv[1]), (array2[0:10]+array2[0:10])); + for (ii = 0; ii < 10; ii++) + if (array[ii] != 2) + return 4; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/conditional.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/conditional.c new file mode 100644 index 000000000..07c50173b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/conditional.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#include <stdlib.h> +int main(void) +{ + int argc = 1; + short array[1000], array2[1000], *array3, cond[1000], ii = 0; + + __asm volatile ("" : "+r" (argc)); + for (ii = 0; ii < 1000; ii++) { + cond[ii] = 1; + array[ii] = 1000; + array2[ii] = 2000; + } + array2[:] = cond[:] ? array[:] : array2[:]; + + for (ii = 0; ii < 1000; ii++) { + if (array2[ii] != 1000) + return 1; + } + + array2[0:500:2] = cond[0:500] ? array[0:500:1] : array2[0:500:2]; + + for (ii = 0; ii < 1000; ii++) { + if (array2[ii] != 1000) + return 2; + } + + for (ii = 0; ii < 1000; ii++) { + cond[ii] = ii % 2; /* This should give 0, 1, 0, 1, 0, 1, 0,... */ + array2[ii] = 5; + array[ii] = 3; + } + array3 = (short *) malloc (sizeof (short) * 1000); + array3[0:1000:argc] = cond[:] ? array[0:(argc * 1000)] : array2[argc-1:1000]; + + for (ii = 0; ii < 1000; ii++) { + if ((cond[ii] == 0 && array3[ii] != 5) + || (cond[ii] == 1 && array3[ii] != 3)) + return 3; + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/decl-ptr-colon.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/decl-ptr-colon.c new file mode 100644 index 000000000..4b54f4d06 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/decl-ptr-colon.c @@ -0,0 +1,19 @@ +/* { dg-do compile { target c } } */ +/* { dg-options "-fcilkplus" } */ + +int main(void) +{ + extern int func(int); + int array3[:], x, q; /* { dg-error "array notations cannot be used in declaration" } */ + int array3[1:2:x]; /* { dg-error "array notations cannot be used in declaration" } */ + extern char array3[1:func(x)]; /* { dg-error "array notations cannot be used in declaration" } */ + int *a, ***b; + extern char *c; + int array2[10]; + + a[:] = 5; /* { dg-error "start-index and length fields necessary for using array notations in pointers" } */ + c[1:2] = 3; /* This is OK. */ + (array2)[:] = 5; /* This is OK. */ + b[1:2][1:func(x)][:] = 3; /* { dg-error "start-index and length fields necessary for using array notations in pointers" } */ +} + diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/dimensionless-arrays.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/dimensionless-arrays.c new file mode 100644 index 000000000..690e89a27 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/dimensionless-arrays.c @@ -0,0 +1,10 @@ +/* { dg-options "-fcilkplus" } */ + +extern int a[]; +extern int *b; + +void foo() +{ + a[:] = 5; // { dg-error "start-index and length fields necessary for using array notation" } + b[:] = 5; // { dg-error "start-index and length fields necessary for using" } +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once.c new file mode 100644 index 000000000..00b018a2c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#define NUMBER 1000 + +#if HAVE_IO +#include <stdio.h> +#endif + +int func (int *x) +{ + int q = *x; + q++; + *x = q; +#if HAVE_IO + printf("%d\n", (q)); +#endif + return *x; +} +int main (void) +{ + char array[NUMBER], array2[NUMBER]; + int ii, d = 2; +#if 1 + for (ii = 0; ii < NUMBER; ii++) { + array[ii] = 5; + array2[ii]= 2; + } +#endif + d = func (&d); /* d = 1 */ + array2[:] = d * array[:] + (char) func (&d); /* 3 * 5 + 4 */ +#if HAVE_IO + for (ii = 0; ii < NUMBER; ii++) + printf("array2[%d] = %d\n", ii, array2[ii]); +#endif + for (ii = 0; ii < NUMBER; ii++) + if (array2[ii] != (3 * 5 + 4)) + return 1; + + return 0; +} + + + diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once2.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once2.c new file mode 100644 index 000000000..d9f39dd66 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/exec-once2.c @@ -0,0 +1,87 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#ifdef HAVE_IO +#include <stdio.h> +#endif + + +int func1(int x) +{ + /* If x == 2 then it should return 0. */ + return (x - 2); +} + +int func2(int x) +{ + /* If x == 2 then it should return 1000. */ + return (x * 500); +} + +int func3 (int x) +{ + /* If x == 2 then it should return 1. */ + /* If x == 1 then it should return 0. */ + return (x-1); +} + +int func4(int x) +{ + if (x > 0) + return x; + else + return x--; +} + + +/* This program makes an assumption that argc == 1. */ +int main (void) +{ + int argc = 1; + int array[2500]; + + /* This is done to make sure the compiler does not optimize out argc. */ + __asm volatile ("" : "+r" (argc)); + /* This should set array[0->999] to 5. */ + array[argc-1:func2(++argc):1] = 5; + array[1000:500:1] = 10; /* set all variables in array[1000-->1499] to 10. */ + array[1500:500:1] = 15; /* set all variables in array[1500-->1999] to 15. */ + array[2000:500:1] = 20; /* set all variables in array[2000-->2499] to 20. */ + array[2000:500:1] = 25; /* set all variables in array[2500-->2999] to 25. */ + array[2000:500:1] = 30; /* set all variables in array[3000-->3499] to 30. */ + + argc = func3 (argc); /* This will set argc back to 1. */ +#if HAVE_IO + printf("argc = %d\n", argc); +#endif + /* If the parameters inside the function get evaluated only once, then this + if statement must work fine, i.e. the triplet values will be 0, 1000, 1. + + Otherwise, the program should crash or give some uneasy value. */ + + /* If done correctly, it should boil down to: array[0:1000:1]. */ + if (array[func3(argc):func2(++argc)] != 5) { +#ifdef HAVE_IO + printf ("Should not be there(1).\n"); +#endif + return 1; + } + + /* If done correctly, it should boil down to: array[999:500:-1]. */ + if (func4(array[func2(argc)-1:func2(argc--):func1(argc)]) != 5) { +#ifdef HAVE_IO + printf ("Should not be there(2).\n"); +#endif + return 2; + } + + /* If done correctly, it should boil down to: array[1000:500:1]. */ + if (func4 (func4(array[func2(argc++):500: func1(argc--)])) != 5) { +#ifdef HAVE_IO + printf ("Should not be there(3).\n"); +#endif + return 3; + } + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr.c new file mode 100644 index 000000000..fa6d9003a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/fn_ptr.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +typedef int (*foo)(int); + +int main(void) +{ + int array[10], array2[10][10]; + foo func_array[10]; + foo func_array2[10][10]; + foo ***func_array_ptr; + int argc = 5; + + array[:] = func_array[:](10); + func_array[0:5](10); + func_array2[0:5][:](10); + array2[0:5][:] = func_array2[0:5][:](10); + func_array_ptr[0:5][0:4][0:argc:2](argc); + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/fp_triplet_values.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/fp_triplet_values.c new file mode 100644 index 000000000..b2ac7bcc8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/fp_triplet_values.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +float q; + +void func (int *x) +{ + *x = 5; +} + +int main (void) +{ + int array[10], array2[10]; + array2[:] = array[1.5:2]; /* { dg-error "start-index of array notation triplet is not an integer" } */ + array2[:] = array[1:2.32333333333]; /* { dg-error "length of array notation triplet is not an integer" } */ + array2[1:2:1.5] = array[:]; /* { dg-error "stride of array notation triplet is not an integer" } */ + func (&array2[1:2.34:3]); /* { dg-error "length of array notation triplet is not an integer" } */ + array2[1.43:9]++; /* { dg-error "start-index of array notation triplet is not an integer" } */ + array2[1:9.3]++; /* { dg-error "length of array notation triplet is not an integer" } */ + array2[1:9:0.3]++; /* { dg-error "stride of array notation triplet is not an integer" } */ + + ++array2[1:q:3]; /* { dg-error "length of array notation triplet is not an integer" } */ + array2[:] = array[q:1:3]; /* { dg-error "start-index of array notation triplet is not an integer" } */ + array2[:] = array[1:q:3]; /* { dg-error "length of array notation triplet is not an integer" } */ + array2[:] = array[1:3:q]; /* { dg-error "stride of array notation triplet is not an integer" } */ + func (&array2[1:q:3]); /* { dg-error "length of array notation triplet is not an integer" } */ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/gather-scatter-errors.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/gather-scatter-errors.c new file mode 100644 index 000000000..f425fbec0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/gather-scatter-errors.c @@ -0,0 +1,19 @@ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + extern int func (int); + int array[10][10], array2[10]; + int argc = 1; + array2[array[:][:]] = 5; /* { dg-error "rank of the array's index is greater than 1" } */ + + array2[array[:][:]] = 5; /* { dg-error "rank of the array's index is greater than 1" } */ + func (array2[array[:][:]]); /* { dg-error "rank of the array's index is greater than 1" } */ + func (array2[array[argc:func(5)][0:10:2]]); /* { dg-error "rank of the array's index is greater than 1" } */ + + array[array2[:]][array2[:]] = 5; /* This is OK. */ + array[array2[:]][array2[:]] = array2[array[:][:]]; /* { dg-error "rank of the array's index is greater than 1" } */ + array[array2[:]][array2[:]] = array2[array[0:10:1][:]]; /* { dg-error "rank of the array's index is greater than 1" } */ + array[array2[:]][array2[:]] = array2[array[:][argc:func (argc)]]; /* { dg-error "rank of the array's index is greater than 1" } */ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/gather_scatter.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/gather_scatter.c new file mode 100644 index 000000000..faee3fceb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/gather_scatter.c @@ -0,0 +1,60 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#define NUMBER 20 +#if HAVE_IO +#include <stdio.h> +#endif + +float array4[NUMBER][NUMBER][NUMBER][NUMBER]; +int main(void) +{ + int array[NUMBER][NUMBER], array2[NUMBER], array3[NUMBER], x = 0, y; + int x_correct, y_correct, ii, jj = 0, kk = 0, ll = 0; + for (ii = 0; ii < NUMBER; ii++) + { + for (jj = 0; jj < NUMBER; jj++) + { + array[ii][jj] = 1+ii; + array2[ii]= 2; + array3[ii]= 3; + } + } + + array[array2[:]][array3[:]] = 1000; + + for (ii = 0; ii < NUMBER; ii++) + if (array[array2[ii]][array3[ii]] != 1000) + return 1; + +#if HAVE_IO + for (ii = 0; ii < NUMBER; ii++) { + for (jj = 0; jj < NUMBER; jj++) { + printf("%4d\t", array[ii][jj]); + } + printf("\n"); + } +#endif + + array4[array2[:]][array3[0:NUMBER:1]][array2[0:NUMBER:1]][array3[0:NUMBER:1]] = + (float)array[array2[:]][array3[:]]; + + for (ii = 0; ii < NUMBER; ii++) + if (array4[array2[ii]][array3[ii]][array2[ii]][array3[ii]] != + (float)array[array2[ii]][array3[ii]]) + return 2; + +#if HAVE_IO + for (ii = 0; ii < NUMBER; ii++) { + for (jj = 0; jj < NUMBER; jj++) { + for (kk = 0; kk < NUMBER; kk++) { + for (ll = 0; ll < NUMBER; ll++) { + printf("%4d\n", array4[ii][jj][kk][ll]); + } + } + } + } +#endif + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c new file mode 100644 index 000000000..4e5b15837 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test.c @@ -0,0 +1,306 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#if HAVE_IO +#include <stdio.h> +#endif +#include <stdlib.h> +int main2 (char **argv); +int main(int argc, char **argv) +{ + int x = 0; + const char *array[] = {"a.out", "10", "15"}; + x = main2 ((char **) array); + return x; +} + + +int main2 (char **argv) +{ + int x = 3, y, z, array[10], array2[10], TwodArray[10][10], jj,kk,ll ; + int array2_check[10], array2d_check[10][10], array2d[10][10]; + int FourDArray[10][10][10][10], array4[10][10][10][10]; + int array4_check[10][10][10][10]; + int ii = 0, argc = 3; + + __asm volatile ("" : "+r" (argc)); + + for (ii = 0; ii < 10; ii++) + { + array[ii] = argc%3; + array2[ii]= 10; + array2_check[ii] = 10; + } + + if (!array[:]) + array2[:] = 5; + else + array2[:] = 10; + + + for (ii = 0; ii < 10; ii++) + { + if (!array[ii]) + array2_check[ii] = 5; + else + array2_check[ii] = 10; + } + + for (ii = 0; ii < 10; ii++) + if (array2_check[ii] != array2[ii]) + return 2; + + + + if (!(array[0:10:1] + array[0:10:1])) + array2[:] = 5; + else + array2[:] = 10; + + for (ii = 0; ii < 10; ii++) + { + if (!(array[ii]+ array[ii])) + array2_check[ii] = 5; + else + array2_check[ii] = 10; + } + + for (ii = 0; ii < 10; ii++) + if (array2_check[ii] != array2[ii]) + return 3; + + x = atoi (argv[1])-10; + y = atoi (argv[1])/2; + z = (atoi (argv[1]))/5; + + for (ii = 0; ii < 10; ii++) + { + if (ii % 2) + array[ii] = 0; + else + array[ii] = 1; + } + + /*printf("x = %2d y = %2d z = %2d\n", x, y, z); */ + + for (ii = 0; ii < 10; ii++) + array[ii] = 10; + + /* This if loop will change all the 10's to 5's */ + if (array[x:y:z] != 9) + array2[:] = 5; + else + array2[:] = 10; + + for (ii = x; ii < (x+y); ii += z) + { + if (array[ii] != 9) + array2_check[ii] = 5; + else + array2_check[ii] = 10; + } + + for (ii = 0; ii < 10; ii++) + if (array2_check[ii] != array2[ii]) + return 4; + + for (ii = 0; ii < 10; ii++) { + array2[ii] = 10; + array2_check[ii] = 10; + } + + /* This if loop will change all the 10's to 5's */ + if (array[atoi(argv[1])-10:atoi(argv[1])/2: atoi(argv[1])/5]) + array2[atoi(argv[1])-10: atoi (argv[1])/2: atoi(argv[1])/5] = 5; + else + array2[atoi(argv[1])-10: atoi (argv[1])/2: atoi(argv[1])/5] = 10; + + for (ii = atoi(argv[1])-10; ii < atoi(argv[1]) + (atoi (argv[1])-10); + ii +=atoi(argv[1])/5) + if (array[ii]) + array2_check[ii] = 5; + else + array2_check[ii] = 10; + + for (ii = 0; ii < 10; ii++) + if (array2_check[ii] != array2[ii]) { +#if HAVE_IO + printf("array2[%2d] = %2d array2_check[%2d] = %2d\n", ii, array2[ii], + ii, array2_check[ii]); +#endif + return 5; + } + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + TwodArray[ii][jj] = atoi(argv[1]); + + + for (ii = 0; ii < 10; ii++) + for (ii = 0; ii < 10; ii++) { + array2d[ii][jj] = 10; + array2d_check[ii][jj] = 10; + } + + /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */ + if (TwodArray[:][:] != 10) + array2d[:][:] = 10; + else + array2d[:][:] = 5; + + for (ii = 0; ii < 10; ii++) { + for (jj = 0; jj < 10; jj++) { + if (TwodArray[ii][jj] != 10) + array2d_check[ii][jj] = 10; + else + array2d_check[ii][jj] = 5; + } + } + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + if (array2d[ii][jj] != array2d_check[ii][jj]) + return 6; + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + { + array4[ii][jj][kk][ll] = 10; + array4_check[ii][jj][kk][ll] = 10; + } + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + FourDArray[ii][jj][kk][ll] = atoi(argv[1]); + + /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */ + if (FourDArray[:][:][:][:] != 10) + array4[:][:][:][:] = 10; + else + array4[:][:][:][:] = 5; + + for (ii = 0; ii < 10; ii++) { + for (jj = 0; jj < 10; jj++) { + for (kk = 0; kk < 10; kk++) { + for (ll = 0; ll < 10; ll++) { + if (FourDArray[ii][jj][kk][ll] != 10) + array4_check[ii][jj][kk][ll] = 10; + else + array4_check[ii][jj][kk][ll] = 5; + } + } + } + } + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + if (array4_check[ii][jj][kk][ll] != array4[ii][jj][kk][ll]) + return 7; + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + { + array4[ii][jj][kk][ll] = 10; + array4_check[ii][jj][kk][ll] = 10; + } + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + FourDArray[ii][jj][kk][ll] = atoi(argv[1]); + + /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */ + if (FourDArray[0:10:1][0:5:2][9:10:-1][0:5:2] != 10) + array4[0:10:1][0:5:2][9:10:-1][0:5:2] = 10; + else + array4[0:10:1][0:5:2][9:10:-1][0:5:2] = 5; + + for (ii = 0; ii < 10; ii++) { + for (jj = 0; jj < 10; jj += 2) { + for (kk = 9; kk >= 0; kk--) { + for (ll = 0; ll < 10; ll += 2) { + if (FourDArray[ii][jj][kk][ll] != 10) + array4_check[ii][jj][kk][ll] = 10; + else + array4_check[ii][jj][kk][ll] = 5; + } + } + } + } + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + if (array4_check[ii][jj][kk][ll] != array4[ii][jj][kk][ll]) { +#if HAVE_IO + printf("array4_check[%d][%d][%d][%d] = %d\n",ii, jj, kk, ll, + array4_check[ii][jj][kk][ll]); + printf("array4[%d][%d][%d][%d] = %d\n",ii, jj, kk, ll, + array4[ii][jj][kk][ll]); +#endif + return 8; + } + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + FourDArray[ii][jj][kk][ll] = atoi(argv[1]); + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + { + array4[ii][jj][kk][ll] = 10; + array4_check[ii][jj][kk][ll] = 10; + } + + + /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */ + if (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] + + FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] != 20) + array4[0:10:1][0:5:2][9:10:-1][x:y:z] = 10; + else + array4[0:10][0:5:2][9:10:-1][x:y:z] = 5; + + for (ii = 0; ii < 10; ii++) { + for (jj = 0; jj < 10; jj += 2) { + for (kk = 9; kk >= 0; kk--) { + for (ll = 0; ll < 10; ll += 2) { + if (FourDArray[ii][jj][kk][ll] != 10) + array4_check[ii][jj][kk][ll] = 10; + else + array4_check[ii][jj][kk][ll] = 5; + } + } + } + } + + for (ii = 0; ii < 10; ii++) + for (jj = 0; jj < 10; jj++) + for (kk = 0; kk < 10; kk++) + for (ll = 0; ll < 10; ll++) + if (array4_check[ii][jj][kk][ll] != array4[ii][jj][kk][ll]) { +#if HAVE_IO + printf("array4_check[%d][%d][%d][%d] = %d\n",ii, jj, kk, ll, + array4_check[ii][jj][kk][ll]); + printf("array4[%d][%d][%d][%d] = %d\n",ii, jj, kk, ll, + array4[ii][jj][kk][ll]); +#endif + return 9; + } + + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test_errors.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test_errors.c new file mode 100644 index 000000000..579d39694 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/if_test_errors.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +#include <stdlib.h> +int main (void) +{ + int x = 3, y, z, array[10], array2[10], TwodArray[10][10], jj,kk,ll ; + int array2_check[10], array2d_check[10][10], array2d[10][10]; + int FourDArray[10][10][10][10], array4[10][10][10][10]; + int array4_check[10][10][10][10]; + int ii = 0; + + x = 5; + y = 10; + z = 2; + + if (!array[:]) /* This is OK! */ + array2[:] = 5; + else + array2[:] = 10; + if (!(array[0:10:1] + array[0:10:1])) /* { dg-error "condition and the then-block" "" { target c } } */ + array2d[:][:] = 5; /* { dg-error "rank mismatch with controlling expression of parent" "" { target c++ } } */ + else + array2[:] = 10; + + if (!(array[0:10:1] + array[0:10:1])) /* { dg-error "condition and the else-block" "" { target c } } */ + array2[:] = 5; + else + array2d[:][:] = 10; /* { dg-error "rank mismatch with controlling expression of parent" "" { target c++ } } */ + + + if (TwodArray[:][:] != 10) /* { dg-error "condition and the then-block" "" { target c } } */ + array2[:] = 10; /* { dg-error "rank mismatch with controlling expression of parent" "" { target c++ } } */ + else + array2[:] = 5; + + if (FourDArray[43][:][:][:] != 10) /* This is OK! */ + array4[45][:][:][:] = 10; + else + array4[32][:][:][:] = 5; + + /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */ + if (FourDArray[42][0:10:1][9:10:-1][0:5:2] != 10) /* { dg-error "condition and the then-block" "" { target c } } */ + array4[0:10:1][0:5:2][9:10:-1][0:5:2] = 10; /* { dg-error "rank mismatch with controlling expression of parent" "" { target c++ } } */ + else + array4[0:10:1][0:5:2][9:10:-1][0:5:2] = 5; + + /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */ + if (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] + + FourDArray[0:10:1][0:5:2][9:-10:1][x:y:z] != 20) + array4[0:10:1][0:5:2][9:10:-1][x:y:z] = 10; + else + array4[0:10][0:5:2][9:10:-1][x:y:z] = 5; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c new file mode 100644 index 000000000..814786b99 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c @@ -0,0 +1,112 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + int array[10], array2[10][10]; + int x, ii, jj ; + + switch (array[:]) { /* { dg-error "cannot be used as a condition for switch statement" } */ + case 1: + x = 5; + break; + case 2: + x = 2; + break; + default: + x = 9; + } + + switch (array2[:][:]) { /* { dg-error "cannot be used as a condition for switch statement" } */ + case 1: + x = 5; + break; + case 2: + x = 2; + break; + default: + x = 9; + } + + switch (array[:] + x) { /* { dg-error "cannot be used as a condition for switch statement" } */ + case 1: + x = 5; + break; + case 2: + x = 2; + break; + default: + x = 9; + } + + switch (array2[:][1:x:4] + x) { /* { dg-error "cannot be used as a condition for switch statement" } */ + case 1: + x = 5; + break; + case 2: + x = 2; + break; + default: + x = 9; + } + + for (ii = 0; ii < array[:]; ii++) /* { dg-error "cannot be used in a condition for a for-loop" } */ + { + x = 2; + } + + for (ii = 0; ii < array2[:][:]; ii++) /* { dg-error "cannot be used in a condition for a for-loop" } */ + { + x = 3; + } + + for (; array2[:][:] < 2;) /* { dg-error "cannot be used in a condition for a for-loop" } */ + x = 4; + + + while (array2[:][:]) /* { dg-error "cannot be used as a condition for while statement" } */ + x = 3; + + while (array[1:1:1]) /* { dg-error "cannot be used as a condition for while statement" } */ + x = 1; + + while (ii != array2[1:x:3][1:2:1]) /* { dg-error "cannot be used as a condition for while statement" } */ + x = 2; + + do { /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c } } */ + x = 3; + } while (ii != array2[:][:]); /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c++ } } */ + + do { /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c } } */ + x = 2; + } while (ii != (x + array2[:][1:x:2]) + 2); /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c++ } } */ + + do { + x += 3; + if (x == 5) + return array2[:][:]; /* { dg-error "array notation expression cannot be used as a return value" } */ + } while (ii != 0); + + for (ii = 0; ii < 10; ii++) + if (ii % 2) + return array[1:x:ii]; /* { dg-error "array notation expression cannot be used as a return value" } */ + + for (ii = 0; ii < x; ii++) + if (ii) + return array2[:][:]; /* { dg-error "array notation expression cannot be used as a return value" } */ + + for (array[:] = 0; ii < x; ii++) /* This should be OK. */ + x= 2; + + for (ii = 0; ii < 10; array[:]++) /* This is OK. */ + x = 5; + + for (jj = 0; jj < 10; array2[:][:]++) /* This is OK. */ + x = 3; + + for (jj = 0; jj < 10; array2[:][1:x:4]++, jj++) /* This is OK. */ + x = 3; + + return x; +} + diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/n-ptr-test.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/n-ptr-test.c new file mode 100644 index 000000000..750446c87 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/n-ptr-test.c @@ -0,0 +1,48 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#define NUMBER 10 +#include <stdlib.h> + +int ***func2 (int ***a1, int ***a2, int size) +{ + a1[0:size:1][0:size:1][0:size] += (a2[0:size][0:size][0:size:1] + size); + return a1; +} + +int main (void) +{ + int ii, jj, kk; + int ***array3, ***array2 = NULL, ***array = NULL; + + array = (int ***) malloc (sizeof (int **) * NUMBER); + array2 = (int ***) malloc (sizeof (int **) * NUMBER); + for (ii = 0; ii < NUMBER; ii++) { + array[ii] = (int **) malloc (sizeof (int *) * NUMBER); + array2[ii] = (int **) malloc (sizeof (int *) * NUMBER); + for (jj = 0; jj < NUMBER; jj++) { + array[ii][jj] = (int *) malloc (sizeof (int) * NUMBER); + array2[ii][jj] = (int *) malloc (sizeof (int) * NUMBER); + } + } + + for (ii = 0; ii < NUMBER; ii++) { + for (jj = 0; jj < NUMBER; jj++) { + for (kk = 0; kk < NUMBER; kk++) { + array[ii][jj][kk] = 5; + array2[ii][jj][kk]= 2; + } + } + } + array3 = func2 ((int ***)array, (int ***)array2, NUMBER); + + for (ii = 0; ii < NUMBER; ii++) { + for (jj = 0; jj < NUMBER; jj++) { + for (kk = 0; kk < NUMBER; kk++) { + if (array3[ii][jj][kk] != (7 + NUMBER)) + return 1; + } + } + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors.c new file mode 100644 index 000000000..18816e0ec --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + int array[10][10], array2[10]; + + array2[:] = array2[: ; /* { dg-error "expected ']'" } */ + + return 0; +} /* { dg-error "expected ';' before" "" { target c } } */ diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors2.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors2.c new file mode 100644 index 000000000..4314090f4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + int array[10][10], array2[10]; + + array2[:] = array2[1:2:] ; /* { dg-error "expected expression before" "" { target c } } */ + /* { dg-error "expected primary-expression before" "" { target c++ } 8 } */ + + return 0; /* { dg-error "expected ';' before" "" { target c } } */ +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors3.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors3.c new file mode 100644 index 000000000..47b597986 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + int array[10][10], array2[10]; + + array2[:] = array2[1: :] ; /* { dg-error "expected expression before" "" { target c } } */ + /* { dg-error "expected primary-expression before" "" { target c++ } 8 } */ + + return 0; /* { dg-error "expected ';' before" "" { target c } } */ +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors4.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors4.c new file mode 100644 index 000000000..a0efc04d2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/parser_errors4.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + int array[10][10], array2[10]; + + array2[:] = array2[ : : ] ; /* { dg-error " expected ']' before ':' token" } */ + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457-2.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457-2.c new file mode 100644 index 000000000..ac11b9209 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +/* Test-case contains no array notation but is compiled with -fcilkplus. + It will still print the too few arguments func, thereby saying the + if-statement after the for-loop to check for !flag_enable_cilkplus || + !is_cilkplus_reduce_function (fundecl) is not valid is always taken. */ + +int func (int, int); /* { dg-message "declared here" } */ + +int main (void) +{ + int a = 5, b = 2; + return func (a); /* { dg-error "too few arguments to function" } */ +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c new file mode 100644 index 000000000..68a1fd811 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57457.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +/* This test has no array notation components in it and thus should compile + fine without crashing. */ + +typedef unsigned int size_t; +typedef int (*__compar_fn_t) (const void *, const void *); +extern void *bsearch (const void *__key, const void *__base, + size_t __nmemb, size_t __size, __compar_fn_t + __compar) + __attribute__ ((__nonnull__ (1, 2, 5))) ; +extern __inline __attribute__ ((__gnu_inline__)) void * +bsearch (const void *__key, const void *__base, size_t __nmemb, size_t + __size, + __compar_fn_t __compar) +{ + size_t __l, __u, __idx; + const void *__p; + int __comparison; + __l = 0; + __u = __nmemb; + while (__l < __u) + { + __idx = (__l + __u) / 2; + __p = (void *) (((const char *) __base) + + (__idx * __size)); + __comparison = (*__compar) (__key, + __p); + if (__comparison < 0) + __u = __idx; + else if (__comparison > 0) + __l = __idx + 1; + else + return (void *) + __p; + } + return ((void *)0); +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57490.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57490.c new file mode 100644 index 000000000..db38b30b5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57490.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +const int n = 8; +float x[8], y[8], z[8]; +int main() { + int i = 0; + float x_sum =0; + for(i=1; i<=5; i+=4 ) { + x[0:n] = 3; + y[0:n] = i; + z[0:n] = 0; + (void)((__sec_reduce_add(x[0:n])==3*n) || (__builtin_abort (), 0)); + (void)((__sec_reduce_add(y[0:n])==i*n) || (__builtin_abort (), 0)); + (void)((__sec_reduce_add(z[0:n])==0) || (__builtin_abort (), 0)); + + if (x[0:n] >= y[0:n]) { + z[0:n] = x[0:n] - y[0:n]; + } else { + z[0:n] = x[0:n] + y[0:n]; + } + (void)((__sec_reduce_add(x[0:n])==3*n) || (__builtin_abort (), 0)); + (void)((__sec_reduce_add(y[0:n])==i*n) || (__builtin_abort (), 0)); + (void)((__sec_reduce_add(z[0:n])==(3>=i?3-i:3+i)*n) + || (__builtin_abort (), 0)); + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c new file mode 100755 index 000000000..9bff07991 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int A[10]; + +int main () { + + /* C compiler uses the term "undeclared" whereas C++ compiler uses + "not declared". Thus, grepping for declared seem to be the easiest. */ + char c = (char)N; /* { dg-error "declared" } */ + short s = (short)N; + long l = (long)N; + A[l:s:c]; +} + +/* { dg-message "note: each" "defined" { target c } 10 } */ + diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57577.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57577.c new file mode 100644 index 000000000..98ab9e166 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/pr57577.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +#define NUMBER 100 +int A[NUMBER], B[NUMBER][NUMBER]; +int foo (int a); + +int main () { + A[:] = foo (B[:][:]); /* { dg-error "rank mismatch between" } */ + A[0] = foo (B[:][:]); /* { dg-error "cannot be scalar when" } */ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch.c new file mode 100644 index 000000000..eb3c1f1d6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus -w" } */ + +/* We use -w because in the first error, there will be a warning of setting an + integer to a pointer. Just ignore it to expose the rank mismatch error. */ + +int main (void) +{ + int x = 0; + int array[10][10], array2[10]; + + array[:][:] = array[:]; /* { dg-error "rank mismatch between" } */ + /* { dg-error "invalid conversion" "" { target c++ } 12 } */ + + x = array2[:]; /* { dg-error "cannot be scalar when" } */ + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch2.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch2.c new file mode 100644 index 000000000..4a4882dba --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch2.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int function_call (int x); +int function_call (int x) +{ + return x; +} + +int main (void) +{ + int array[100], array2[100][100]; + int argc = 4; + array[:] = array[:] + array2[:][:]; /* { dg-error "rank mismatch between" } */ + + if (array[:] + array2[:][:]) /* { dg-error "rank mismatch between" } */ + return argc == 5; + + argc += function_call (array[:] + array2[5:10:2][:]); /* { dg-error "rank mismatch between" } */ + + argc += function_call (function_call (array[:] + array2[5:10:2][:])); /* { dg-error "rank mismatch between" } */ + + argc += __sec_reduce_add (array[:], array2[:][:]); /* { dg-error "rank mismatch between" } */ + + argc += __sec_reduce_add (array2[:][:]) + argc; /* This is OK. */ + return argc; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch3.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch3.c new file mode 100644 index 000000000..de335922f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/rank_mismatch3.c @@ -0,0 +1,19 @@ +/* { dg-options "-fcilkplus" } */ + +int funct (int x, int y); +void funct_void (int x, int y, int z); +int main(void) +{ + int y, array[100], array2[100], array3[100][100], array4[100]; + + array[:] = ((array2[:] + array[:]) * array4[:]) + array3[:][:]; /* { dg-error "rank mismatch between" } */ + array[:] = funct (array2[:], array3[:][:]); /* { dg-error "rank mismatch between" } */ + array[:] = array3[:][:]; /* { dg-error "rank mismatch between" } */ + array3[:][:] = array[:]; /* { dg-error "rank mismatch between" } */ + array3[:][:] = array[5]; /* This is OK! */ + funct_void (array2[:], array3[:][:], array[:]); /* { dg-error "rank mismatch between" } */ + funct_void (array2[:], array3[:][:], array[:]); /* { dg-error "rank mismatch between" } */ + funct_void (array3[:][:], array2[:], array[:]); /* { dg-error "rank mismatch between" } */ + funct_void (array2[:], array[:], array3[:][0:10:1]); /* { dg-error "rank mismatch between" } */ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit.c new file mode 100644 index 000000000..bacbf3505 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + int array[10][10], array2[10]; + + array[:][:] = __sec_implicit_index(5) + array[:][:]; /* { dg-error "__sec_implicit_index argument" } */ + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit2.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit2.c new file mode 100644 index 000000000..0aef0c29a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + int argc = 2; + int array[10][10], array2[10]; + __asm volatile ("" : "+r" (argc)); + array[:][:] = __sec_implicit_index(argc) + array[:][:]; /* { dg-error "__sec_implicit_index parameter" } */ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit_ex.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit_ex.c new file mode 100644 index 000000000..419799a3b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_implicit_ex.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#define NUMBER 20 + +int main(void) +{ + int jj, kk, array_3C[NUMBER][NUMBER][NUMBER]; + int ii,array[NUMBER], y = 0, y_int = 0, array2[NUMBER], + array_3[NUMBER][NUMBER][NUMBER]; + double x, yy, array3[NUMBER], array4[NUMBER]; + + array[:] = __sec_implicit_index (0); + array_3[:][:][:] = __sec_implicit_index (1) + __sec_implicit_index(0) + + __sec_implicit_index (2); + + for (ii = 0; ii < NUMBER; ii++) + for (jj = 0; jj < NUMBER; jj++) + for (kk = 0; kk < NUMBER; kk++) + array_3C[ii][jj][kk] = ii+jj+kk; + + for (ii = 0; ii < NUMBER; ii++) + for (jj = 0; jj < NUMBER; jj++) + for (kk = 0; kk < NUMBER; kk++) + if (array_3[ii][jj][kk] != array_3C[ii][jj][kk]) + return 1; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_ind_same_value.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_ind_same_value.c new file mode 100644 index 000000000..34c6f1284 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_ind_same_value.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +int A[256]; + +int main () { + A[:] = 2; + int max_index = 0, min_index = 0; + + max_index = __sec_reduce_max_ind (A[:]); + + if (max_index != 255) + return 1; + + min_index = __sec_reduce_min_ind (A[:]); + if (min_index != 255) + return 2; + + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_max_min_ind.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_max_min_ind.c new file mode 100644 index 000000000..9652e1594 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_max_min_ind.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main (void) +{ + int array[10][10], array2[10]; + int x, y; + x = __sec_reduce_max_ind (array[:][:]); /* { dg-error "cannot have arrays with dimension greater than" } */ + + y = __sec_reduce_max_ind (array2[:]); /* this should be OK. */ + + x = __sec_reduce_min_ind (array[:][:]); /* { dg-error "cannot have arrays with dimension greater than" } */ + + y = __sec_reduce_min_ind (array2[:]); /* this should be OK. */ + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_return.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_return.c new file mode 100644 index 000000000..034017146 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/sec_reduce_return.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +int add_all (int *my_array, int size) +{ + return __sec_reduce_add (my_array[0:size]); +} + +int mult_all (int *my_array, int size) +{ + return __sec_reduce_mul (my_array[0:size]); +} + +int main (void) +{ + int argc = 1; + int array[10000]; + + __asm volatile ("" : "+r" (argc)); + array[:] = argc; /* All elements should be one. */ + + if (add_all (array, 10000) != 10000) + return 1; + + if (mult_all (array, 10000) != 1) + return 2; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/side-effects-1.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/side-effects-1.c new file mode 100644 index 000000000..8b0034e72 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/side-effects-1.c @@ -0,0 +1,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; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/test_builtin_return.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/test_builtin_return.c new file mode 100644 index 000000000..b9f9f8d65 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/test_builtin_return.c @@ -0,0 +1,73 @@ +/* { dg-options "-lm -fcilkplus" } */ +/* { dg-do run } */ + +#if HAVE_IO +#include <stdio.h> +#endif +#include <math.h> +#define NUMBER 5 + +int func1 (int *a1, int *a2) +{ + return __sec_reduce_add (a1[0:NUMBER] * a2[0:NUMBER:1]); +} + +int func2 (int *a1, int *a2) +{ + return (__sec_reduce_add (a1[0:NUMBER] * a2[0:NUMBER]) + + __sec_reduce_mul (a1[0:NUMBER] + a2[0:NUMBER])); +} + +int func3 (int *a1, int *a2) +{ + return (int) sqrt ((double)(__sec_reduce_add (a1[0:NUMBER] * a2[0:NUMBER]) + + a2[0] + a2[1] + a2[3])); +} + +int func4 (int *a1, int *a2) +{ + return a1[NUMBER-1] * (__sec_reduce_add (a1[0:NUMBER] * a2[0:NUMBER]) + a2[0] + a2[1] + a2[3])/a1[NUMBER-2]; +} +int main(void) +{ + int array[NUMBER], array2[NUMBER]; + int return_value = 0; + int ii = 0; + int argc = 1; + __asm volatile ("" : "+r" (argc)); + for (ii = 0; ii < NUMBER; ii++) + { + array[ii] = argc; /* This should calculate to 1. */ + array2[ii] = argc * argc + argc; /* This should calculate to 2. */ + } + + return_value = func1 (array, array2); +#if HAVE_IO + printf("Return_value = %d\n", return_value); +#endif + if (return_value != (2+2+2+2+2)) + return 1; + + return_value = func2 (array2, array); +#if HAVE_IO + printf("Return_value = %d\n", return_value); +#endif + if (return_value != (3*3*3*3*3) + (2+2+2+2+2)) + return 2; + + return_value = func3 (array, array2); +#if HAVE_IO + printf("Return_value = %d\n", return_value); +#endif + if (return_value != 4) + return 3; + + return_value = func4 (array, array2); +#if HAVE_IO + printf("Return_value = %d\n", return_value); +#endif + if (return_value != 16) + return 4; + + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/test_sec_limits.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/test_sec_limits.c new file mode 100644 index 000000000..f4f3ca5a6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/test_sec_limits.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#include <limits.h> +int A[16]; +int a = 0; + +int main () { + if (__sec_reduce_max(A[0:0:2]) != INT_MIN) + a++; + + if (__sec_reduce_min(A[0:0:2]) != INT_MAX) + a++; + + return a; +} + + diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/tst_lngth.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/tst_lngth.c new file mode 100644 index 000000000..015a7eb73 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/tst_lngth.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options " -fcilkplus " } */ + +#if HAVE_IO +#include <stdio.h> +#endif + +#define N 256 +int A[N], B[N]; + +int +main () +{ + A[0:(N / 4)] = A[4]+ B[0:(N / 2):2]; /* { dg-error "length mismatch between" } */ + A[0:(N / 4)] = B[0:(N / 2):2] + N; /* { dg-error "length mismatch between" } */ + A[0:(N / 4)] = B[0:(N / 2):2] + A[4]; /* { dg-error "length mismatch between" } */ + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/vla.c b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/vla.c new file mode 100644 index 000000000..3b0777e0f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/AN/vla.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target c } } */ +/* { dg-options "-fcilkplus -std=c99 -w" } */ + +int func (int x) +{ + return x++; +} +int main(void) +{ + int argc = 1; + __asm volatile ("" : "+r" (argc)); + int array[argc]; + + array[:] = 5; /* { dg-error "start-index and length fields necessary for using array notations in variable-length arrays." } */ + array[0:argc] = 5; /* This is OK. */ + array[0:5:2] = 5; /* This is OK. */ + array[0:argc:2] = 5; /* This is OK. */ + array[0:argc:func (argc-2)] = 5; /* This is OK. */ + return 0; +} |