target-has-device-addr-2.C 402 B

1234567891011121314151617181920212223
  1. /* Testing 'has_device_addr' clause on the target construct with reference. */
  2. #include <omp.h>
  3. int
  4. main ()
  5. {
  6. int *dp = (int*)omp_target_alloc (sizeof(int), 0);
  7. #pragma omp target is_device_ptr(dp)
  8. *dp = 42;
  9. int &x = *dp;
  10. #pragma omp target has_device_addr(x)
  11. x = 24;
  12. #pragma omp target has_device_addr(x)
  13. if (x != 24)
  14. __builtin_abort ();
  15. omp_target_free(dp, 0);
  16. }