@@ -2836,11 +2836,14 @@ class SYCLKernelNameTypeVisitor
2836
2836
using InnerTypeVisitor = TypeVisitor<SYCLKernelNameTypeVisitor>;
2837
2837
using InnerTAVisitor =
2838
2838
ConstTemplateArgumentVisitor<SYCLKernelNameTypeVisitor>;
2839
+ bool IsInvalid = false ;
2839
2840
2840
2841
public:
2841
2842
SYCLKernelNameTypeVisitor (Sema &S, SourceLocation KernelInvocationFuncLoc)
2842
2843
: S(S), KernelInvocationFuncLoc(KernelInvocationFuncLoc) {}
2843
2844
2845
+ bool isValid () { return !IsInvalid; }
2846
+
2844
2847
void Visit (QualType T) {
2845
2848
if (T.isNull ())
2846
2849
return ;
@@ -2872,6 +2875,7 @@ class SYCLKernelNameTypeVisitor
2872
2875
<< /* Unscoped enum requires fixed underlying type */ 2 ;
2873
2876
S.Diag (ED->getSourceRange ().getBegin (), diag::note_entity_declared_at)
2874
2877
<< ED;
2878
+ IsInvalid = true ;
2875
2879
}
2876
2880
}
2877
2881
@@ -2888,12 +2892,14 @@ class SYCLKernelNameTypeVisitor
2888
2892
if (KernelNameIsMissing) {
2889
2893
S.Diag (KernelInvocationFuncLoc, diag::err_sycl_kernel_incorrectly_named)
2890
2894
<< /* kernel name is missing */ 0 ;
2895
+ IsInvalid = true ;
2891
2896
} else {
2892
- if (Tag->isCompleteDefinition ())
2897
+ if (Tag->isCompleteDefinition ()) {
2893
2898
S.Diag (KernelInvocationFuncLoc,
2894
2899
diag::err_sycl_kernel_incorrectly_named)
2895
2900
<< /* kernel name is not globally-visible */ 1 ;
2896
- else
2901
+ IsInvalid = true ;
2902
+ } else
2897
2903
S.Diag (KernelInvocationFuncLoc, diag::warn_sycl_implicit_decl);
2898
2904
2899
2905
S.Diag (Tag->getSourceRange ().getBegin (), diag::note_previous_decl)
@@ -2970,11 +2976,13 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc, SourceRange CallLoc,
2970
2976
SyclKernelArgsSizeChecker ArgsSizeChecker (*this , Args[0 ]->getExprLoc ());
2971
2977
2972
2978
KernelObjVisitor Visitor{*this };
2973
- SYCLKernelNameTypeVisitor KernelTypeVisitor (*this , Args[0 ]->getExprLoc ());
2979
+ SYCLKernelNameTypeVisitor KernelNameTypeVisitor (*this , Args[0 ]->getExprLoc ());
2980
+
2981
+ DiagnosingSYCLKernel = true ;
2982
+
2974
2983
// Emit diagnostics for SYCL device kernels only
2975
2984
if (LangOpts.SYCLIsDevice )
2976
- KernelTypeVisitor.Visit (KernelNameType);
2977
- DiagnosingSYCLKernel = true ;
2985
+ KernelNameTypeVisitor.Visit (KernelNameType);
2978
2986
Visitor.VisitRecordBases (KernelObj, FieldChecker, UnionChecker, DecompMarker);
2979
2987
Visitor.VisitRecordFields (KernelObj, FieldChecker, UnionChecker,
2980
2988
DecompMarker);
@@ -2987,7 +2995,9 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc, SourceRange CallLoc,
2987
2995
Visitor.VisitRecordFields (KernelObj, ArgsSizeChecker);
2988
2996
}
2989
2997
DiagnosingSYCLKernel = false ;
2990
- if (!FieldChecker.isValid () || !UnionChecker.isValid ())
2998
+ // Set the kernel function as invalid, if any of the checkers fail validation.
2999
+ if (!FieldChecker.isValid () || !UnionChecker.isValid () ||
3000
+ !KernelNameTypeVisitor.isValid ())
2991
3001
KernelFunc->setInvalidDecl ();
2992
3002
}
2993
3003
0 commit comments