File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4823,6 +4823,8 @@ DeviceFunctionDecl::DeviceFunctionDecl(
48234823 FuncInfo(getFuncInfo(FD)) {
48244824 if (FD->isFunctionTemplateSpecialization ()) {
48254825 SourceRange ReturnTypeRange = FD->getReturnTypeSourceRange ();
4826+ ReturnTypeRange = clang::dpct::getDefinitionRange (
4827+ ReturnTypeRange.getBegin (), ReturnTypeRange.getEnd ());
48264828 OffsetForAttr =
48274829 DpctGlobalInfo::getLocInfo (ReturnTypeRange.getBegin ()).second ;
48284830 }
@@ -4859,6 +4861,11 @@ DeviceFunctionDecl::DeviceFunctionDecl(
48594861 FuncInfo(getFuncInfo(Specialization)) {
48604862 IsDefFilePathNeeded = false ;
48614863
4864+ auto ReturnLoc = FTL.getReturnLoc ();
4865+ auto ReturnRange = clang::dpct::getDefinitionRange (ReturnLoc.getBeginLoc (),
4866+ ReturnLoc.getEndLoc ());
4867+ OffsetForAttr = DpctGlobalInfo::getLocInfo (ReturnRange.getBegin ()).second ;
4868+
48624869 buildReplaceLocInfo (FTL, Attrs);
48634870 buildTextureObjectParamsInfo (FTL.getParams ());
48644871 if (Specialization->hasAttr <CUDAGlobalAttr>()) {
Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ __global__ void Reset_kernel_parameters(void)
1010 g_mutex=0 ;
1111}
1212
13+ // CHECK: template <typename T> SYCL_EXTERNAL void template_test(T v) {};
14+ // CHECK: #define FUNC(T) template SYCL_EXTERNAL void template_test<T>(T v);
15+ // CHECK: FUNC(int)
16+ template <typename T> __global__ void template_test (T v) {};
17+
18+ #define FUNC (T ) template __global__ void template_test<T>(T v);
19+
20+ FUNC (int )
21+
1322// CHECK: SYCL_EXTERNAL void kernel_extern(const sycl::nd_item<3> &item_ct1, int *a) {
1423__global__ void kernel_extern() {
1524 __shared__ int a[360 ];
Original file line number Diff line number Diff line change 55// CHECK: SYCL_EXTERNAL void Reset_kernel_parameters(volatile int &g_mutex);
66__global__ void Reset_kernel_parameters (void );
77
8+ // CHECK: template <typename T> SYCL_EXTERNAL void template_test(T v);
9+ template <typename T> __global__ void template_test (T v);
10+
811// CHECK: SYCL_EXTERNAL void test_foo();
912__device__ void test_foo (void );
1013
Original file line number Diff line number Diff line change @@ -77,6 +77,9 @@ void test() {
7777 // CHECK-NEXT: });
7878 // CHECK-NEXT: }
7979 test_fp<<<1 , 1 >>> ();
80+
81+ template_test<int ><<<1 , 1 >>> (0 );
82+
8083}
8184
8285
You can’t perform that action at this time.
0 commit comments