aboutsummaryrefslogtreecommitdiff
path: root/offload/test/offloading/ctor_dtor_lazy.cpp
blob: 6ca232c288b5dcbb7c434366d2b284325c351d51 (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
// RUN: %libomptarget-compilexx-generic
// RUN: %libomptarget-run-generic
// RUN: %libomptarget-compilexx-generic -DCTOR_KERNEL
// RUN: %not --crash %libomptarget-run-generic
// RUN: %libomptarget-compilexx-generic -DCTOR_API
// RUN: %not --crash %libomptarget-run-generic

#include <cstdio>
#include <omp.h>

void foo_dev() { __builtin_trap(); }

#pragma omp declare variant(foo_dev) match(device = {kind(nohost)})
void foo() {}

struct S {
  S() { foo(); }
};

S s;
#pragma omp declare target(s)

int main() {
  int Dev = omp_get_default_device();

#ifdef CTOR_KERNEL
#pragma omp target
  {}
#endif
#ifdef CTOR_API
  omp_get_mapped_ptr(&s, Dev);
#endif
}