gcc/libgomp/testsuite/libgomp.c/lib-1.c
Kwok Cheung Yeung 10508db867 openmp: Mark deprecated symbols in OpenMP 5.0
2020-11-05  Ulrich Drepper  <drepper@redhat.com>
	    Kwok Cheung Yeung  <kcy@codesourcery.com>

	libgomp/
	* Makefile.am (%.mod): Add -cpp and -fopenmp to compile flags.
	* Makefile.in: Regenerate.
	* fortran.c: Wrap uses of omp_set_nested and omp_get_nested with
	pragmas to ignore -Wdeprecated-declarations warnings.
	* icv.c: Likewise.
	* omp.h.in (__GOMP_DEPRECATED_5_0): Define.
	Mark omp_lock_hint_* enum values, omp_lock_hint_t, omp_set_nested,
	and omp_get_nested with __GOMP_DEPRECATED_5_0.
	* omp_lib.f90.in: Mark omp_get_nested and omp_set_nested as
	deprecated.
	* testsuite/libgomp.c++/affinity-1.C: Add -Wno-deprecated-declarations
	to test options.
	* testsuite/libgomp.c/affinity-1.c: Likewise.
	* testsuite/libgomp.c/affinity-2.c: Likewise.
	* testsuite/libgomp.c/appendix-a/a.15.1.c: Likewise.
	* testsuite/libgomp.c/lib-1.c: Likewise.
	* testsuite/libgomp.c/nested-1.c: Likewise.
	* testsuite/libgomp.c/nested-2.c: Likewise.
	* testsuite/libgomp.c/nested-3.c: Likewise.
	* testsuite/libgomp.c/pr32362-1.c: Likewise.
	* testsuite/libgomp.c/pr32362-2.c: Likewise.
	* testsuite/libgomp.c/pr32362-3.c: Likewise.
	* testsuite/libgomp.c/pr35549.c: Likewise.
	* testsuite/libgomp.c/pr42942.c: Likewise.
	* testsuite/libgomp.c/pr61200.c: Likewise.
	* testsuite/libgomp.c/sort-1.c: Likewise.
	* testsuite/libgomp.c/target-5.c: Likewise.
	* testsuite/libgomp.c/target-6.c: Likewise.
	* testsuite/libgomp.c/teams-1.c: Likewise.
	* testsuite/libgomp.c/thread-limit-1.c: Likewise.
	* testsuite/libgomp.c/thread-limit-2.c: Likewise.
	* testsuite/libgomp.c/thread-limit-4.c: Likewise.
	* testsuite/libgomp.fortran/affinity1.f90: Likewise.
	* testsuite/libgomp.fortran/lib1.f90: Likewise.
	* testsuite/libgomp.fortran/lib2.f: Likewise.
	* testsuite/libgomp.fortran/nested1.f90: Likewise.
	* testsuite/libgomp.fortran/teams1.f90: Likewise.
2020-11-05 10:32:56 -08:00

104 lines
2.1 KiB
C

/* { dg-additional-options "-Wno-deprecated-declarations" } */
#include <stdlib.h>
#include <omp.h>
int
main (void)
{
double d, e;
int l;
omp_lock_t lck;
omp_nest_lock_t nlck;
d = omp_get_wtime ();
omp_init_lock (&lck);
omp_set_lock (&lck);
if (omp_test_lock (&lck))
abort ();
omp_unset_lock (&lck);
if (! omp_test_lock (&lck))
abort ();
if (omp_test_lock (&lck))
abort ();
omp_unset_lock (&lck);
omp_destroy_lock (&lck);
omp_init_nest_lock (&nlck);
if (omp_test_nest_lock (&nlck) != 1)
abort ();
omp_set_nest_lock (&nlck);
if (omp_test_nest_lock (&nlck) != 3)
abort ();
omp_unset_nest_lock (&nlck);
omp_unset_nest_lock (&nlck);
if (omp_test_nest_lock (&nlck) != 2)
abort ();
omp_unset_nest_lock (&nlck);
omp_unset_nest_lock (&nlck);
omp_destroy_nest_lock (&nlck);
omp_set_dynamic (1);
if (! omp_get_dynamic ())
abort ();
omp_set_dynamic (0);
if (omp_get_dynamic ())
abort ();
omp_set_nested (1);
if (! omp_get_nested ())
abort ();
omp_set_nested (0);
if (omp_get_nested ())
abort ();
omp_set_num_threads (5);
if (omp_get_num_threads () != 1)
abort ();
if (omp_get_max_threads () != 5)
abort ();
if (omp_get_thread_num () != 0)
abort ();
omp_set_num_threads (3);
if (omp_get_num_threads () != 1)
abort ();
if (omp_get_max_threads () != 3)
abort ();
if (omp_get_thread_num () != 0)
abort ();
l = 0;
#pragma omp parallel reduction (|:l)
{
l = omp_get_num_threads () != 3;
l |= omp_get_thread_num () < 0;
l |= omp_get_thread_num () >= 3;
#pragma omp master
l |= omp_get_thread_num () != 0;
}
if (l)
abort ();
if (omp_get_num_procs () <= 0)
abort ();
if (omp_in_parallel ())
abort ();
#pragma omp parallel reduction (|:l)
l = ! omp_in_parallel ();
#pragma omp parallel reduction (|:l) if (1)
l = ! omp_in_parallel ();
if (l)
abort ();
e = omp_get_wtime ();
if (d > e)
abort ();
d = omp_get_wtick ();
/* Negative precision is definitely wrong,
bigger than 1s clock resolution is also strange. */
if (d <= 0 || d > 1)
abort ();
return 0;
}