aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/target-has-device-addr-5.C
blob: e847cdceb441742e70da452f039b05c96ba68f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Testing 'has_device_addr' clause on the target construct with reference. */

#include <omp.h>

int
main ()
{
  int *dpx = (int*)omp_target_alloc (sizeof(int), 0);
  int **dpy = (int**)omp_target_alloc (sizeof(int*), 0);

  #pragma omp target is_device_ptr(dpx, dpy)
    {
      *dpx = 42;
      int z = 77;
      *dpy = &z;
    }

  int& x = *dpx;
  int*& y = *dpy;

  #pragma omp target has_device_addr(x, y)
    {
      x = 24;
      y = &x;
    }

  #pragma omp target has_device_addr(x, y)
    if (x != 24 || y != &x)
      __builtin_abort ();

  omp_target_free(dpx, 0);
  omp_target_free(dpy, 0);
}