aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-4.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-05-29 09:51:43 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-05-29 09:51:43 +0200
commit7e47198b802ed52fb8bb314b75ddf3cd84b2d9f4 (patch)
treee9533c1c58c656e54720467040cf9dc16c2c2968 /libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-4.c
parent357a352fe3a3a96b1a8c321f36a010e3798abdeb (diff)
downloadgcc-7e47198b802ed52fb8bb314b75ddf3cd84b2d9f4.zip
gcc-7e47198b802ed52fb8bb314b75ddf3cd84b2d9f4.tar.gz
gcc-7e47198b802ed52fb8bb314b75ddf3cd84b2d9f4.tar.bz2
gimplify.c (struct gimplify_omp_ctx): Add clauses member.
* gimplify.c (struct gimplify_omp_ctx): Add clauses member. (gimplify_scan_omp_clauses): Initialize ctx->clauses. (gimplify_adjust_omp_clauses_1): Transform lastprivate conditional explicit clause on combined parallel into implicit shared clause. (gimplify_adjust_omp_clauses): Move lastprivate conditional clause and firstprivate if the decl has one too from combined parallel to the worksharing construct. gcc/testsuite/ * c-c++-common/gomp/lastprivate-conditional-2.c (foo): Don't expect sorry on lastprivate conditional on parallel for. * c-c++-common/gomp/lastprivate-conditional-3.c (foo): Add tests for lastprivate conditional warnings on parallel for constructs. * c-c++-common/gomp/lastprivate-conditional-4.c: New test. libgomp/ * testsuite/libgomp.c-c++-common/lastprivate_conditional_4.c: Rename to ... * testsuite/libgomp.c-c++-common/lastprivate-conditional-4.c: ... this. * testsuite/libgomp.c-c++-common/lastprivate-conditional-5.c: New test. * testsuite/libgomp.c-c++-common/lastprivate-conditional-6.c: New test. From-SVN: r271733
Diffstat (limited to 'libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-4.c')
-rw-r--r--libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-4.c161
1 files changed, 161 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-4.c b/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-4.c
new file mode 100644
index 0000000..bc102a1
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-4.c
@@ -0,0 +1,161 @@
+#include <stdlib.h>
+
+int x;
+long long y;
+int r, s, t;
+
+void
+foo (const char *a)
+{
+ #pragma omp sections lastprivate (conditional: x, y)
+ {
+ if (a[0])
+ x = a[0];
+ #pragma omp section
+ {
+ if (a[1])
+ x = a[1];
+ if (a[2])
+ y = a[2];
+ }
+ #pragma omp section
+ if (a[3])
+ y = a[3];
+ #pragma omp section
+ if (a[4])
+ x = a[4];
+ #pragma omp section
+ {
+ if (a[5])
+ x = a[5];
+ if (a[6])
+ y = a[6];
+ }
+ }
+}
+
+void
+bar (const char *a)
+{
+ #pragma omp sections lastprivate (conditional: x, y) reduction (task, +: t)
+ {
+ if (a[0])
+ x = a[0];
+ #pragma omp section
+ {
+ if (a[1])
+ x = a[1];
+ if (a[2])
+ y = a[2];
+ #pragma omp task in_reduction (+: t)
+ t++;
+ }
+ #pragma omp section
+ if (a[3])
+ y = a[3];
+ #pragma omp section
+ if (a[4])
+ x = a[4];
+ #pragma omp section
+ {
+ #pragma omp task in_reduction (+: t)
+ ++t;
+ if (a[5])
+ x = a[5];
+ if (a[6])
+ y = a[6];
+ }
+ }
+}
+
+void
+baz (const char *a)
+{
+ #pragma omp sections lastprivate (conditional: x, y) reduction (+: r, s)
+ {
+ if (a[0])
+ x = a[0];
+ #pragma omp section
+ {
+ if (a[1])
+ x = a[1];
+ ++r;
+ ++s;
+ if (a[2])
+ y = a[2];
+ }
+ #pragma omp section
+ if (a[3])
+ y = a[3];
+ #pragma omp section
+ {
+ ++s;
+ if (a[4])
+ x = a[4];
+ }
+ #pragma omp section
+ {
+ if (a[5])
+ x = a[5];
+ if (a[6])
+ y = a[6];
+ ++s;
+ }
+ }
+}
+
+int
+main ()
+{
+ #pragma omp parallel
+ {
+ foo ("\0\1\2\3\0\5");
+ if (x != 5 || y != 3)
+ abort ();
+ #pragma omp barrier
+ foo ("\6\0\0\0\0\0\7");
+ if (x != 6 || y != 7)
+ abort ();
+ #pragma omp barrier
+ foo ("\7\6\5\4\3\2\1");
+ if (x != 2 || y != 1)
+ abort ();
+ #pragma omp barrier
+ foo ("\0\0\4\3\0\7");
+ if (x != 7 || y != 3)
+ abort ();
+ #pragma omp barrier
+ bar ("\0\1\2\4\0\5");
+ if (x != 5 || y != 4 || t != 2)
+ abort ();
+ #pragma omp barrier
+ bar ("\6\0\0\0\0\0\7");
+ if (x != 6 || y != 7 || t != 4)
+ abort ();
+ #pragma omp barrier
+ bar ("\7\6\5\4\3\2\1");
+ if (x != 2 || y != 1 || t != 6)
+ abort ();
+ #pragma omp barrier
+ bar ("\0\0\4\3\0\7");
+ if (x != 7 || y != 3 || t != 8)
+ abort ();
+ #pragma omp barrier
+ baz ("\0\1\2\4\0\5");
+ if (x != 5 || y != 4 || r != 1 || s != 3)
+ abort ();
+ #pragma omp barrier
+ baz ("\6\0\0\0\0\0\7");
+ if (x != 6 || y != 7 || r != 2 || s != 6)
+ abort ();
+ #pragma omp barrier
+ baz ("\7\6\5\4\3\2\1");
+ if (x != 2 || y != 1 || r != 3 || s != 9)
+ abort ();
+ #pragma omp barrier
+ baz ("\0\0\4\3\0\7");
+ if (x != 7 || y != 3 || r != 4 || s != 12)
+ abort ();
+ }
+ return 0;
+}