Introduce libgomp/testsuite/libgomp.c-c++-common
authorTom de Vries <tom@codesourcery.com>
Thu, 14 Sep 2017 21:15:40 +0000 (21:15 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Thu, 14 Sep 2017 21:15:40 +0000 (21:15 +0000)
2017-09-14  Tom de Vries  <tom@codesourcery.com>

* testsuite/libgomp.c++/cancel-taskgroup-1.C: Remove.
* testsuite/libgomp.c/cancel-taskgroup-1.c: Move to ...
* testsuite/libgomp.c-c++-common/cancel-taskgroup-1.c: ... here.
* testsuite/libgomp.c/c.exp: Include test-cases from
libgomp.c-c++-common.
* testsuite/libgomp.c++/c++.exp: Same.  Force c++-mode compilation of .c
files.

From-SVN: r252775

libgomp/ChangeLog
libgomp/testsuite/libgomp.c++/c++.exp
libgomp/testsuite/libgomp.c++/cancel-taskgroup-1.C [deleted file]
libgomp/testsuite/libgomp.c-c++-common/cancel-taskgroup-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/c.exp
libgomp/testsuite/libgomp.c/cancel-taskgroup-1.c [deleted file]

index 459dcffa5701321e873b6bbf5a2c9fbe2b21aa97..9fafd622b60311de75c0feefc42fc162a3d2600f 100644 (file)
@@ -1,3 +1,13 @@
+2017-09-14  Tom de Vries  <tom@codesourcery.com>
+
+       * testsuite/libgomp.c++/cancel-taskgroup-1.C: Remove.
+       * testsuite/libgomp.c/cancel-taskgroup-1.c: Move to ...
+       * testsuite/libgomp.c-c++-common/cancel-taskgroup-1.c: ... here.
+       * testsuite/libgomp.c/c.exp: Include test-cases from
+       libgomp.c-c++-common.
+       * testsuite/libgomp.c++/c++.exp: Same.  Force c++-mode compilation of .c
+       files.
+
 2017-09-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/81314
index 0454f95588ec50825ac1bb1ac9ffcffc4d6c05f9..f4884e2ffa7a85932fc769cd90357da4040d522f 100644 (file)
@@ -22,6 +22,11 @@ dg-init
 # Turn on OpenMP.
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
+# Switch into C++ mode.  Otherwise, the libgomp.c-c++-common/*.c
+# files would be compiled as C files.
+set SAVE_GCC_UNDER_TEST "$GCC_UNDER_TEST"
+set GCC_UNDER_TEST "$GCC_UNDER_TEST -x c++"
+
 set blddir [lookfor_file [get_multilibs] libgomp]
 
 
@@ -47,7 +52,9 @@ if { $blddir != "" } {
 
 if { $lang_test_file_found } {
     # Gather a list of all tests.
-    set tests [lsort [find $srcdir/$subdir *.C]]
+    set tests [lsort [concat \
+                         [find $srcdir/$subdir *.C] \
+                         [find $srcdir/$subdir/../libgomp.c-c++-common *.c]]]
 
     if { $blddir != "" } {
         set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
@@ -68,5 +75,8 @@ if { $lang_test_file_found } {
     dg-runtest $tests "" "$libstdcxx_includes $DEFAULT_CFLAGS"
 }
 
+# See above.
+set GCC_UNDER_TEST "$SAVE_GCC_UNDER_TEST"
+
 # All done.
 dg-finish
diff --git a/libgomp/testsuite/libgomp.c++/cancel-taskgroup-1.C b/libgomp/testsuite/libgomp.c++/cancel-taskgroup-1.C
deleted file mode 100644 (file)
index 4f66859..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-// { dg-do run }
-// { dg-set-target-env-var OMP_CANCELLATION "true" }
-
-#include "../libgomp.c/cancel-taskgroup-1.c"
diff --git a/libgomp/testsuite/libgomp.c-c++-common/cancel-taskgroup-1.c b/libgomp/testsuite/libgomp.c-c++-common/cancel-taskgroup-1.c
new file mode 100644 (file)
index 0000000..5a80811
--- /dev/null
@@ -0,0 +1,70 @@
+/* { dg-do run } */
+/* { dg-set-target-env-var OMP_CANCELLATION "true" } */
+
+#include <stdlib.h>
+#include <omp.h>
+
+struct T { struct T *children[2]; int val; };
+
+struct T *
+search (struct T *tree, int val, int lvl)
+{
+  if (tree == NULL || tree->val == val)
+    return tree;
+  struct T *ret = NULL;
+  int i;
+  for (i = 0; i < 2; i++)
+    #pragma omp task shared(ret) if(lvl < 10)
+    {
+      struct T *r = search (tree->children[i], val, lvl + 1);
+      if (r)
+       {
+         #pragma omp atomic write
+         ret = r;
+         #pragma omp cancel taskgroup
+       }
+    }
+  #pragma omp taskwait
+  return ret;
+}
+
+struct T *
+searchp (struct T *tree, int val)
+{
+  struct T *ret;
+  #pragma omp parallel shared(ret) firstprivate (tree, val)
+  #pragma omp single
+  #pragma omp taskgroup
+  ret = search (tree, val, 0);
+  return ret;
+}
+
+int
+main ()
+{
+  /* Must be power of two minus 1.  */
+  int size = 0x7ffff;
+  struct T *trees = (struct T *) malloc (size * sizeof (struct T));
+  if (trees == NULL)
+    return 0;
+  int i, l = 1, b = 0;
+  for (i = 0; i < size; i++)
+    {
+      if (i == l)
+       {
+         b = l;
+         l = l * 2 + 1;
+       }
+      trees[i].val = i;
+      trees[i].children[0] = l == size ? NULL : &trees[l + (i - b) * 2];
+      trees[i].children[1] = l == size ? NULL : &trees[l + (i - b) * 2 + 1];
+    }
+  for (i = 0; i < 50; i++)
+    {
+      int v = random () & size;
+      if (searchp (&trees[0], v) != &trees[v])
+       abort ();
+    }
+  free (trees);
+  return 0;
+}
index 300b9211f6de36b9a77f98c9e780cdb190057495..31bdd5795dc27cb159fd74700b277a8d69311c30 100644 (file)
@@ -24,7 +24,9 @@ dg-init
 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
 
 # Gather a list of all tests.
-set tests [lsort [find $srcdir/$subdir *.c]]
+set tests [lsort [concat \
+                     [find $srcdir/$subdir *.c] \
+                     [find $srcdir/$subdir/../libgomp.c-c++-common *.c]]]
 
 set ld_library_path $always_ld_library_path
 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
diff --git a/libgomp/testsuite/libgomp.c/cancel-taskgroup-1.c b/libgomp/testsuite/libgomp.c/cancel-taskgroup-1.c
deleted file mode 100644 (file)
index 5a80811..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* { dg-do run } */
-/* { dg-set-target-env-var OMP_CANCELLATION "true" } */
-
-#include <stdlib.h>
-#include <omp.h>
-
-struct T { struct T *children[2]; int val; };
-
-struct T *
-search (struct T *tree, int val, int lvl)
-{
-  if (tree == NULL || tree->val == val)
-    return tree;
-  struct T *ret = NULL;
-  int i;
-  for (i = 0; i < 2; i++)
-    #pragma omp task shared(ret) if(lvl < 10)
-    {
-      struct T *r = search (tree->children[i], val, lvl + 1);
-      if (r)
-       {
-         #pragma omp atomic write
-         ret = r;
-         #pragma omp cancel taskgroup
-       }
-    }
-  #pragma omp taskwait
-  return ret;
-}
-
-struct T *
-searchp (struct T *tree, int val)
-{
-  struct T *ret;
-  #pragma omp parallel shared(ret) firstprivate (tree, val)
-  #pragma omp single
-  #pragma omp taskgroup
-  ret = search (tree, val, 0);
-  return ret;
-}
-
-int
-main ()
-{
-  /* Must be power of two minus 1.  */
-  int size = 0x7ffff;
-  struct T *trees = (struct T *) malloc (size * sizeof (struct T));
-  if (trees == NULL)
-    return 0;
-  int i, l = 1, b = 0;
-  for (i = 0; i < size; i++)
-    {
-      if (i == l)
-       {
-         b = l;
-         l = l * 2 + 1;
-       }
-      trees[i].val = i;
-      trees[i].children[0] = l == size ? NULL : &trees[l + (i - b) * 2];
-      trees[i].children[1] = l == size ? NULL : &trees[l + (i - b) * 2 + 1];
-    }
-  for (i = 0; i < 50; i++)
-    {
-      int v = random () & size;
-      if (searchp (&trees[0], v) != &trees[v])
-       abort ();
-    }
-  free (trees);
-  return 0;
-}