Index: lib/Sema/SemaOverload.cpp =================================================================== --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -5278,12 +5278,12 @@ } if (!Context.hasSameType(From->getType(), DestType)) { - if (From->getType().getAddressSpace() != DestType.getAddressSpace()) - From = ImpCastExprToType(From, DestType, CK_AddressSpaceConversion, - From->getValueKind()).get(); + CastKind CK; + if (FromRecordType.getAddressSpace() != DestType.getAddressSpace()) + CK = CK_AddressSpaceConversion; else - From = ImpCastExprToType(From, DestType, CK_NoOp, - From->getValueKind()).get(); + CK = CK_NoOp; + From = ImpCastExprToType(From, DestType, CK, From->getValueKind()).get(); } return From; } Index: test/SemaOpenCLCXX/this-initialisation-from-pointer.cl =================================================================== --- /dev/null +++ test/SemaOpenCLCXX/this-initialisation-from-pointer.cl @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -cl-std=c++ -triple spir -fsyntax-only -verify -ast-dump %s | FileCheck %s +// expected-no-diagnostics + +struct foo { + void init() { + m_data = 1; + } +private: + int m_data; +}; + +kernel void test(global struct foo* afoo) { + afoo->init(); + // CHECK: CXXMemberCallExpr {{.*}} 'void' + // CHECK-NEXT: MemberExpr {{.*}} '' ->init {{.*}} + // CHECK-NEXT: ImplicitCastExpr {{.*}} '__generic foo *' +}