11// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -sycl-std=2020 -fsycl-int-header=%t.h %s
22// RUN: FileCheck -input-file=%t.h %s
33
4- // This test checks integration header contents free functions kernels in
5- // presense of template arguments.
4+ // This test checks integration header contents for free functions kernels with
5+ // parameter types that have default template arguments.
66
77#include " mock_properties.hpp"
88#include " sycl.hpp"
@@ -13,6 +13,13 @@ struct notatuple {
1313 int a;
1414};
1515
16+ namespace ns1 {
17+ template <typename A = notatuple>
18+ class hasDefaultArg {
19+
20+ };
21+ }
22+
1623template <typename T, typename = int , int a = 12 , typename = notatuple, typename ...TS> struct Arg {
1724 T val;
1825};
@@ -24,6 +31,11 @@ simple(Arg<char>){
2431
2532}
2633
34+ [[__sycl_detail__::add_ir_attributes_function(" sycl-single-task-kernel" ,
35+ 2 )]] void
36+ simple1 (ns::Arg<ns::ns1::hasDefaultArg<>>){
37+ }
38+
2739
2840template <typename T>
2941[[__sycl_detail__::add_ir_attributes_function(" sycl-nd-range-kernel" , 2 )]] void
@@ -41,7 +53,12 @@ templated2(Arg<T, notatuple>, T end) {
4153
4254template void templated2 (Arg<int , notatuple>, int );
4355
44- // CHECK: Definition of _ZN16__sycl_kernel_ns6simpleENS_3ArgIciLi12ENS_9notatupleEJEEE as a free function kernel
56+ template <typename T, int a = 3 >
57+ [[__sycl_detail__::add_ir_attributes_function(" sycl-nd-range-kernel" , 2 )]] void
58+ templated3 (Arg<T, notatuple, a, ns1::hasDefaultArg<>, int , int >, T end) {
59+ }
60+
61+ template void templated3 (Arg<int , notatuple, 3 , ns1::hasDefaultArg<>, int , int >, int );
4562
4663// CHECK: Forward declarations of kernel and its argument types:
4764// CHECK-NEXT: namespace ns {
@@ -56,15 +73,28 @@ template void templated2(Arg<int, notatuple>, int);
5673// CHECK-NEXT: return (void (*)(struct ns::Arg<char, int, 12, struct ns::notatuple>))simple;
5774// CHECK-NEXT: }
5875
59- // CHECK: Definition of _Z23__sycl_kernel_templatedIiEvN2ns3ArgIT_fLi3ENS0_9notatupleEJEEES2_ as a free function kernel
60- // CHECK: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple>, T end);
76+ // CHECK: Forward declarations of kernel and its argument types:
77+ // CHECK: namespace ns {
78+ // CHECK: namespace ns1 {
79+ // CHECK-NEXT: template <typename A> class hasDefaultArg;
80+ // CHECK-NEXT: }
81+
82+ // CHECK: void simple1(ns::Arg<ns::ns1::hasDefaultArg<ns::notatuple>, int, 12, ns::notatuple>);
6183// CHECK-NEXT: static constexpr auto __sycl_shim2() {
84+ // CHECK-NEXT: return (void (*)(struct ns::Arg<class ns::ns1::hasDefaultArg<struct ns::notatuple>, int, 12, struct ns::notatuple>))simple1;
85+ // CHECK-NEXT: }
86+
87+ // CHECK: template <typename T> void templated(ns::Arg<T, float, 3, ns::notatuple>, T end);
88+ // CHECK-NEXT: static constexpr auto __sycl_shim3() {
6289// CHECK-NEXT: return (void (*)(struct ns::Arg<int, float, 3, struct ns::notatuple>, int))templated<int>;
6390// CHECK-NEXT: }
6491
65- // CHECK: Definition of _Z24__sycl_kernel_templated2IiEvN2ns3ArgIT_NS0_9notatupleELi12ES3_JEEES2_ as a free function kernel
66- // CHECK: Forward declarations of kernel and its argument types:
6792// CHECK: template <typename T> void templated2(ns::Arg<T, ns::notatuple, 12, ns::notatuple>, T end);
68- // CHECK-NEXT: static constexpr auto __sycl_shim3 () {
93+ // CHECK-NEXT: static constexpr auto __sycl_shim4 () {
6994// CHECK-NEXT: return (void (*)(struct ns::Arg<int, struct ns::notatuple, 12, struct ns::notatuple>, int))templated2<int>;
7095// CHECK-NEXT: }
96+
97+ // CHECK: template <typename T, int a> void templated3(ns::Arg<T, ns::notatuple, a, ns::ns1::hasDefaultArg<ns::notatuple>, int, int>, T end);
98+ // CHECK-NEXT: static constexpr auto __sycl_shim5() {
99+ // CHECK-NEXT: return (void (*)(struct ns::Arg<int, struct ns::notatuple, 3, class ns::ns1::hasDefaultArg<struct ns::notatuple>, int, int>, int))templated3<int, 3>;
100+ // CHECK-NEXT: }
0 commit comments