Skip to content

Commit 12d14e8

Browse files
[SYCL] Fix KernelNameInfo generated for empty template parameter pack (#1775)
* Fix KernelNameInfo generated in integration header when kernel name type is a template specialization class with empty template pack argument. This commit fixes a bug introduced by commit e7020a1 where an extra comma was printed before empty pack arguments Signed-off-by: Elizabeth Andrews <[email protected]>
1 parent f86b562 commit 12d14e8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,10 @@ static void printArguments(ASTContext &Ctx, raw_ostream &ArgOS,
19061906
for (unsigned I = 0; I < Args.size(); I++) {
19071907
const TemplateArgument &Arg = Args[I];
19081908

1909+
// If argument is an empty pack argument, skip printing comma and argument.
1910+
if (Arg.getKind() == TemplateArgument::ArgKind::Pack && !Arg.pack_size())
1911+
continue;
1912+
19091913
if (I != 0)
19101914
ArgOS << ", ";
19111915

clang/test/CodeGenSYCL/int_header1.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// CHECK:template <> struct KernelInfo<::nm1::KernelName4<KernelName7>> {
1313
// CHECK:template <> struct KernelInfo<::nm1::KernelName8<::nm1::nm2::C>> {
1414
// CHECK:template <> struct KernelInfo<::TmplClassInAnonNS<ClassInAnonNS>> {
15+
// CHECK:template <> struct KernelInfo<::nm1::KernelName9<char>> {
1516

1617
// This test checks if the SYCL device compiler is able to generate correct
1718
// integration header when the kernel name class is expressed in different
@@ -42,6 +43,9 @@ namespace nm1 {
4243
template <> class KernelName4<nm1::nm2::KernelName0> {};
4344
template <> class KernelName4<KernelName1> {};
4445

46+
template <typename T, typename...>
47+
class KernelName9;
48+
4549
} // namespace nm1
4650

4751
namespace {
@@ -128,6 +132,10 @@ struct MyWrapper {
128132
kernel_single_task<TmplClassInAnonNS<class ClassInAnonNS>>(
129133
[=]() { acc.use(); });
130134

135+
// Kernel name type is a templated specialization class with empty template pack argument
136+
kernel_single_task<nm1::KernelName9<char>>(
137+
[=]() { acc.use(); });
138+
131139
return 0;
132140
}
133141
};
@@ -151,5 +159,6 @@ int main() {
151159
KernelInfo<class nm1::KernelName4<class KernelName7>>::getName();
152160
KernelInfo<class nm1::KernelName8<nm1::nm2::C>>::getName();
153161
KernelInfo<class TmplClassInAnonNS<class ClassInAnonNS>>::getName();
162+
KernelInfo<class nm1::KernelName9<char>>::getName();
154163
#endif //__SYCL_DEVICE_ONLY__
155164
}

0 commit comments

Comments
 (0)