From 45b2ce310547fe844b333e9924a1ba26de72e232 Mon Sep 17 00:00:00 2001 From: Andrey Alekseenko Date: Tue, 3 Sep 2024 19:01:35 +0200 Subject: [PATCH] [SYCL] Fix -Wstring-concatenation in integration headers (#15197) A sentinel value added in #15175 fixed the problem of empty arrays, but for non-empty arrays was just concatenated to the last valid value. This produced warnings when compiling SYCL applications, and also meant that there is no sentinel value in the non-empty arrays. --- clang/lib/Sema/SemaSYCL.cpp | 6 +----- clang/test/CodeGenSYCL/int-header-empty-signatures.cpp | 2 +- clang/test/CodeGenSYCL/kernel-param-acc-array-ih.cpp | 2 +- clang/test/CodeGenSYCL/kernel-param-member-acc-array-ih.cpp | 2 +- clang/test/CodeGenSYCL/kernel-param-pod-array-ih.cpp | 2 +- clang/test/CodeGenSYCL/union-kernel-param-ih.cpp | 2 +- clang/test/CodeGenSYCL/wrapped-accessor.cpp | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index a3b2fb2728b55..e3e88358aaf24 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -6188,11 +6188,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) { O << "const char* const kernel_names[] = {\n"; for (unsigned I = 0; I < KernelDescs.size(); I++) { - O << " \"" << KernelDescs[I].Name << "\""; - - if (I < KernelDescs.size() - 1) - O << ","; - O << "\n"; + O << " \"" << KernelDescs[I].Name << "\",\n"; } // Add a sentinel to avoid warning if the collection is empty // (similar to what we do for kernel_signatures below). diff --git a/clang/test/CodeGenSYCL/int-header-empty-signatures.cpp b/clang/test/CodeGenSYCL/int-header-empty-signatures.cpp index 7cac7c335293a..88a1c7b182c85 100644 --- a/clang/test/CodeGenSYCL/int-header-empty-signatures.cpp +++ b/clang/test/CodeGenSYCL/int-header-empty-signatures.cpp @@ -6,7 +6,7 @@ // CHECK: static constexpr // CHECK-NEXT: const char* const kernel_names[] = { -// CHECK-NEXT: "_ZTSZ4mainE1K" +// CHECK-NEXT: "_ZTSZ4mainE1K", // CHECK-NEXT: "" // CHECK-NEXT: }; diff --git a/clang/test/CodeGenSYCL/kernel-param-acc-array-ih.cpp b/clang/test/CodeGenSYCL/kernel-param-acc-array-ih.cpp index d686dbdafae93..90e24fb115918 100644 --- a/clang/test/CodeGenSYCL/kernel-param-acc-array-ih.cpp +++ b/clang/test/CodeGenSYCL/kernel-param-acc-array-ih.cpp @@ -14,7 +14,7 @@ // CHECK: static constexpr // CHECK-NEXT: const char* const kernel_names[] = { -// CHECK-NEXT: "_ZTSZ4mainE8kernel_A" +// CHECK-NEXT: "_ZTSZ4mainE8kernel_A", // CHECK-NEXT: "" // CHECK-NEXT: }; diff --git a/clang/test/CodeGenSYCL/kernel-param-member-acc-array-ih.cpp b/clang/test/CodeGenSYCL/kernel-param-member-acc-array-ih.cpp index 1c39e5ff5463c..a71d2d9abc28a 100644 --- a/clang/test/CodeGenSYCL/kernel-param-member-acc-array-ih.cpp +++ b/clang/test/CodeGenSYCL/kernel-param-member-acc-array-ih.cpp @@ -14,7 +14,7 @@ // CHECK: static constexpr // CHECK-NEXT: const char* const kernel_names[] = { -// CHECK-NEXT: "_ZTSZ4mainE8kernel_C" +// CHECK-NEXT: "_ZTSZ4mainE8kernel_C", // CHECK-NEXT: "" // CHECK-NEXT: }; diff --git a/clang/test/CodeGenSYCL/kernel-param-pod-array-ih.cpp b/clang/test/CodeGenSYCL/kernel-param-pod-array-ih.cpp index 15582516d3de7..b06bb58c1b28a 100644 --- a/clang/test/CodeGenSYCL/kernel-param-pod-array-ih.cpp +++ b/clang/test/CodeGenSYCL/kernel-param-pod-array-ih.cpp @@ -15,7 +15,7 @@ // CHECK-NEXT: const char* const kernel_names[] = { // CHECK-NEXT: "_ZTSZ4mainE8kernel_B", // CHECK-NEXT: "_ZTSZ4mainE8kernel_C", -// CHECK-NEXT: "_ZTSZ4mainE8kernel_D" +// CHECK-NEXT: "_ZTSZ4mainE8kernel_D", // CHECK-NEXT: "" // CHECK-NEXT: }; diff --git a/clang/test/CodeGenSYCL/union-kernel-param-ih.cpp b/clang/test/CodeGenSYCL/union-kernel-param-ih.cpp index ba137d981f221..4f219c386b528 100644 --- a/clang/test/CodeGenSYCL/union-kernel-param-ih.cpp +++ b/clang/test/CodeGenSYCL/union-kernel-param-ih.cpp @@ -14,7 +14,7 @@ // CHECK: static constexpr // CHECK-NEXT: const char* const kernel_names[] = { -// CHECK-NEXT: "_ZTSZ4mainE8kernel_A" +// CHECK-NEXT: "_ZTSZ4mainE8kernel_A", // CHECK-NEXT: "" // CHECK-NEXT: }; diff --git a/clang/test/CodeGenSYCL/wrapped-accessor.cpp b/clang/test/CodeGenSYCL/wrapped-accessor.cpp index 556ec24298561..c47faec09f134 100644 --- a/clang/test/CodeGenSYCL/wrapped-accessor.cpp +++ b/clang/test/CodeGenSYCL/wrapped-accessor.cpp @@ -11,7 +11,7 @@ // CHECK: static constexpr // CHECK-NEXT: const char* const kernel_names[] = { -// CHECK-NEXT: "_ZTSZ4mainE14wrapped_access" +// CHECK-NEXT: "_ZTSZ4mainE14wrapped_access", // CHECK-NEXT: "" // CHECK-NEXT: };