@@ -1605,71 +1605,71 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
16051605 return false ;
16061606 }
16071607
1608- void checkPropertyListType (TemplateArgument PropList, SourceLocation Loc) {
1609- if (PropList.getKind () != TemplateArgument::ArgKind::Type) {
1610- SemaRef.Diag (Loc,
1611- diag::err_sycl_invalid_accessor_property_template_param);
1612- return ;
1613- }
1608+ bool checkPropertyListType (TemplateArgument PropList, SourceLocation Loc) {
1609+ if (PropList.getKind () != TemplateArgument::ArgKind::Type)
1610+ return SemaRef.Diag (
1611+ Loc, diag::err_sycl_invalid_accessor_property_template_param);
1612+
16141613 QualType PropListTy = PropList.getAsType ();
1615- if (!Util::isAccessorPropertyListType (PropListTy)) {
1616- SemaRef.Diag (Loc,
1617- diag::err_sycl_invalid_accessor_property_template_param);
1618- return ;
1619- }
1614+ if (!Util::isAccessorPropertyListType (PropListTy))
1615+ return SemaRef.Diag (
1616+ Loc, diag::err_sycl_invalid_accessor_property_template_param);
1617+
16201618 const auto *AccPropListDecl =
16211619 cast<ClassTemplateSpecializationDecl>(PropListTy->getAsRecordDecl ());
1622- if (AccPropListDecl->getTemplateArgs ().size () != 1 ) {
1623- SemaRef.Diag (Loc, diag::err_sycl_invalid_property_list_param_number)
1624- << " accessor_property_list " ;
1625- return ;
1626- }
1620+ if (AccPropListDecl->getTemplateArgs ().size () != 1 )
1621+ return SemaRef.Diag (Loc,
1622+ diag::err_sycl_invalid_property_list_param_number)
1623+ << " accessor_property_list " ;
1624+
16271625 const auto TemplArg = AccPropListDecl->getTemplateArgs ()[0 ];
1628- if (TemplArg.getKind () != TemplateArgument::ArgKind::Pack) {
1629- SemaRef.Diag (Loc,
1630- diag::err_sycl_invalid_accessor_property_list_template_param)
1631- << /* accessor_property_list */ 0 << /* parameter pack */ 0 ;
1632- return ;
1633- }
1626+ if (TemplArg.getKind () != TemplateArgument::ArgKind::Pack)
1627+ return SemaRef.Diag (
1628+ Loc,
1629+ diag::err_sycl_invalid_accessor_property_list_template_param)
1630+ << /* accessor_property_list */ 0 << /* parameter pack */ 0 ;
1631+
16341632 for (TemplateArgument::pack_iterator Prop = TemplArg.pack_begin ();
16351633 Prop != TemplArg.pack_end (); ++Prop) {
1636- if (Prop->getKind () != TemplateArgument::ArgKind::Type) {
1637- SemaRef.Diag (
1638- Loc, diag::err_sycl_invalid_accessor_property_list_template_param)
1639- << /* accessor_property_list pack argument*/ 1 << /* type*/ 1 ;
1640- return ;
1641- }
1634+ if (Prop->getKind () != TemplateArgument::ArgKind::Type)
1635+ return SemaRef.Diag (
1636+ Loc,
1637+ diag::err_sycl_invalid_accessor_property_list_template_param)
1638+ << /* accessor_property_list pack argument*/ 1 << /* type*/ 1 ;
16421639 QualType PropTy = Prop->getAsType ();
1643- if (Util::isSyclBufferLocationType (PropTy))
1644- checkBufferLocationType (PropTy, Loc);
1640+ if (Util::isSyclBufferLocationType (PropTy) &&
1641+ checkBufferLocationType (PropTy, Loc))
1642+ return true ;
16451643 }
1644+ return false ;
16461645 }
16471646
1648- void checkBufferLocationType (QualType PropTy, SourceLocation Loc) {
1647+ bool checkBufferLocationType (QualType PropTy, SourceLocation Loc) {
16491648 const auto *PropDecl =
16501649 cast<ClassTemplateSpecializationDecl>(PropTy->getAsRecordDecl ());
1651- if (PropDecl->getTemplateArgs ().size () != 1 ) {
1652- SemaRef.Diag (Loc, diag::err_sycl_invalid_property_list_param_number)
1653- << " buffer_location " ;
1654- return ;
1655- }
1650+ if (PropDecl->getTemplateArgs ().size () != 1 )
1651+ return SemaRef.Diag (Loc,
1652+ diag::err_sycl_invalid_property_list_param_number)
1653+ << " buffer_location " ;
1654+
16561655 const auto BufferLoc = PropDecl->getTemplateArgs ()[0 ];
1657- if (BufferLoc.getKind () != TemplateArgument::ArgKind::Integral) {
1658- SemaRef.Diag (Loc,
1659- diag::err_sycl_invalid_accessor_property_list_template_param)
1660- << /* buffer_location */ 2 << /* non-negative integer */ 2 ;
1661- return ;
1662- }
1656+ if (BufferLoc.getKind () != TemplateArgument::ArgKind::Integral)
1657+ return SemaRef.Diag (
1658+ Loc,
1659+ diag::err_sycl_invalid_accessor_property_list_template_param)
1660+ << /* buffer_location */ 2 << /* non-negative integer */ 2 ;
1661+
16631662 int LocationID = static_cast <int >(BufferLoc.getAsIntegral ().getExtValue ());
1664- if (LocationID < 0 ) {
1665- SemaRef.Diag (Loc,
1666- diag::err_sycl_invalid_accessor_property_list_template_param)
1667- << /* buffer_location*/ 2 << /* non-negative integer*/ 2 ;
1668- return ;
1669- }
1663+ if (LocationID < 0 )
1664+ return SemaRef.Diag (
1665+ Loc,
1666+ diag::err_sycl_invalid_accessor_property_list_template_param)
1667+ << /* buffer_location*/ 2 << /* non-negative integer*/ 2 ;
1668+
1669+ return false ;
16701670 }
16711671
1672- void checkAccessorType (QualType Ty, SourceRange Loc) {
1672+ bool checkAccessorType (QualType Ty, SourceRange Loc) {
16731673 assert (Util::isSyclAccessorType (Ty) &&
16741674 " Should only be called on SYCL accessor types." );
16751675
@@ -1678,13 +1678,13 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
16781678 dyn_cast<ClassTemplateSpecializationDecl>(RecD)) {
16791679 const TemplateArgumentList &TAL = CTSD->getTemplateArgs ();
16801680 TemplateArgument TA = TAL.get (0 );
1681- const QualType TemplateArgTy = TA.getAsType ();
1681+ llvm::DenseSet<QualType> Visited;
1682+ checkSYCLType (SemaRef, TA.getAsType (), Loc, Visited);
16821683
16831684 if (TAL.size () > 5 )
1684- checkPropertyListType (TAL.get (5 ), Loc.getBegin ());
1685- llvm::DenseSet<QualType> Visited;
1686- checkSYCLType (SemaRef, TemplateArgTy, Loc, Visited);
1685+ return checkPropertyListType (TAL.get (5 ), Loc.getBegin ());
16871686 }
1687+ return false ;
16881688 }
16891689
16901690public:
@@ -1706,12 +1706,12 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
17061706
17071707 bool handleSyclAccessorType (const CXXRecordDecl *, const CXXBaseSpecifier &BS,
17081708 QualType FieldTy) final {
1709- checkAccessorType (FieldTy, BS.getBeginLoc ());
1709+ IsInvalid |= checkAccessorType (FieldTy, BS.getBeginLoc ());
17101710 return isValid ();
17111711 }
17121712
17131713 bool handleSyclAccessorType (FieldDecl *FD, QualType FieldTy) final {
1714- checkAccessorType (FieldTy, FD->getLocation ());
1714+ IsInvalid |= checkAccessorType (FieldTy, FD->getLocation ());
17151715 return isValid ();
17161716 }
17171717
0 commit comments