gcc/libgomp/testsuite/libgomp.c-c++-common/imperfect5.c
Sandra Loosemore 410df0843d OpenMP: New C/C++ testcases for imperfectly nested loops.
gcc/testsuite/ChangeLog
	* c-c++-common/gomp/imperfect-attributes.c: New.
	* c-c++-common/gomp/imperfect-badloops.c: New.
	* c-c++-common/gomp/imperfect-blocks.c: New.
	* c-c++-common/gomp/imperfect-extension.c: New.
	* c-c++-common/gomp/imperfect-gotos.c: New.
	* c-c++-common/gomp/imperfect-invalid-scope.c: New.
	* c-c++-common/gomp/imperfect-labels.c: New.
	* c-c++-common/gomp/imperfect-legacy-syntax.c: New.
	* c-c++-common/gomp/imperfect-pragmas.c: New.
	* c-c++-common/gomp/imperfect1.c: New.
	* c-c++-common/gomp/imperfect2.c: New.
	* c-c++-common/gomp/imperfect3.c: New.
	* c-c++-common/gomp/imperfect4.c: New.
	* c-c++-common/gomp/imperfect5.c: New.

libgomp/ChangeLog
	* testsuite/libgomp.c-c++-common/imperfect1.c: New.
	* testsuite/libgomp.c-c++-common/imperfect2.c: New.
	* testsuite/libgomp.c-c++-common/imperfect3.c: New.
	* testsuite/libgomp.c-c++-common/imperfect4.c: New.
	* testsuite/libgomp.c-c++-common/imperfect5.c: New.
	* testsuite/libgomp.c-c++-common/imperfect6.c: New.
	* testsuite/libgomp.c-c++-common/target-imperfect1.c: New.
	* testsuite/libgomp.c-c++-common/target-imperfect2.c: New.
	* testsuite/libgomp.c-c++-common/target-imperfect3.c: New.
	* testsuite/libgomp.c-c++-common/target-imperfect4.c: New.
2023-08-25 19:42:50 +00:00

49 lines
863 B
C

/* { dg-do run } */
#ifndef __cplusplus
extern void abort (void);
#else
extern "C" void abort (void);
#endif
static int inner_loop_count = 0;
static int intervening_code_count = 0;
void
g (int x, int y)
{
inner_loop_count++;
}
int
foo (int imax, int jmax)
{
int j = 0;
#pragma omp for collapse(2)
for (int i = 0; i < imax; ++i)
{
/* All the intervening code at the same level must be executed
the same number of times. */
++intervening_code_count;
for (int j = 0; j < jmax; ++j)
{
g (i, j);
}
/* This is the outer j, not the one from the inner collapsed loop. */
++j;
}
return j;
}
int
main (void)
{
int j = foo (5, 3);
if (j != intervening_code_count)
abort ();
if (inner_loop_count != 5 * 3)
abort ();
if (intervening_code_count < 5 || intervening_code_count > 5 * 3)
abort ();
}