Debian Codegraph @

libgomp/testsuite/libgomp.c++/target-has-device-addr-7.C

raw
1 /* Testing 'has_device_addr' clause on the target construct with template. */
2
3 template <typename T>
4 void
5 foo (T x)
6 {
7 x = 24;
8 #pragma omp target data map(x) use_device_addr(x)
9 #pragma omp target has_device_addr(x)
10 x = 42;
11
12 if (x != 42)
13 __builtin_abort ();
14 }
15
16 template <typename T>
17 void
18 bar (T (&x)[])
19 {
20 x[0] = 24;
21 #pragma omp target data map(x[:2]) use_device_addr(x)
22 #pragma omp target has_device_addr(x[:2])
23 x[0] = 42;
24
25 if (x[0] != 42)
26 __builtin_abort ();
27 }
28
29 int
30 main ()
31 {
32 int a[] = { 24, 42};
33 foo <int> (42);
34 bar <int> (a);
35 return 0;
36 }