@@ -2852,6 +2852,7 @@ class SYCLKernelNameTypeVisitor
2852
2852
if (T->isNullPtrType ())
2853
2853
S.Diag (KernelInvocationFuncLoc, diag::err_sycl_kernel_incorrectly_named)
2854
2854
<< /* kernel name cannot be a type in the std namespace */ 3 ;
2855
+ IsInvalid = true ;
2855
2856
return ;
2856
2857
}
2857
2858
// If KernelNameType has template args visit each template arg via
@@ -2890,21 +2891,23 @@ class SYCLKernelNameTypeVisitor
2890
2891
void VisitTagDecl (const TagDecl *Tag) {
2891
2892
bool UnnamedLambdaEnabled =
2892
2893
S.getASTContext ().getLangOpts ().SYCLUnnamedLambda ;
2893
- const DeclContext *DC = Tag->getDeclContext ();
2894
- if (DC && !UnnamedLambdaEnabled) {
2895
- auto *NS = dyn_cast_or_null<NamespaceDecl>(DC );
2896
- if (NS && NS ->isStdNamespace ()) {
2894
+ const DeclContext *DeclCtx = Tag->getDeclContext ();
2895
+ if (DeclCtx && !UnnamedLambdaEnabled) {
2896
+ auto *NameSpace = dyn_cast_or_null<NamespaceDecl>(DeclCtx );
2897
+ if (NameSpace && NameSpace ->isStdNamespace ()) {
2897
2898
S.Diag (KernelInvocationFuncLoc, diag::err_sycl_kernel_incorrectly_named)
2898
2899
<< /* kernel name cannot be a type in the std namespace */ 3 ;
2899
2900
IsInvalid = true ;
2901
+ return ;
2900
2902
} else {
2901
- if (!DC ->isTranslationUnit () && !isa<NamespaceDecl>(DC )) {
2903
+ if (!DeclCtx ->isTranslationUnit () && !isa<NamespaceDecl>(DeclCtx )) {
2902
2904
const bool KernelNameIsMissing = Tag->getName ().empty ();
2903
2905
if (KernelNameIsMissing) {
2904
2906
S.Diag (KernelInvocationFuncLoc,
2905
2907
diag::err_sycl_kernel_incorrectly_named)
2906
2908
<< /* kernel name is missing */ 0 ;
2907
2909
IsInvalid = true ;
2910
+ return ;
2908
2911
} else {
2909
2912
if (Tag->isCompleteDefinition ()) {
2910
2913
S.Diag (KernelInvocationFuncLoc,
0 commit comments