libgomp/testsuite/libgomp.c++/target-has-device-addr-2.C
raw| 1 | /* Testing 'has_device_addr' clause on the target construct with reference. */ |
| 2 | |
| 3 | #include <omp.h> |
| 4 | |
| 5 | int |
| 6 | main () |
| 7 | { |
| 8 | int *dp = (int*)omp_target_alloc (sizeof(int), 0); |
| 9 | |
| 10 | #pragma omp target is_device_ptr(dp) |
| 11 | *dp = 42; |
| 12 | |
| 13 | int &x = *dp; |
| 14 | |
| 15 | #pragma omp target has_device_addr(x) |
| 16 | x = 24; |
| 17 | |
| 18 | #pragma omp target has_device_addr(x) |
| 19 | if (x != 24) |
| 20 | __builtin_abort (); |
| 21 | |
| 22 | omp_target_free(dp, 0); |
| 23 | } |