@@ -1566,6 +1566,7 @@ void KernelObjVisitor::visitArray(const CXXRecordDecl *Owner, FieldDecl *Field,
1566
1566
// A type to check the validity of all of the argument types.
1567
1567
class SyclKernelFieldChecker : public SyclKernelFieldHandler {
1568
1568
bool IsInvalid = false ;
1569
+ bool IsSIMD = false ;
1569
1570
DiagnosticsEngine &Diag;
1570
1571
// Check whether the object should be disallowed from being copied to kernel.
1571
1572
// Return true if not copyable, false if copyable.
@@ -1652,6 +1653,10 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
1652
1653
assert (Util::isSyclSpecialType (Ty) &&
1653
1654
" Should only be called on sycl special class types." );
1654
1655
const RecordDecl *RecD = Ty->getAsRecordDecl ();
1656
+ if (IsSIMD && !Util::isSyclType (Ty, " accessor" , true /* Tmp*/ ))
1657
+ return SemaRef.Diag (Loc.getBegin (),
1658
+ diag::err_sycl_esimd_not_supported_for_type)
1659
+ << RecD;
1655
1660
if (const ClassTemplateSpecializationDecl *CTSD =
1656
1661
dyn_cast<ClassTemplateSpecializationDecl>(RecD)) {
1657
1662
const TemplateArgumentList &TAL = CTSD->getTemplateArgs ();
@@ -1666,8 +1671,9 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
1666
1671
}
1667
1672
1668
1673
public:
1669
- SyclKernelFieldChecker (Sema &S)
1670
- : SyclKernelFieldHandler(S), Diag(S.getASTContext().getDiagnostics()) {}
1674
+ SyclKernelFieldChecker (Sema &S, bool isSIMD)
1675
+ : SyclKernelFieldHandler(S), Diag(S.getASTContext().getDiagnostics()),
1676
+ IsSIMD (isSIMD) {}
1671
1677
static constexpr const bool VisitNthArrayElement = false ;
1672
1678
bool isValid () { return !IsInvalid; }
1673
1679
@@ -2250,7 +2256,9 @@ class SyclKernelArgsSizeChecker : public SyclKernelFieldHandler {
2250
2256
const CXXRecordDecl *RecordDecl = FieldTy->getAsCXXRecordDecl ();
2251
2257
assert (RecordDecl && " The type must be a RecordDecl" );
2252
2258
llvm::StringLiteral MethodName =
2253
- IsSIMD ? InitESIMDMethodName : InitMethodName;
2259
+ (IsSIMD && Util::isSyclType (FieldTy, " accessor" , true /* Tmp*/ ))
2260
+ ? InitESIMDMethodName
2261
+ : InitMethodName;
2254
2262
CXXMethodDecl *InitMethod = getMethodByName (RecordDecl, MethodName);
2255
2263
assert (InitMethod && " The type must have the __init method" );
2256
2264
for (const ParmVarDecl *Param : InitMethod->parameters ())
@@ -3549,11 +3557,12 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc, SourceRange CallLoc,
3549
3557
if (KernelObj->isInvalidDecl ())
3550
3558
return ;
3551
3559
3560
+ bool IsSIMDKernel = isESIMDKernelType (KernelObj);
3561
+
3552
3562
SyclKernelDecompMarker DecompMarker (*this );
3553
- SyclKernelFieldChecker FieldChecker (*this );
3563
+ SyclKernelFieldChecker FieldChecker (*this , IsSIMDKernel );
3554
3564
SyclKernelUnionChecker UnionChecker (*this );
3555
3565
3556
- bool IsSIMDKernel = isESIMDKernelType (KernelObj);
3557
3566
SyclKernelArgsSizeChecker ArgsSizeChecker (*this , Args[0 ]->getExprLoc (),
3558
3567
IsSIMDKernel);
3559
3568
0 commit comments