@@ -1605,71 +1605,71 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
1605
1605
return false ;
1606
1606
}
1607
1607
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
+
1614
1613
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
+
1620
1618
const auto *AccPropListDecl =
1621
1619
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
+
1627
1625
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
+
1634
1632
for (TemplateArgument::pack_iterator Prop = TemplArg.pack_begin ();
1635
1633
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 ;
1642
1639
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 ;
1645
1643
}
1644
+ return false ;
1646
1645
}
1647
1646
1648
- void checkBufferLocationType (QualType PropTy, SourceLocation Loc) {
1647
+ bool checkBufferLocationType (QualType PropTy, SourceLocation Loc) {
1649
1648
const auto *PropDecl =
1650
1649
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
+
1656
1655
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
+
1663
1662
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 ;
1670
1670
}
1671
1671
1672
- void checkAccessorType (QualType Ty, SourceRange Loc) {
1672
+ bool checkAccessorType (QualType Ty, SourceRange Loc) {
1673
1673
assert (Util::isSyclAccessorType (Ty) &&
1674
1674
" Should only be called on SYCL accessor types." );
1675
1675
@@ -1678,13 +1678,13 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
1678
1678
dyn_cast<ClassTemplateSpecializationDecl>(RecD)) {
1679
1679
const TemplateArgumentList &TAL = CTSD->getTemplateArgs ();
1680
1680
TemplateArgument TA = TAL.get (0 );
1681
- const QualType TemplateArgTy = TA.getAsType ();
1681
+ llvm::DenseSet<QualType> Visited;
1682
+ checkSYCLType (SemaRef, TA.getAsType (), Loc, Visited);
1682
1683
1683
1684
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 ());
1687
1686
}
1687
+ return false ;
1688
1688
}
1689
1689
1690
1690
public:
@@ -1706,12 +1706,12 @@ class SyclKernelFieldChecker : public SyclKernelFieldHandler {
1706
1706
1707
1707
bool handleSyclAccessorType (const CXXRecordDecl *, const CXXBaseSpecifier &BS,
1708
1708
QualType FieldTy) final {
1709
- checkAccessorType (FieldTy, BS.getBeginLoc ());
1709
+ IsInvalid |= checkAccessorType (FieldTy, BS.getBeginLoc ());
1710
1710
return isValid ();
1711
1711
}
1712
1712
1713
1713
bool handleSyclAccessorType (FieldDecl *FD, QualType FieldTy) final {
1714
- checkAccessorType (FieldTy, FD->getLocation ());
1714
+ IsInvalid |= checkAccessorType (FieldTy, FD->getLocation ());
1715
1715
return isValid ();
1716
1716
}
1717
1717
0 commit comments