aboutsummaryrefslogtreecommitdiff
path: root/clang/test/OpenMP/target_vtable_codegen_container.cpp
blob: 9fd4c6b7361634496ae2217210d4f4ee788fb1c0 (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
34
35
36
37
38
39
40
41
42
// RUN: %clang_cc1 -verify -fopenmp -Wno-openmp-mapping -x c++ -triple x86_64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-cuda-mode  -emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=52 -stdlib=libc++
// RUN: %clang_cc1 -verify -fopenmp -Wno-openmp-mapping -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-cuda-mode  -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -debug-info-kind=limited -fopenmp-version=52 -stdlib=libc++ | FileCheck %s
// expected-no-diagnostics

// CHECK-DAG: @_ZTV7Derived
// CHECK-DAG: @_ZTV4Base
template <typename T>
class Container {
private:
T value;
public:
Container() : value() {}
Container(T val) : value(val) {}

T getValue() const { return value; }

void setValue(T val) { value = val; }
};

class Base {
public:
    virtual void foo() {}
};
class Derived : public Base {};

class Test {
public:
    Container<Derived> v;
};

int main() {
  Test test;
  Derived d;
  test.v.setValue(d);

// Make sure we emit VTable for type indirectly (template specialized type)
#pragma omp target map(test)
  {
      test.v.getValue().foo();
  }
  return 0;
}