Debian Codegraph @

clang/test/SemaSYCL/sycl-kernel-entry-point-attr-kernel-name-module.cpp

raw
1 // Test that SYCL kernel name conflicts that occur across module boundaries are
2 // properly diagnosed and that declarations are properly merged so that spurious
3 // conflicts are not reported.
4
5 // RUN: rm -rf %t
6 // RUN: split-file %s %t
7 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
8 // RUN: -std=c++17 -fsycl-is-host %t/test.cpp -verify
9 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
10 // RUN: -std=c++17 -fsycl-is-device %t/test.cpp -verify
11
12 #--- module.modulemap
13 module M1 { header "m1.h" }
14 module M2 { header "m2.h" }
15
16
17 #--- common.h
18 template<int> struct KN;
19
20 [[clang::sycl_kernel_entry_point(KN<1>)]]
21 void common_test1() {}
22
23 template<typename T>
24 [[clang::sycl_kernel_entry_point(T)]]
25 void common_test2() {}
26 template void common_test2<KN<2>>();
27
28
29 #--- m1.h
30 #include "common.h"
31
32 [[clang::sycl_kernel_entry_point(KN<3>)]]
33 void m1_test3() {} // << expected previous declaration note here.
34
35 template<typename T>
36 [[clang::sycl_kernel_entry_point(T)]]
37 void m1_test4() {} // << expected previous declaration note here.
38 template void m1_test4<KN<4>>();
39
40 [[clang::sycl_kernel_entry_point(KN<5>)]]
41 void m1_test5() {} // << expected previous declaration note here.
42
43 template<typename T>
44 [[clang::sycl_kernel_entry_point(T)]]
45 void m1_test6() {} // << expected previous declaration note here.
46 template void m1_test6<KN<6>>();
47
48
49 #--- m2.h
50 #include "common.h"
51
52 [[clang::sycl_kernel_entry_point(KN<3>)]]
53 void m2_test3() {} // << expected kernel name conflict here.
54
55 template<typename T>
56 [[clang::sycl_kernel_entry_point(T)]]
57 void m2_test4() {} // << expected kernel name conflict here.
58 template void m2_test4<KN<4>>();
59
60 [[clang::sycl_kernel_entry_point(KN<7>)]]
61 void m2_test7() {} // << expected previous declaration note here.
62
63 template<typename T>
64 [[clang::sycl_kernel_entry_point(T)]]
65 void m2_test8() {} // << expected previous declaration note here.
66 template void m2_test8<KN<8>>();
67
68
69 #--- test.cpp
70 #include "m1.h"
71 #include "m2.h"
72
73 // Expected diagnostics for m1_test3() and m2_test3():
74 // [email protected]:4 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
75 // [email protected]:12 {{previous declaration is here}}
76
77 // Expected diagnostics for m1_test4<KN<4>>() and m2_test4<KN<4>>():
78 // [email protected]:8 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
79 // [email protected]:16 {{previous declaration is here}}
80
81 // expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
82 // [email protected]:4 {{previous declaration is here}}
83 [[clang::sycl_kernel_entry_point(KN<5>)]]
84 void test5() {}
85
86 // expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
87 // [email protected]:8 {{previous declaration is here}}
88 [[clang::sycl_kernel_entry_point(KN<6>)]]
89 void test6() {}
90
91 // expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
92 // [email protected]:12 {{previous declaration is here}}
93 [[clang::sycl_kernel_entry_point(KN<7>)]]
94 void test7() {}
95
96 // expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
97 // [email protected]:16 {{previous declaration is here}}
98 [[clang::sycl_kernel_entry_point(KN<8>)]]
99 void test8() {}
100
101 void f() {
102 common_test1();
103 common_test2<KN<2>>();
104 }