Skip to content

Commit fdfbe19

Browse files
committed
Add empty base case for windows failure
Signed-off-by: Soumi Manna <[email protected]>
1 parent 6a80b99 commit fdfbe19

File tree

1 file changed

+23
-36
lines changed

1 file changed

+23
-36
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,13 @@ class KernelObjVisitor {
872872
(handlers.leaveUnion(Owner, Parent), 0)...};
873873
}
874874

875+
// Handle empty base case.
876+
template <typename ParentTy>
877+
void VisitUnion(const CXXRecordDecl *Owner, ParentTy &Parent,
878+
const CXXRecordDecl *Wrapper) {}
879+
880+
// Add overloads including the base case when
881+
// sizeof...(FilteredHandlers) > 0.
875882
template <typename... FilteredHandlers, typename ParentTy,
876883
typename CurHandler, typename... Handlers>
877884
std::enable_if_t<!CurHandler::VisitUnionBody>
@@ -894,6 +901,8 @@ class KernelObjVisitor {
894901
filtered_handlers..., cur_handler, Owner, Parent, Wrapper, handlers...);
895902
}
896903

904+
// Add overloads without having filtered-handlers
905+
// to handle leading-empty argument packs.
897906
template <typename ParentTy, typename CurHandler, typename... Handlers>
898907
std::enable_if_t<!CurHandler::VisitUnionBody>
899908
VisitUnion(const CXXRecordDecl *Owner, ParentTy &Parent,
@@ -1275,6 +1284,14 @@ class SyclKernelUnionChecker : public SyclKernelFieldHandler {
12751284
bool isValid() { return !IsInvalid; }
12761285
static constexpr const bool VisitUnionBody = true;
12771286

1287+
bool checkType(SourceLocation Loc, QualType Ty) {
1288+
if (UnionCount) {
1289+
IsInvalid = true;
1290+
Diag.Report(Loc, diag::err_bad_union_kernel_param_members) << Ty;
1291+
}
1292+
return isValid();
1293+
}
1294+
12781295
bool enterUnion(const CXXRecordDecl *RD, FieldDecl *FD) {
12791296
++UnionCount;
12801297
return true;
@@ -1286,60 +1303,30 @@ class SyclKernelUnionChecker : public SyclKernelFieldHandler {
12861303
}
12871304

12881305
bool handleSyclAccessorType(FieldDecl *FD, QualType FieldTy) final {
1289-
if (UnionCount) {
1290-
IsInvalid = true;
1291-
Diag.Report(FD->getLocation(), diag::err_bad_union_kernel_param_members)
1292-
<< FieldTy;
1293-
}
1294-
return isValid();
1306+
return checkType(FD->getLocation(), FieldTy);
12951307
}
12961308

12971309
bool handleSyclAccessorType(const CXXBaseSpecifier &BS,
12981310
QualType FieldTy) final {
1299-
if (UnionCount) {
1300-
IsInvalid = true;
1301-
Diag.Report(BS.getBeginLoc(), diag::err_bad_union_kernel_param_members)
1302-
<< FieldTy;
1303-
}
1304-
return isValid();
1311+
return checkType(BS.getBeginLoc(), FieldTy);
13051312
}
13061313

13071314
bool handleSyclSamplerType(FieldDecl *FD, QualType FieldTy) final {
1308-
if (UnionCount) {
1309-
IsInvalid = true;
1310-
Diag.Report(FD->getLocation(), diag::err_bad_union_kernel_param_members)
1311-
<< FieldTy;
1312-
}
1313-
return isValid();
1315+
return checkType(FD->getLocation(), FieldTy);
13141316
}
13151317

13161318
bool handleSyclSamplerType(const CXXBaseSpecifier &BS,
13171319
QualType FieldTy) final {
1318-
if (UnionCount) {
1319-
IsInvalid = true;
1320-
Diag.Report(BS.getBeginLoc(), diag::err_bad_union_kernel_param_members)
1321-
<< FieldTy;
1322-
}
1323-
return isValid();
1320+
return checkType(BS.getBeginLoc(), FieldTy);
13241321
}
13251322

13261323
bool handleSyclStreamType(FieldDecl *FD, QualType FieldTy) final {
1327-
if (UnionCount) {
1328-
IsInvalid = true;
1329-
Diag.Report(FD->getLocation(), diag::err_bad_union_kernel_param_members)
1330-
<< FieldTy;
1331-
}
1332-
return isValid();
1324+
return checkType(FD->getLocation(), FieldTy);
13331325
}
13341326

13351327
bool handleSyclStreamType(const CXXBaseSpecifier &BS,
13361328
QualType FieldTy) final {
1337-
if (UnionCount) {
1338-
IsInvalid = true;
1339-
Diag.Report(BS.getBeginLoc(), diag::err_bad_union_kernel_param_members)
1340-
<< FieldTy;
1341-
}
1342-
return isValid();
1329+
return checkType(BS.getBeginLoc(), FieldTy);
13431330
}
13441331
};
13451332

0 commit comments

Comments
 (0)