gcc/libgomp/testsuite/libgomp.c/pr39591-3.c
Jakub Jelinek 03742a9b01 re PR other/39591 (GOMP_loop_end illegally optmized into GOMP_loop_end_nowait)
PR other/39591
	* omp-low.c (remove_exit_barrier): Don't optimize if there are any
	addressable variables in the parallel that could go out of scope while
	running queued tasks.

	* testsuite/libgomp.c/pr39591-1.c: New test.
	* testsuite/libgomp.c/pr39591-2.c: New test.
	* testsuite/libgomp.c/pr39591-3.c: New test.

From-SVN: r145390
2009-04-01 08:54:52 +02:00

41 lines
577 B
C

/* PR other/39591 */
/* { dg-do run } */
/* { dg-options "-O2" } */
extern void abort (void);
int err, a[40];
void __attribute__((noinline))
foo (int *array)
{
#pragma omp task
{
int j;
for (j = 0; j < sizeof array / sizeof array[0]; j++)
if (array[j] != 0x55555555)
#pragma omp atomic
err++;
}
}
int
main (void)
{
int k;
for (k = 0; k < sizeof a / sizeof a[0]; k++)
a[k] = 0x55555555;
#pragma omp parallel
{
int i;
#pragma omp for schedule (dynamic)
for (i = 0; i < 50; i++)
foo (a);
}
if (err)
abort ();
return 0;
}