Skip to content

Commit 8f50407

Browse files
Address review comments
1 parent fe94fce commit 8f50407

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,8 +2994,8 @@ class SYCLKernelNameTypeVisitor
29942994

29952995
void DiagnoseKernelNameType(const NamedDecl *DeclNamed) {
29962996
/*
2997-
This is a helper function which throws an error if the given declaration
2998-
is:
2997+
This is a helper function which throws an error if the kernel name
2998+
declaration is:
29992999
* declared within namespace 'std' (at any level)
30003000
e.g., namespace std { namespace literals { class Whatever; } }
30013001
h.single_task<std::literals::Whatever>([]() {});
@@ -3023,7 +3023,7 @@ class SYCLKernelNameTypeVisitor
30233023
const DeclContext *DeclCtx = DeclNamed->getDeclContext();
30243024
if (DeclCtx && !UnnamedLambdaEnabled) {
30253025

3026-
// Check if the declaration is declared within namespace
3026+
// Check if the kernel name declaration is declared within namespace
30273027
// "std" or "anonymous" namespace (at any level).
30283028
while (!DeclCtx->isTranslationUnit() && isa<NamespaceDecl>(DeclCtx)) {
30293029
const auto *NSDecl = cast<NamespaceDecl>(DeclCtx);
@@ -3044,6 +3044,9 @@ class SYCLKernelNameTypeVisitor
30443044
DeclCtx = DeclCtx->getParent();
30453045
}
30463046

3047+
// Check if the kernel name is a Tag declaration
3048+
// local to a non-namespace scope (i.e. Inside a function or within
3049+
// another Tag etc).
30473050
if (!DeclCtx->isTranslationUnit() && !isa<NamespaceDecl>(DeclCtx)) {
30483051
if (const auto *Tag = dyn_cast<TagDecl>(DeclNamed)) {
30493052
bool UnnamedTypeUsed = Tag->getIdentifier() == nullptr;

clang/test/SemaSYCL/stdtypes_kernel_type.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// RUN: %clang_cc1 -fsycl-is-device -sycl-std=2020 -DCHECK_ERROR -verify %s
22

3+
// This test verifies that an error is thrown if the kernel name declaration
4+
// is declared within 'std' namespace.
5+
36
#include "Inputs/sycl.hpp"
47

58
namespace std {

clang/test/SemaSYCL/unnamed-kernel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -fsyntax-only -sycl-std=2020 -verify %s
22
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -fsycl-unnamed-lambda -fsyntax-only -sycl-std=2020 -verify %s
33

4+
// This test verifies that an error is thrown when kernel names are declared within function/class scope
5+
// and if kernel names are empty.
6+
47
#include "sycl.hpp"
58

69
#ifdef __SYCL_UNNAMED_LAMBDA__

sycl/test/functor/kernel_functor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// RUN: cd %T
33
// RUN: %RUN_ON_HOST %t.out
44

5-
//==--- kernel_functor.cpp - Functors as SYCL kernel test ------------------==//
5+
//==--- kernel_functor.cpp -
6+
// This test illustrates defining kernels as named function objects (functors)
67
//
78
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
89
// See https://llvm.org/LICENSE.txt for license information.

0 commit comments

Comments
 (0)