Skip to content

Commit 954bbfb

Browse files
Address review comments
1 parent 643bc94 commit 954bbfb

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ let Component = "Sema" in {
1414
let CategoryName = "Semantic Issue" in {
1515
def note_previous_decl : Note<"%0 declared here">;
1616
def note_entity_declared_at : Note<"%0 declared here">;
17+
def note_nullptr_used : Note<"nullptr is a prvalue of type std::nullptr_t">;
1718
def note_callee_decl : Note<"%0 declared here">;
1819
def note_defined_here : Note<"%0 defined here">;
1920

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,13 +2834,13 @@ class SYCLKernelNameTypeVisitor
28342834
Sema &S;
28352835
SourceLocation KernelInvocationFuncLoc;
28362836
using InnerTypeVisitor = TypeVisitor<SYCLKernelNameTypeVisitor>;
2837-
using InnerTAVisitor =
2837+
using InnerTemplArgVisitor =
28382838
ConstTemplateArgumentVisitor<SYCLKernelNameTypeVisitor>;
28392839
bool IsInvalid = false;
28402840

28412841
void VisitTemplateArgs(ArrayRef<TemplateArgument> Args) {
2842-
for (size_t I = 0, E = Args.size(); I < E; ++I)
2843-
Visit(Args[I]);
2842+
for (auto &A : Args)
2843+
Visit(A);
28442844
}
28452845

28462846
public:
@@ -2857,6 +2857,7 @@ class SYCLKernelNameTypeVisitor
28572857
if (T->isNullPtrType()) {
28582858
S.Diag(KernelInvocationFuncLoc, diag::err_sycl_kernel_incorrectly_named)
28592859
<< /* kernel name cannot be a type in the std namespace */ 3;
2860+
S.Diag(KernelInvocationFuncLoc, diag::note_nullptr_used);
28602861
IsInvalid = true;
28612862
}
28622863
return;
@@ -2874,7 +2875,7 @@ class SYCLKernelNameTypeVisitor
28742875
void Visit(const TemplateArgument &TA) {
28752876
if (TA.isNull())
28762877
return;
2877-
InnerTAVisitor::Visit(TA);
2878+
InnerTemplArgVisitor::Visit(TA);
28782879
}
28792880

28802881
void VisitEnumType(const EnumType *T) {
@@ -2903,7 +2904,7 @@ class SYCLKernelNameTypeVisitor
29032904
<< /* kernel name cannot be a type in the std namespace */ 3;
29042905
IsInvalid = true;
29052906
return;
2906-
} else {
2907+
}
29072908
if (!DeclCtx->isTranslationUnit() && !isa<NamespaceDecl>(DeclCtx)) {
29082909
const bool KernelNameIsMissing = Tag->getName().empty();
29092910
if (KernelNameIsMissing) {
@@ -2912,7 +2913,7 @@ class SYCLKernelNameTypeVisitor
29122913
<< /* kernel name is missing */ 0;
29132914
IsInvalid = true;
29142915
return;
2915-
} else {
2916+
}
29162917
if (Tag->isCompleteDefinition()) {
29172918
S.Diag(KernelInvocationFuncLoc,
29182919
diag::err_sycl_kernel_incorrectly_named)
@@ -2923,9 +2924,7 @@ class SYCLKernelNameTypeVisitor
29232924

29242925
S.Diag(Tag->getSourceRange().getBegin(), diag::note_previous_decl)
29252926
<< Tag->getName();
2926-
}
29272927
}
2928-
}
29292928
}
29302929
}
29312930

clang/test/CodeGenSYCL/stdtypes_kernel_type.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -sycl-std=2020 -DCHECK_ERROR -verify %s
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -sycl-std=2020 -DCHECK_ERROR -verify %s
22

3-
#include "sycl.hpp"
3+
#include "Inputs/sycl.hpp"
44

55
namespace std {
66
typedef long unsigned int size_t;
@@ -21,6 +21,7 @@ queue q;
2121
int main() {
2222
#ifdef CHECK_ERROR
2323
// expected-error@Inputs/sycl.hpp:328 5 {{kernel name cannot be a type in the "std" namespace}}
24+
// expected-note@Inputs/sycl.hpp:328 3 {{nullptr is a prvalue of type std::nullptr_t}}
2425
q.submit([&](handler &h) {
2526
// expected-note@+1{{in instantiation of function template specialization}}
2627
h.single_task<std::nullptr_t>([=] {});

0 commit comments

Comments
 (0)