Skip to content

Commit 72007a3

Browse files
authored
[SYCL] Add a sentinel empty string to kernel names array (#15175)
We create a kernel_names array in the integration header even when the list of names is empty. This leads to diagnostics about zero-length arrays in pedantic modes. This change adds an empty string as a sentinel node to all kernel_names arrays so the array is never empty.
1 parent 099865e commit 72007a3

9 files changed

+12
-1
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6169,6 +6169,9 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
61696169
O << ",";
61706170
O << "\n";
61716171
}
6172+
// Add a sentinel to avoid warning if the collection is empty
6173+
// (similar to what we do for kernel_signatures below).
6174+
O << " \"\",\n";
61726175
O << "};\n\n";
61736176

61746177
O << "// array representing signatures of all kernels defined in the\n";

clang/test/CodeGenSYCL/free_function_int_header.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ template <> void ff_3<double>(double *ptr, double start, double end) {
4949
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_3IiEvPT_S0_S0_
5050
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_3IfEvPT_S0_S0_
5151
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_3IdEvPT_S0_S0_
52+
// CHECK-NEXT: ""
5253
// CHECK-NEXT: };
5354

5455
// CHECK: const kernel_param_desc_t kernel_signatures[] = {
@@ -201,4 +202,4 @@ template <> void ff_3<double>(double *ptr, double start, double end) {
201202
// CHECK-NEXT: kernel_id ext::oneapi::experimental::get_kernel_id<__sycl_shim5()>() {
202203
// CHECK-NEXT: return sycl::detail::get_kernel_id_impl(std::string_view{"_Z18__sycl_kernel_ff_3IdEvPT_S0_S0_"});
203204
// CHECK-NEXT: }
204-
// CHECK-NEXT: }
205+
// CHECK-NEXT: }

clang/test/CodeGenSYCL/int-header-empty-signatures.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// CHECK: static constexpr
88
// CHECK-NEXT: const char* const kernel_names[] = {
99
// CHECK-NEXT: "_ZTSZ4mainE1K"
10+
// CHECK-NEXT: ""
1011
// CHECK-NEXT: };
1112

1213
// CHECK: static constexpr

clang/test/CodeGenSYCL/integration_header.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// CHECK-NEXT: "_ZTSZ4mainE16accessor_in_base"
2323
// CHECK-NEXT: "_ZTSZ4mainE15annotated_types"
2424
// CHECK-NEXT: "_ZTS10FinalClass"
25+
// CHECK-NEXT: ""
2526
// CHECK-NEXT: };
2627
//
2728
// CHECK: static constexpr

clang/test/CodeGenSYCL/kernel-param-acc-array-ih.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// CHECK: static constexpr
1616
// CHECK-NEXT: const char* const kernel_names[] = {
1717
// CHECK-NEXT: "_ZTSZ4mainE8kernel_A"
18+
// CHECK-NEXT: ""
1819
// CHECK-NEXT: };
1920

2021
// CHECK: static constexpr

clang/test/CodeGenSYCL/kernel-param-member-acc-array-ih.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// CHECK: static constexpr
1616
// CHECK-NEXT: const char* const kernel_names[] = {
1717
// CHECK-NEXT: "_ZTSZ4mainE8kernel_C"
18+
// CHECK-NEXT: ""
1819
// CHECK-NEXT: };
1920

2021
// CHECK: static constexpr

clang/test/CodeGenSYCL/kernel-param-pod-array-ih.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// CHECK-NEXT: "_ZTSZ4mainE8kernel_B",
1717
// CHECK-NEXT: "_ZTSZ4mainE8kernel_C",
1818
// CHECK-NEXT: "_ZTSZ4mainE8kernel_D"
19+
// CHECK-NEXT: ""
1920
// CHECK-NEXT: };
2021

2122
// CHECK: static constexpr

clang/test/CodeGenSYCL/union-kernel-param-ih.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// CHECK: static constexpr
1616
// CHECK-NEXT: const char* const kernel_names[] = {
1717
// CHECK-NEXT: "_ZTSZ4mainE8kernel_A"
18+
// CHECK-NEXT: ""
1819
// CHECK-NEXT: };
1920

2021
// CHECK: static constexpr

clang/test/CodeGenSYCL/wrapped-accessor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// CHECK: static constexpr
1313
// CHECK-NEXT: const char* const kernel_names[] = {
1414
// CHECK-NEXT: "_ZTSZ4mainE14wrapped_access"
15+
// CHECK-NEXT: ""
1516
// CHECK-NEXT: };
1617

1718
// CHECK: static constexpr

0 commit comments

Comments
 (0)