summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/for-7.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libgomp/testsuite/libgomp.c++/for-7.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libgomp/testsuite/libgomp.c++/for-7.C')
-rw-r--r--libgomp/testsuite/libgomp.c++/for-7.C110
1 files changed, 110 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c++/for-7.C b/libgomp/testsuite/libgomp.c++/for-7.C
new file mode 100644
index 000000000..9d626c028
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/for-7.C
@@ -0,0 +1,110 @@
+// PR c++/
+// { dg-do run }
+// { dg-options "-std=c++0x -fopenmp" }
+
+extern "C" void abort ();
+int cnt;
+
+template <typename T>
+void
+f0 (T, int)
+{
+ abort ();
+}
+
+template <>
+void
+f0<int> (int, int type)
+{
+ if (type != 0)
+ abort ();
+#pragma omp atomic
+ cnt++;
+}
+
+template <>
+void
+f0<const char *> (const char *, int type)
+{
+ if (type != 1)
+ abort ();
+#pragma omp atomic
+ cnt++;
+}
+
+template <typename T>
+void
+f1 ()
+{
+#pragma omp parallel for
+ for (auto i = 0; i < 10; i++)
+ f0 (i, 0);
+}
+
+template <typename T>
+void
+f2 ()
+{
+#pragma omp parallel for
+ for (auto i = T (0); i < T (10); i += T (1))
+ f0 (i, 0);
+}
+
+void
+f3 ()
+{
+#pragma omp parallel for
+ for (auto i = 0; i < 10; i++)
+ f0 (i, 0);
+}
+
+const char *p = "abcdefghij";
+
+template <typename T>
+void
+f4 ()
+{
+#pragma omp parallel for
+ for (auto i = p; i < p + 10; i++)
+ f0 (i, 1);
+}
+
+template <typename T>
+void
+f5 ()
+{
+#pragma omp parallel for
+ for (auto i = T (p); i < T (p + 10); i++)
+ f0 (i, 1);
+}
+
+void
+f6 ()
+{
+#pragma omp parallel for
+ for (auto i = p; i < p + 10; i++)
+ f0 (i, 1);
+}
+
+int
+main ()
+{
+ f1<int> ();
+ if (cnt != 10)
+ abort ();
+ f2<int> ();
+ if (cnt != 20)
+ abort ();
+ f3 ();
+ if (cnt != 30)
+ abort ();
+ f4<int> ();
+ if (cnt != 40)
+ abort ();
+ f5<const char *> ();
+ if (cnt != 50)
+ abort ();
+ f6 ();
+ if (cnt != 60)
+ abort ();
+}