@@ -160,7 +160,8 @@ CompoundStmt *CreateSYCLKernelBody(Sema &S, FunctionDecl *KernelHelper,
160160 SourceLocation (), *TargetFuncParam, false ,
161161 DeclarationNameInfo (), ParamType, VK_LValue);
162162
163- CXXRecordDecl *CRD = Field->getType ()->getAsCXXRecordDecl ();
163+ QualType FieldType = Field->getType ();
164+ CXXRecordDecl *CRD = FieldType->getAsCXXRecordDecl ();
164165 if (CRD) {
165166 llvm::SmallVector<Expr *, 16 > ParamStmts;
166167 DeclAccessPair FieldDAP = DeclAccessPair::make (Field, AS_none);
@@ -205,6 +206,22 @@ CompoundStmt *CreateSYCLKernelBody(Sema &S, FunctionDecl *KernelHelper,
205206 BodyStmts.push_back (Call);
206207 }
207208 }
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);
208225 }
209226 TargetFuncParam++;
210227 }
0 commit comments