[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
This revision was automatically updated to reflect the committed changes. Closed by commit rC359798: [OpenCL] Fix initialisation of this via pointer. (authored by stulova, committed by ). Changed prior to commit: https://reviews.llvm.org/D61319?vs=197749=197800#toc Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61319/new/ https://reviews.llvm.org/D61319 Files: lib/Sema/SemaOverload.cpp test/CodeGenOpenCLCXX/addrspace-of-this.cl Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -5279,12 +5279,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/CodeGenOpenCLCXX/addrspace-of-this.cl === --- test/CodeGenOpenCLCXX/addrspace-of-this.cl +++ test/CodeGenOpenCLCXX/addrspace-of-this.cl @@ -59,7 +59,8 @@ __kernel void test__global() { int i = c.get(); - int i2 = c.outside(); + int i2 = ()->get(); + int i3 = c.outside(); C c1(c); C c2; c2 = c1; @@ -85,10 +86,12 @@ // COMMON-LABEL: @_Z12test__globalv() // Test the address space of 'this' when invoking a method. -// COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// COMMON: call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// Test the address space of 'this' when invoking a method using a pointer to the object. +// COMMON: call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking a method that is declared in the file contex. -// COMMON: %call1 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// COMMON: call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking copy-constructor. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* @@ -130,7 +133,7 @@ // Test the address space of 'this' when invoking the move assignment // COMMON: [[C5GEN:%[0-9]+]] = addrspacecast %class.C* %c5 to %class.C addrspace(4)* // COMMON: [[CALL:%call[0-9]+]] = call spir_func dereferenceable(4) %class.C addrspace(4)* @_Z3foov() -// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) %call4) +// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) [[CALL]]) // IMPL: [[C5VOID:%[0-9]+]] = bitcast %class.C* %c5 to i8* // IMPL: [[CALLVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[CALL]] to i8 addrspace(4)* // IMPL: call void @llvm.memcpy.p0i8.p4i8.i32(i8* {{.*}}[[C5VOID]], i8 addrspace(4)* {{.*}}[[CALLVOID]] @@ -155,7 +158,7 @@ // EXPL-NOT: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast (%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking a method. -// COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*)) +// COMMON: call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking copy-constructor. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* @@ -185,7 +188,7 @@ // Test the address space of 'this' when invoking a method. // COMMON: [[CGEN:%[0-9]+]] = addrspacecast %class.C* %c to %class.C addrspace(4)* -// COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* [[CGEN]]) +// COMMON: call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* [[CGEN]]) // Test the address space of 'this' when invoking a copy-constructor. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* @@ -202,7 +205,7 @@ // Test the address space of 'this' when invoking a copy-assignment. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast
[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! Thanks! Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61319/new/ https://reviews.llvm.org/D61319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
kpet updated this revision to Diff 197749. kpet added a comment. Clean up the tests. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61319/new/ https://reviews.llvm.org/D61319 Files: clang/lib/Sema/SemaOverload.cpp clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl Index: clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl === --- clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl +++ clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl @@ -59,7 +59,8 @@ __kernel void test__global() { int i = c.get(); - int i2 = c.outside(); + int i2 = ()->get(); + int i3 = c.outside(); C c1(c); C c2; c2 = c1; @@ -85,10 +86,12 @@ // COMMON-LABEL: @_Z12test__globalv() // Test the address space of 'this' when invoking a method. -// COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// COMMON: call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// Test the address space of 'this' when invoking a method using a pointer to the object. +// COMMON: call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking a method that is declared in the file contex. -// COMMON: %call1 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// COMMON: call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking copy-constructor. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* @@ -130,7 +133,7 @@ // Test the address space of 'this' when invoking the move assignment // COMMON: [[C5GEN:%[0-9]+]] = addrspacecast %class.C* %c5 to %class.C addrspace(4)* // COMMON: [[CALL:%call[0-9]+]] = call spir_func dereferenceable(4) %class.C addrspace(4)* @_Z3foov() -// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) %call4) +// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) [[CALL]]) // IMPL: [[C5VOID:%[0-9]+]] = bitcast %class.C* %c5 to i8* // IMPL: [[CALLVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[CALL]] to i8 addrspace(4)* // IMPL: call void @llvm.memcpy.p0i8.p4i8.i32(i8* {{.*}}[[C5VOID]], i8 addrspace(4)* {{.*}}[[CALLVOID]] @@ -155,7 +158,7 @@ // EXPL-NOT: call void @_ZNU3AS41CC1Ev(%class.C addrspace(4)* addrspacecast (%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking a method. -// COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*)) +// COMMON: call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(3)* @_ZZ11test__localvE1c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking copy-constructor. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* @@ -185,7 +188,7 @@ // Test the address space of 'this' when invoking a method. // COMMON: [[CGEN:%[0-9]+]] = addrspacecast %class.C* %c to %class.C addrspace(4)* -// COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* [[CGEN]]) +// COMMON: call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* [[CGEN]]) // Test the address space of 'this' when invoking a copy-constructor. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* @@ -202,7 +205,7 @@ // Test the address space of 'this' when invoking a copy-assignment. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* // COMMON: [[C2GEN:%[0-9]+]] = addrspacecast %class.C* %c2 to %class.C addrspace(4)* -// EXPL: %call1 = call dereferenceable(4) %class.C addrspace(4)* @_ZNU3AS41CaSERU3AS4KS_(%class.C addrspace(4)* [[C2GEN]], %class.C addrspace(4)* dereferenceable(4) [[C1GEN]]) +// EXPL: call dereferenceable(4) %class.C addrspace(4)* @_ZNU3AS41CaSERU3AS4KS_(%class.C addrspace(4)* [[C2GEN]], %class.C addrspace(4)* dereferenceable(4) [[C1GEN]]) // IMPL: [[C2GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C2GEN]] to i8 addrspace(4)* // IMPL: [[C1GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C1GEN]] to i8 addrspace(4)* // IMPL: call void @llvm.memcpy.p4i8.p4i8.i32(i8 addrspace(4)* {{.*}}[[C2GENVOID]], i8 addrspace(4)* {{.*}}[[C1GENVOID]] Index: clang/lib/Sema/SemaOverload.cpp === --- clang/lib/Sema/SemaOverload.cpp +++ clang/lib/Sema/SemaOverload.cpp @@ -5278,12 +5278,12
[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
kpet added a comment. Most of these are pre-existing issues with the tests but I agree they're worth fixing. I'll update the tests. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61319/new/ https://reviews.llvm.org/D61319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
Anastasia added inline comments. Comment at: test/CodeGenOpenCLCXX/addrspace-of-this.cl:94 // Test the address space of 'this' when invoking a method that is declared in the file contex. -// COMMON: %call1 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// COMMON: %call2 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) Ok I think we should regex name of call registers or may be even prevent checking it if it's not required. The same applies to other places btw. Comment at: test/CodeGenOpenCLCXX/addrspace-of-this.cl:136 // COMMON: [[CALL:%call[0-9]+]] = call spir_func dereferenceable(4) %class.C addrspace(4)* @_Z3foov() -// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) %call4) +// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) %call5) // IMPL: [[C5VOID:%[0-9]+]] = bitcast %class.C* %c5 to i8* Shouldn't `%call5` just be `[[CALL]]`? If not I see little value in checking the name... Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61319/new/ https://reviews.llvm.org/D61319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
kpet updated this revision to Diff 197617. kpet added a comment. Replaced the AST dump test with an IR test. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61319/new/ https://reviews.llvm.org/D61319 Files: lib/Sema/SemaOverload.cpp test/CodeGenOpenCLCXX/addrspace-of-this.cl Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl === --- test/CodeGenOpenCLCXX/addrspace-of-this.cl +++ test/CodeGenOpenCLCXX/addrspace-of-this.cl @@ -59,7 +59,8 @@ __kernel void test__global() { int i = c.get(); - int i2 = c.outside(); + int i2 = ()->get(); + int i3 = c.outside(); C c1(c); C c2; c2 = c1; @@ -86,9 +87,11 @@ // Test the address space of 'this' when invoking a method. // COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// Test the address space of 'this' when invoking a method using a pointer to the object. +// COMMON: %call1 = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking a method that is declared in the file contex. -// COMMON: %call1 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// COMMON: %call2 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking copy-constructor. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* @@ -130,7 +133,7 @@ // Test the address space of 'this' when invoking the move assignment // COMMON: [[C5GEN:%[0-9]+]] = addrspacecast %class.C* %c5 to %class.C addrspace(4)* // COMMON: [[CALL:%call[0-9]+]] = call spir_func dereferenceable(4) %class.C addrspace(4)* @_Z3foov() -// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) %call4) +// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* [[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) %call5) // IMPL: [[C5VOID:%[0-9]+]] = bitcast %class.C* %c5 to i8* // IMPL: [[CALLVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[CALL]] to i8 addrspace(4)* // IMPL: call void @llvm.memcpy.p0i8.p4i8.i32(i8* {{.*}}[[C5VOID]], i8 addrspace(4)* {{.*}}[[CALLVOID]] 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/CodeGenOpenCLCXX/addrspace-of-this.cl === --- test/CodeGenOpenCLCXX/addrspace-of-this.cl +++ test/CodeGenOpenCLCXX/addrspace-of-this.cl @@ -59,7 +59,8 @@ __kernel void test__global() { int i = c.get(); - int i2 = c.outside(); + int i2 = ()->get(); + int i3 = c.outside(); C c1(c); C c2; c2 = c1; @@ -86,9 +87,11 @@ // Test the address space of 'this' when invoking a method. // COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// Test the address space of 'this' when invoking a method using a pointer to the object. +// COMMON: %call1 = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking a method that is declared in the file contex. -// COMMON: %call1 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) +// COMMON: %call2 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*)) // Test the address space of 'this' when invoking copy-constructor. // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)* @@ -130,7 +133,7 @@ // Test the address space of 'this' when invoking the move assignment // COMMON: [[C5GEN:%[0-9]+]] = addrspacecast %class.C* %c5 to %class.C addrspace(4)* // COMMON: [[CALL:%call[0-9]+]] = call spir_func dereferenceable(4)
[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
kpet added a comment. Ok, I'll replace the test with an IR-level test. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61319/new/ https://reviews.llvm.org/D61319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
Anastasia added a comment. I would suggest an IR test, especially since what you want to achieve is addrspacecast in IR output. We use AST dump only if there is no other good way to test something. In fact we already have a test with similar logic that tests various OpenCL address spaces: test/CodeGenOpenCLCXX/addrspace-of-this.cl. I think it should be reasonable enough to extend it. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61319/new/ https://reviews.llvm.org/D61319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer
kpet created this revision. kpet added reviewers: Anastasia, mikael. Herald added subscribers: cfe-commits, yaxunl. Herald added a project: clang. When the expression used to initialise this has a pointer type, check the address space of the pointee type instead of the pointer type to decide whether an address space cast is required. It is the pointee type that carries the address space qualifier. Repository: rC Clang https://reviews.llvm.org/D61319 Files: lib/Sema/SemaOverload.cpp test/SemaOpenCLCXX/this-initialisation-from-pointer.cl 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 *' +} 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 *' +} 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; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits