gcc/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-3.c
Jakub Jelinek 36c7a3fff9 omp-low.c (lower_omp_1): Look through ordered...
* omp-low.c (lower_omp_1) <case GIMPLE_ASSIGN>: Look through ordered,
	critical, taskgroup and section regions when looking for a region
	with non-NULL lastprivate_conditional_map.

	* testsuite/libgomp.c-c++-common/lastprivate-conditional-3.c: New test.

From-SVN: r271672
2019-05-27 23:31:40 +02:00

58 lines
1019 B
C

/* { dg-do run } */
/* { dg-require-effective-target tls_runtime } */
/* { dg-additional-options "-std=gnu99" {target c } } */
#include <omp.h>
#include <stdlib.h>
int r, s, u, v, t;
int *x;
void
foo (int *a)
{
int i;
long long j;
#pragma omp for lastprivate (conditional: u, x) ordered
for (i = 15; i < 64; i++)
{
#pragma omp critical
{
if ((a[i] % 5) == 3)
u = i;
}
#pragma omp ordered
{
if ((a[i] % 7) == 2)
x = &a[i];
}
}
#pragma omp for lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static) reduction (task, +: t)
for (i = -3; i < 119; i += 2)
{
++s;
#pragma omp taskgroup
{
#pragma omp task in_reduction (+: t)
++t;
if ((a[i + 4] % 11) == 9)
v = i;
else
++r;
}
}
}
int
main ()
{
int a[128], i;
for (i = 0; i < 128; i++)
a[i] = i;
#pragma omp parallel
foo (a);
if (u != 63 || v != 115 || x != &a[58] || r != 55 || s != 61 || t != 61)
abort ();
return 0;
}