@@ -160,7 +160,8 @@ CompoundStmt *CreateSYCLKernelBody(Sema &S, FunctionDecl *KernelHelper,
160
160
SourceLocation (), *TargetFuncParam, false ,
161
161
DeclarationNameInfo (), ParamType, VK_LValue);
162
162
163
- CXXRecordDecl *CRD = Field->getType ()->getAsCXXRecordDecl ();
163
+ QualType FieldType = Field->getType ();
164
+ CXXRecordDecl *CRD = FieldType->getAsCXXRecordDecl ();
164
165
if (CRD) {
165
166
llvm::SmallVector<Expr *, 16 > ParamStmts;
166
167
DeclAccessPair FieldDAP = DeclAccessPair::make (Field, AS_none);
@@ -205,6 +206,22 @@ CompoundStmt *CreateSYCLKernelBody(Sema &S, FunctionDecl *KernelHelper,
205
206
BodyStmts.push_back (Call);
206
207
}
207
208
}
209
+ } else if (FieldType->isBuiltinType ()) {
210
+ // If field have built-in type just initialize this field
211
+ // with corresponding kernel argument using '=' binary operator.
212
+ DeclAccessPair FieldDAP = DeclAccessPair::make (Field, AS_none);
213
+ auto Lhs = MemberExpr::Create (
214
+ S.Context , LambdaDRE, false , SourceLocation (),
215
+ NestedNameSpecifierLoc (), SourceLocation (), Field, FieldDAP,
216
+ DeclarationNameInfo (Field->getDeclName (), SourceLocation ()),
217
+ nullptr , Field->getType (), VK_LValue, OK_Ordinary);
218
+ auto Rhs = ImplicitCastExpr::Create (
219
+ S.Context , ParamType, CK_LValueToRValue, DRE, nullptr , VK_RValue);
220
+ // lambda.field = kernel_parameter
221
+ Expr *Res = new (S.Context )
222
+ BinaryOperator (Lhs, Rhs, BO_Assign, FieldType, VK_LValue,
223
+ OK_Ordinary, SourceLocation (), FPOptions ());
224
+ BodyStmts.push_back (Res);
208
225
}
209
226
TargetFuncParam++;
210
227
}
0 commit comments