1// RUN: %libomptarget-compilexx-run-and-check-generic
2
3// REQUIRES: libc
4
5#include <stdio.h>
6
7#pragma omp begin declare target device_type(nohost)
8
9// CHECK: void ctor1()
10// CHECK: void ctor2()
11// CHECK: void ctor3()
12[[gnu::constructor(101)]] void ctor1() { puts(s: __PRETTY_FUNCTION__); }
13[[gnu::constructor(102)]] void ctor2() { puts(s: __PRETTY_FUNCTION__); }
14[[gnu::constructor(103)]] void ctor3() { puts(s: __PRETTY_FUNCTION__); }
15
16struct S {
17 S() { puts(s: __PRETTY_FUNCTION__); }
18 ~S() { puts(s: __PRETTY_FUNCTION__); }
19};
20
21// CHECK: S::S()
22// CHECK: S::~S()
23S s;
24
25// CHECK: void dtor3()
26// CHECK: void dtor2()
27// CHECK: void dtor1()
28[[gnu::destructor(101)]] void dtor1() { puts(s: __PRETTY_FUNCTION__); }
29[[gnu::destructor(103)]] void dtor3() { puts(s: __PRETTY_FUNCTION__); }
30[[gnu::destructor(102)]] void dtor2() { puts(s: __PRETTY_FUNCTION__); }
31
32#pragma omp end declare target
33
34int main() {
35#pragma omp target
36 ;
37}
38

source code of offload/test/libc/global_ctor_dtor.cpp