Skip to content

Commit 1e4c915

Browse files
Andrew Savonichevbader
authored andcommitted
[SYCL] Fix kernel argument cast kind (#914)
We insert a cast in SemaSYCL only if address spaces of pointee types are different. However, ImplicitCastExpr checks for pointee types only if the cast is RValue. Signed-off-by: Andrew Savonichev <[email protected]>
1 parent 14290c5 commit 1e4c915

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ static CompoundStmt *CreateOpenCLKernelBody(Sema &S,
889889
ParamType->getPointeeType().getAddressSpace())
890890
DRE = ImplicitCastExpr::Create(S.Context, FieldType,
891891
CK_AddressSpaceConversion, DRE,
892-
nullptr, VK_LValue);
892+
nullptr, VK_RValue);
893893
InitializationKind InitKind =
894894
InitializationKind::CreateCopy(SourceLocation(), SourceLocation());
895895
InitializationSequence InitSeq(S, Entity, InitKind, DRE);

clang/test/SemaSYCL/built-in-type-kernel-arg.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@ int main() {
8383

8484
// Check that lambda fields of pointer types are initialized
8585
// CHECK: InitListExpr
86-
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <LValueToRValue>
87-
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' lvalue <AddressSpaceConversion>
86+
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <AddressSpaceConversion>
8887
// CHECK-NEXT: DeclRefExpr {{.*}} '__global int *' lvalue ParmVar {{.*}} '_arg_' '__global int *'
89-
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <LValueToRValue>
90-
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' lvalue <AddressSpaceConversion>
88+
// CHECK-NEXT: ImplicitCastExpr {{.*}} 'int *' <AddressSpaceConversion>
9189
// CHECK-NEXT: DeclRefExpr {{.*}} '__global int *' lvalue ParmVar {{.*}} '_arg_' '__global int *'
9290

9391
// Check kernel parameters

0 commit comments

Comments
 (0)