gcc/libgomp/testsuite/libgomp.c++/target-has-device-addr-9.C
Marcel Vollweiler b4fb9f4f9a OpenMP, C++: Add template support for the has_device_addr clause.
This patch adds support for list items in the has_device_addr clause which type
is given by C++ template parameters.

gcc/cp/ChangeLog:

	* pt.cc (tsubst_omp_clauses): Added OMP_CLAUSE_HAS_DEVICE_ADDR.
	* semantics.cc (finish_omp_clauses): Added template decl processing.

libgomp/ChangeLog:

	* testsuite/libgomp.c++/target-has-device-addr-7.C: New test.
	* testsuite/libgomp.c++/target-has-device-addr-8.C: New test.
	* testsuite/libgomp.c++/target-has-device-addr-9.C: New test.
2022-05-16 01:02:50 -07:00

31 lines
521 B
C

/* Testing 'has_device_addr' clause on the target construct with template. */
#include <omp.h>
template <typename T>
void
foo (T (&x))
{
#pragma omp target has_device_addr(x)
x = 24;
}
int
main ()
{
int *dp = (int*)omp_target_alloc (sizeof(int), 0);
int &x = *dp;
foo <int> (x);
int y = 42;
int h = omp_get_initial_device ();
int t = omp_get_default_device ();
omp_target_memcpy (&y, dp, sizeof(int), 0, 0, h, t);
if (y != 24)
__builtin_abort ();
omp_target_free (dp, 0);
return 0;
}