@@ -1452,7 +1452,7 @@ class KernelObjVisitor {
14521452 else if (ParamTy->isStructureOrClassType ()) {
14531453 if (KF_FOR_EACH (handleStructType, Param, ParamTy)) {
14541454 CXXRecordDecl *RD = ParamTy->getAsCXXRecordDecl ();
1455- visitRecord (RD , Param, RD, ParamTy, Handlers...);
1455+ visitRecord (nullptr , Param, RD, ParamTy, Handlers...);
14561456 }
14571457 } else if (ParamTy->isUnionType ())
14581458 KP_FOR_EACH (handleOtherType, Param, ParamTy);
@@ -1980,7 +1980,11 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
19801980
19811981 // Check that the type is defined at namespace scope.
19821982 const DeclContext *DeclCtx = RD->getDeclContext ();
1983- if (!DeclCtx->isTranslationUnit () && !isa<NamespaceDecl>(DeclCtx)) {
1983+ while (!DeclCtx->isTranslationUnit () &&
1984+ (isa<NamespaceDecl>(DeclCtx) || isa<LinkageSpecDecl>(DeclCtx)))
1985+ DeclCtx = DeclCtx->getParent ();
1986+
1987+ if (!DeclCtx->isTranslationUnit ()) {
19841988 Diag.Report (PD->getLocation (), diag::err_bad_kernel_param_type)
19851989 << ParamTy;
19861990 IsInvalid = true ;
@@ -3017,13 +3021,13 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
30173021
30183022 bool handleNonDecompStruct (const CXXRecordDecl *RD, ParmVarDecl *PD,
30193023 QualType ParamTy) final {
3020- // This is a field which should not be decomposed.
3021- CXXRecordDecl *FieldRecordDecl = ParamTy->getAsCXXRecordDecl ();
3022- assert (FieldRecordDecl && " Type must be a C++ record type" );
3024+ // This is a struct parameter which should not be decomposed.
3025+ CXXRecordDecl *ParamRecordDecl = ParamTy->getAsCXXRecordDecl ();
3026+ assert (ParamRecordDecl && " Type must be a C++ record type" );
30233027 // Check if we need to generate a new type for this record,
30243028 // i.e. this record contains pointers.
3025- if (FieldRecordDecl ->hasAttr <SYCLGenerateNewTypeAttr>())
3026- addParam (PD, GenerateNewRecordType (FieldRecordDecl ));
3029+ if (ParamRecordDecl ->hasAttr <SYCLGenerateNewTypeAttr>())
3030+ addParam (PD, GenerateNewRecordType (ParamRecordDecl ));
30273031 else
30283032 addParam (PD, ParamTy);
30293033 return true ;
0 commit comments