summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog22
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/compound_cilk_spawn.c26
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/concec_cilk_spawn.c20
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/fib.c61
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/fib_init_expr_xy.c60
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_return.c65
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_sync.c59
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_spawns.c11
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/no_args_error.c11
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/spawn_in_return.c8
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/spawnee_inline.c80
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/spawner_inline.c67
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c37
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c43
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/sync_wo_spawn.c9
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/test__cilk.c10
-rw-r--r--gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c47
-rw-r--r--gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp32
18 files changed, 668 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 357939e9dd4..621b951bfa3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,25 @@
+2013-10-29 Balaji V. Iyer <balaji.v.iyer@intel.com>
+
+ * c-c++-common/cilk-plus/CK/compound_cilk_spawn.c: New test.
+ * c-c++-common/cilk-plus/CK/concec_cilk_spawn.c: Likewise.
+ * c-c++-common/cilk-plus/CK/fib.c: Likewise.
+ * c-c++-common/cilk-plus/CK/no_args_error.c: Likewise.
+ * c-c++-common/cilk-plus/CK/spawnee_inline.c: Likewise.
+ * c-c++-common/cilk-plus/CK/spawner_inline.c: Likewise.
+ * c-c++-common/cilk-plus/CK/spawning_arg.c: Likewise.
+ * c-c++-common/cilk-plus/CK/steal_check.c: Likewise.
+ * c-c++-common/cilk-plus/CK/test__cilk.c: Likewise.
+ * c-c++-common/cilk-plus/CK/varargs_test.c: Likewise.
+ * c-c++-common/cilk-plus/CK/sync_wo_spawn.c: Likewise.
+ * c-c++-common/cilk-plus/CK/invalid_spawn.c: Likewise.
+ * c-c++-common/cilk-plus/CK/spawn_in_return.c: Likewise.
+ * c-c++-common/cilk-plus/CK/fib_init_expr_xy.c: Likewise.
+ * c-c++-common/cilk-plus/CK/fib_no_sync.c: Likewise.
+ * c-c++-common/cilk-plus/CK/fib_no_return.c: Likewise.
+ * gcc.dg/cilk-plus/cilk-plus.exp: Added support to run Cilk Keywords
+ test stored in c-c++-common. Also, added the Cilk runtime's library
+ to the ld_library_path.
+
2013-10-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58888
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/compound_cilk_spawn.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/compound_cilk_spawn.c
new file mode 100644
index 00000000000..5e687bd0a0c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/compound_cilk_spawn.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+/* <feature>
+ A program is considered ill formed if the _Cilk_spawn form of this
+ expression appears other than in one of the following contexts:
+ as the entire body of an expression statement,
+ as the entire right hand side of an assignment expression that is the entire
+ body of an expression statement, or as the entire initializer-clause in a
+ simple declaration.
+ </feature>
+*/
+
+int spawn_func (int arg)
+{
+ return arg + 1;
+}
+
+int check()
+{
+ int z;
+ z = 23, _Cilk_spawn spawn_func (3), 3424; /* { dg-error "spawned function call cannot be part of a comma expression" } */
+ 23, spawn_func (5), _Cilk_spawn spawn_func (3); /* { dg-error "spawned function call cannot be part of a comma expression" } */
+ _Cilk_spawn spawn_func (0), _Cilk_spawn spawn_func (3), 3, spawn_func (0); /* { dg-error "spawned function call cannot be part of a comma expression" } */
+ return 23;
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/concec_cilk_spawn.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/concec_cilk_spawn.c
new file mode 100644
index 00000000000..b93c9626d18
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/concec_cilk_spawn.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+/* <feature> Consecutive _Cilk_spawn tokens are not permitted
+ </feature>
+*/
+
+int spawn_func (int arg)
+{
+ return arg + 1;
+}
+
+void func ()
+{
+ int a;
+ a = _Cilk_spawn _Cilk_spawn spawn_func (4); /* { dg-error "consecutive" } */
+ a = _Cilk_spawn _Cilk_spawn _Cilk_spawn spawn_func (4); /* { dg-error "consecutive" } */
+ a = _Cilk_spawn _Cilk_spawn _Cilk_spawn _Cilk_spawn spawn_func (4); /* { dg-error "consecutive" } */
+ return;
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib.c
new file mode 100644
index 00000000000..6612936a05c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib.c
@@ -0,0 +1,61 @@
+/* { dg-options "-fcilkplus" } */
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#if HAVE_IO
+#include <stdio.h>
+#endif
+
+int fib (int);
+int fib_serial (int);
+
+int main(void)
+{
+ int ii = 0, error = 0;
+ int fib_result[41], fib_serial_result[41];
+#if HAVE_IO
+
+ for (ii = 0; ii <= 40; ii++)
+ printf("fib (%2d) = %10d\n", ii, fib (ii));
+#else
+ for (ii = 0; ii <= 40; ii++)
+ {
+ fib_result[ii] = fib (ii);
+ fib_serial_result[ii] = fib_serial (ii);
+ }
+
+ for (ii = 0; ii <= 40; ii++)
+ {
+ if (fib_result[ii] != fib_serial_result[ii])
+ error = 1;
+ }
+#endif
+ return error;
+}
+
+int fib_serial (int n)
+{
+ int x = 0, y = 0;
+ if (n < 2)
+ return n;
+ else
+ {
+ x = fib (n-1);
+ y = fib (n-2);
+ return (x+y);
+ }
+}
+
+int fib(int n)
+{
+ int x = 0, y = 0;
+ if (n < 2)
+ return n;
+ else
+ {
+ x = _Cilk_spawn fib(n-1);
+ y = fib(n-2);
+ _Cilk_sync;
+ return (x+y);
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_init_expr_xy.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_init_expr_xy.c
new file mode 100644
index 00000000000..6b09918a420
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_init_expr_xy.c
@@ -0,0 +1,60 @@
+/* { dg-options "-fcilkplus" } */
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#if HAVE_IO
+#include <stdio.h>
+#endif
+
+int fib (int);
+int fib_serial (int);
+
+int main(void)
+{
+ int ii = 0, error = 0;
+ int fib_result[41], fib_serial_result[41];
+#if HAVE_IO
+
+ for (ii = 0; ii <= 40; ii++)
+ printf("fib (%2d) = %10d\n", ii, fib (ii));
+#else
+ for (ii = 0; ii <= 40; ii++)
+ {
+ fib_result[ii] = fib (ii);
+ fib_serial_result[ii] = fib_serial (ii);
+ }
+
+ for (ii = 0; ii <= 40; ii++)
+ {
+ if (fib_result[ii] != fib_serial_result[ii])
+ error = 1;
+ }
+#endif
+ return error;
+}
+
+int fib_serial (int n)
+{
+ int x = 0, y = 0;
+ if (n < 2)
+ return n;
+ else
+ {
+ x = fib (n-1);
+ y = fib (n-2);
+ return (x+y);
+ }
+}
+
+int fib(int n)
+{
+ if (n < 2)
+ return n;
+ else
+ {
+ int x = _Cilk_spawn fib(n-1);
+ int y = fib(n-2);
+ _Cilk_sync;
+ return (x+y);
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_return.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_return.c
new file mode 100644
index 00000000000..2adf3a2f6e1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_return.c
@@ -0,0 +1,65 @@
+/* { dg-options "-fcilkplus" } */
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#if HAVE_IO
+#include <stdio.h>
+#endif
+
+void fib (int *, int);
+int fib_serial (int);
+
+int main(void)
+{
+ int ii = 0, error = 0;
+ int fib_result[41], fib_serial_result[41];
+
+#if HAVE_IO
+ for (ii = 0; ii <= 40; ii++)
+ {
+ int result = 0;
+ fib (&result, ii);
+ printf("fib (%2d) = %10d\n", ii, result);
+ }
+#else
+ for (ii = 0; ii <= 40; ii++)
+ {
+ fib (&fib_result[ii], ii);
+ fib_serial_result[ii] = fib_serial (ii);
+ }
+
+ for (ii = 0; ii <= 40; ii++)
+ {
+ if (fib_result[ii] != fib_serial_result[ii])
+ error = 1;
+ }
+#endif
+ return error;
+}
+
+int fib_serial (int n)
+{
+ int x = 0, y = 0;
+ if (n < 2)
+ return n;
+ else
+ {
+ fib (&x, n-1);
+ fib (&y, n-2);
+ return (x+y);
+ }
+}
+
+void fib(int *result, int n)
+{
+ int x = 0, y = 0;
+ if (n < 2)
+ x = n;
+ else
+ {
+ _Cilk_spawn fib(&x, n-1);
+ fib(&y, n-2);
+ _Cilk_sync;
+ }
+ *result = (x+y);
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_sync.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_sync.c
new file mode 100644
index 00000000000..9de70be7584
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/fib_no_sync.c
@@ -0,0 +1,59 @@
+/* { dg-options "-fcilkplus" } */
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#if HAVE_IO
+#include <stdio.h>
+#endif
+
+int fib (int);
+int fib_serial (int);
+
+int main(void)
+{
+ int ii = 0, error = 0;
+ int fib_result[41], fib_serial_result[41];
+#if HAVE_IO
+
+ for (ii = 0; ii <= 40; ii++)
+ printf("fib (%2d) = %10d\n", ii, fib (ii));
+#else
+ for (ii = 0; ii <= 40; ii++)
+ {
+ fib_result[ii] = fib (ii);
+ fib_serial_result[ii] = fib_serial (ii);
+ }
+
+ for (ii = 0; ii <= 40; ii++)
+ {
+ if (fib_result[ii] != fib_serial_result[ii])
+ error = 1;
+ }
+#endif
+ return error;
+}
+
+int fib_serial (int n)
+{
+ int x = 0, y = 0;
+ if (n < 2)
+ return n;
+ else
+ {
+ x = fib (n-1);
+ y = fib (n-2);
+ return (x+y);
+ }
+}
+
+int fib(int n)
+{
+ if (n < 2)
+ return n;
+ else
+ {
+ int x = _Cilk_spawn fib(n-1);
+ int y = fib(n-2);
+ return (x+y);
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_spawns.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_spawns.c
new file mode 100644
index 00000000000..90dd5c130b4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_spawns.c
@@ -0,0 +1,11 @@
+extern int foo ();
+int bar = _Cilk_spawn foo (); /* { dg-error "may only be used inside a function" } */
+
+
+int main (void)
+{
+ int x;
+
+ _Cilk_spawn x; /* { dg-error "only function calls can be spawned" } */
+ return x;
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/no_args_error.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/no_args_error.c
new file mode 100644
index 00000000000..593732ef5ab
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/no_args_error.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+int spawn_1 ();
+typedef int(*func) (int);
+
+void check () {
+ func var = spawn_1; /* { dg-error "invalid conversion from" "" { target c++ } 8 } */
+ _Cilk_spawn var (); /* { dg-error "too few arguments to function" } */
+}
+
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/spawn_in_return.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawn_in_return.c
new file mode 100644
index 00000000000..14b7eef1276
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawn_in_return.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+int main (void)
+{
+ extern int foo ();
+ return _Cilk_spawn foo (); /* { dg-error "return statement is not allowed" } */
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/spawnee_inline.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawnee_inline.c
new file mode 100644
index 00000000000..8060c6ceb15
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawnee_inline.c
@@ -0,0 +1,80 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus -w" } */
+/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#include <stdio.h>
+#include <stdlib.h>
+#define DEFAULT_VALUE "30"
+
+int fib (char *n_char)
+{
+ int n;
+ char n_char_minus_one[20], n_char_minus_two[20];
+ if (n_char)
+ n = atoi (n_char);
+ else
+ n = atoi(DEFAULT_VALUE);
+
+ if (n < 2)
+ return n;
+ else
+ {
+ int x, y;
+ sprintf (n_char_minus_one,"%d", n-1);
+ sprintf (n_char_minus_two,"%d", n-2);
+ x = _Cilk_spawn fib (n_char_minus_one);
+ y = _Cilk_spawn fib (n_char_minus_two);
+ _Cilk_sync;
+ return (x+y);
+ }
+}
+
+int fib_serial (int n)
+{
+ int x, y;
+ if (n < 2)
+ return n;
+ else
+ {
+ x = fib_serial (n-1);
+ y = fib_serial (n-2);
+ return (x+y);
+ }
+ return 0;
+}
+
+int main2_parallel (int argc, char *argv[])
+{
+ int n, result_parallel = 0;
+
+ if (argc == 2)
+ {
+ result_parallel = _Cilk_spawn fib (argv[1]);
+ _Cilk_sync;
+ }
+ else
+ {
+ result_parallel = _Cilk_spawn fib((char *)"30");
+ _Cilk_sync;
+ }
+ return result_parallel;
+}
+
+int main2_serial (int argc, char *argv[])
+{
+ int n, result_serial = 0;
+ if (argc == 2)
+ result_serial = fib_serial (atoi (argv[1]));
+ else
+ result_serial = fib_serial (atoi (DEFAULT_VALUE));
+
+ return result_serial;
+}
+
+int main (void)
+{
+ if (main2_serial (1, 0) != main2_parallel (1,0))
+ return 1;
+ return 0;
+}
+
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/spawner_inline.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawner_inline.c
new file mode 100644
index 00000000000..eab9e4206a0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawner_inline.c
@@ -0,0 +1,67 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus" } */
+/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#include <stdlib.h>
+#define DEFAULT_VALUE 30
+int fib (int n)
+{
+ if (n<2)
+ return n;
+ else
+ {
+ int x, y;
+ x = _Cilk_spawn fib (n-1);
+ y = _Cilk_spawn fib (n-2);
+ _Cilk_sync;
+ return (x+y);
+ return 5;
+ }
+}
+
+int main_parallel (int argc, char *argv[])
+{
+ int n, result;
+ if (argc == 2)
+ n = atoi(argv[1]);
+ else
+ n = DEFAULT_VALUE;
+ result = _Cilk_spawn fib(n);
+ _Cilk_sync;
+ return result;
+}
+
+int fib_serial (int n)
+{
+ int x, y;
+ if (n < 2)
+ return n;
+ else
+ {
+ x = fib (n-1);
+ y = fib (n-2);
+ return (x+y);
+ }
+}
+
+int main_serial (int argc, char *argv[])
+{
+ int n, result;
+
+ if (argc == 2)
+ n = atoi (argv[1]);
+ else
+ n = DEFAULT_VALUE;
+ result = fib_serial (n);
+
+ return result;
+}
+
+int main (void)
+{
+ if (main_serial (1, 0) != main_parallel (1,0))
+ return 1;
+ else
+ return 0;
+}
+
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c
new file mode 100644
index 00000000000..ac379528379
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c
@@ -0,0 +1,37 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus" } */
+/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+void f0(volatile int *steal_flag)
+{
+ int i = 0;
+ /* Wait for steal_flag to be set */
+ while (!*steal_flag)
+ ;
+}
+
+int f1()
+{
+
+ volatile int steal_flag = 0;
+ _Cilk_spawn f0(&steal_flag);
+ steal_flag = 1; // Indicate stolen
+ _Cilk_sync;
+ return 0;
+}
+
+void f2(int q)
+{
+ q = 5;
+}
+
+void f3()
+{
+ _Cilk_spawn f2(f1());
+}
+
+int main()
+{
+ f3();
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c
new file mode 100644
index 00000000000..21d6797857d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c
@@ -0,0 +1,43 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus" } */
+/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+// #include <cilk/cilk_api.h>
+extern void __cilkrts_set_param (char *, char *);
+
+void foo(volatile int *);
+
+void main2(void);
+
+int main(void)
+{
+ // __cilkrts_set_param ((char *)"nworkers", (char *)"2");
+ main2();
+ return 0;
+}
+
+
+void main2(void)
+{
+ int some_var = 0;
+
+ _Cilk_spawn foo(&some_var);
+
+ some_var=1;
+ some_var=5;
+ some_var=3;
+ some_var=4;
+
+ _Cilk_sync;
+ return;
+}
+
+void foo(volatile int *some_other_var)
+{
+ while (*some_other_var == 0)
+ {
+ ;
+ }
+}
+
+
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/sync_wo_spawn.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/sync_wo_spawn.c
new file mode 100644
index 00000000000..51be796e562
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/sync_wo_spawn.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+int main (void)
+{
+ _Cilk_sync; /* { dg-error "expected '_Cilk_spawn' before '_Cilk_sync'" } */
+ return 0;
+}
+
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/test__cilk.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/test__cilk.c
new file mode 100644
index 00000000000..2b37cd664c1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/test__cilk.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus" } */
+
+int main (void)
+{
+ if (__cilk == 200)
+ return 0;
+ return 1;
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c
new file mode 100644
index 00000000000..ab5d63a3f4c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c
@@ -0,0 +1,47 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus" } */
+/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+
+double compute_total (int no_elements, ...);
+
+int main(void)
+{
+ double array[5] = {5.0, 4.0, 9.0, 3.0, 4.0};
+ double array2[5] = {5.0, 6.0, 8.0, 6.0};
+ double yy=0, xx=0, xx_serial, yy_serial;
+
+ yy = _Cilk_spawn compute_total(5,array[0],array[1],array[2],
+ array[3], array[4]);
+ xx= compute_total(4,array2[0],array2[1],array2[2], array2[3]);
+
+ _Cilk_sync;
+
+ yy_serial = compute_total(5,array[0],array[1],array[2], array[3], array[4]);
+ xx_serial = compute_total(4,array2[0],array2[1],array2[2], array2[3]);
+
+ if ((xx + yy) != (xx_serial + yy_serial))
+ return 1;
+ return 0;
+
+}
+
+
+double compute_total (int no_elements, ...)
+{
+ double total = 0;
+ va_list args;
+ va_start(args, no_elements);
+ int ii = 0;
+ for (ii = 0; ii < no_elements; ii++)
+ {
+ total += va_arg(args,double);
+ }
+ va_end(args);
+
+ return total;
+}
+
diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp b/gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp
index 2533febc8ab..a8f00d493ee 100644
--- a/gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp
+++ b/gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp
@@ -23,6 +23,11 @@ if { ![check_effective_target_cilkplus] } {
return;
}
+verbose "$tool $libdir" 1
+set library_var [get_multilibs]
+# Pointing the ld_library_path to the Cilk Runtime library binaries.
+set ld_library_path "${library_var}/libcilkrts/.libs"
+
dg-init
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus" " "
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O0 -fcilkplus" " "
@@ -46,4 +51,31 @@ dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -f
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -g -O2 -ftree-vectorize -std=c99" " "
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -g -O3 -std=c99" " "
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -O3 -ftree-vectorize -std=c99 -g -fcilkplus" " "
+
+
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O0 -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O1 -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -ftree-vectorize -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O0 -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O1 -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O2 -ftree-vectorize -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O3 -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -ftree-vectorize -fcilkplus -g" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -O0 -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -O1 -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -O2 -ftree-vectorize -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -O3 -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -g -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -g -O0 -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -g -O1 -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -g -O2 -ftree-vectorize -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus -g -O3 -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -ftree-vectorize -std=c99 -g -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O0 -flto -g -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -flto -g -fcilkplus" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -flto -g -fcilkplus" " "
dg-finish