1 // RUN: %libomptarget-compilexx-generic 2 // RUN: %libomptarget-run-generic 3 // RUN: %libomptarget-compilexx-generic -DCTOR_KERNEL 4 // RUN: %not --crash %libomptarget-run-generic 5 // RUN: %libomptarget-compilexx-generic -DCTOR_API 6 // RUN: %not --crash %libomptarget-run-generic 7 8 #include <cstdio> 9 #include <omp.h> 10 11 void foo_dev() { __builtin_trap(); } 12 13 #pragma omp declare variant(foo_dev) match(device = {kind(nohost)}) 14 void foo() {} 15 16 struct S { 17 S() { foo(); } 18 }; 19 20 S s; 21 #pragma omp declare target(s) 22 23 int main() { 24 int Dev = omp_get_default_device(); 25 26 #ifdef CTOR_KERNEL 27 #pragma omp target 28 {} 29 #endif 30 #ifdef CTOR_API 31 omp_get_mapped_ptr(&s, Dev); 32 #endif 33 } 34