brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 808d9e3 Raw
78 lines · plain
1// RUN: %clang_cc1 %s -triple spir -emit-llvm -O0 -o - | FileCheck %s2 3struct B {4  int mb;5};6 7class D : public B {8public:9  int getmb() { return mb; }10};11 12void foo() {13  D d;14  //CHECK-LABEL: foo15  //CHECK: addrspacecast ptr %d to ptr addrspace(4)16  //CHECK: call spir_func noundef i32 @_ZNU3AS41D5getmbEv(ptr addrspace(4)17  d.getmb();18}19 20//Derived and Base are in the same address space.21 22//CHECK: define linkonce_odr spir_func noundef i32 @_ZNU3AS41D5getmbEv(ptr addrspace(4) {{[^,]*}} %this)23 24 25// Calling base method through multiple inheritance.26 27class B2 {28  public:29    void baseMethod() const {  }30    int &getRef() { return bb; }31    int bb;32};33 34class Derived : public B, public B2 {35  public:36    void work() const { baseMethod(); }37    // CHECK-LABEL: work38};39 40void pr43145(const Derived *argDerived) {41  argDerived->work();42}43 44// Casting from base to derived.45 46void pr43145_2(B *argB) {47  Derived *x = (Derived*)argB;48  // CHECK-LABEL: @_Z9pr43145_249}50 51// Assigning to reference returned by base class method through derived class.52 53void pr43145_3(int n) {54  Derived d;55  d.getRef() = n;56 57  // CHECK-LABEL: @_Z9pr43145_358  // CHECK: addrspacecast ptr %d to ptr addrspace(4)59  // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv60 61  private Derived *pd = &d;62  pd->getRef() = n;63 64  // CHECK: addrspacecast ptr %2 to ptr addrspace(4)65  // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv66}67 68// Implicit conversion of derived to base.69 70void functionWithBaseArgPtr(class B2 *b) {}71void functionWithBaseArgRef(class B2 &b) {}72 73void pr43145_4() {74  Derived d;75  functionWithBaseArgPtr(&d);76  functionWithBaseArgRef(d);77}78