Debian Codegraph @

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

raw
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only -fsycl-is-device -verify %s
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 -fsyntax-only -fsycl-is-device -verify %s
3
4 // These tests validate that the kernel name type argument provided to the
5 // sycl_kernel_entry_point attribute meets the requirements of a SYCL kernel
6 // name as described in section 5.2, "Naming of kernels", of the SYCL 2020
7 // specification.
8
9 struct S1;
10 // expected-warning@+3 {{redundant 'clang::sycl_kernel_entry_point' attribute}}
11 // expected-note@+1 {{previous attribute is here}}
12 [[clang::sycl_kernel_entry_point(S1),
13 clang::sycl_kernel_entry_point(S1)]]
14 void ok1();
15
16 // expected-error@+1 {{'int' is not a valid SYCL kernel name type; a non-union class type is required}}
17 [[clang::sycl_kernel_entry_point(int)]] void bad2();
18
19 // expected-error@+1 {{'int ()' is not a valid SYCL kernel name type; a non-union class type is required}}
20 [[clang::sycl_kernel_entry_point(int())]] void bad3();
21
22 // expected-error@+1 {{'int (*)()' is not a valid SYCL kernel name type; a non-union class type is required}}
23 [[clang::sycl_kernel_entry_point(int(*)())]] void bad4();
24
25 // expected-error@+1 {{'int (&)()' is not a valid SYCL kernel name type; a non-union class type is required}}
26 [[clang::sycl_kernel_entry_point(int(&)())]] void bad5();
27
28 // expected-error@+1 {{'decltype(nullptr)' (aka 'std::nullptr_t') is not a valid SYCL kernel name type; a non-union class type is required}}
29 [[clang::sycl_kernel_entry_point(decltype(nullptr))]] void bad6();
30
31 union U7; // #U7-decl
32 // expected-error@+2 {{'U7' is not a valid SYCL kernel name type; a non-union class type is required}}
33 // expected-note@#U7-decl {{'U7' declared here}}
34 [[clang::sycl_kernel_entry_point(U7)]] void bad7();
35
36 enum E8 {}; // #E8-decl
37 // expected-error@+2 {{'E8' is not a valid SYCL kernel name type; a non-union class type is required}}
38 // expected-note@#E8-decl {{'E8' declared here}}
39 [[clang::sycl_kernel_entry_point(E8)]] void bad8();
40
41 enum E9 : int; // #E9-decl
42 // expected-error@+2 {{'E9' is not a valid SYCL kernel name type; a non-union class type is required}}
43 // expected-note@#E9-decl {{'E9' declared here}}
44 [[clang::sycl_kernel_entry_point(E9)]] void bad9();
45
46 struct B10 {
47 struct MS;
48 };
49 // FIXME-expected-error@+1 {{the 'clang::sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
50 [[clang::sycl_kernel_entry_point(B10::MS)]] void bad10();
51
52 struct B11 {
53 struct MS;
54 };
55 // FIXME-expected-error@+3 {{the 'clang::sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
56 template<typename T>
57 [[clang::sycl_kernel_entry_point(typename T::MS)]] void bad11() {}
58 template void bad11<B11>();
59
60 template<typename T>
61 [[clang::sycl_kernel_entry_point(T)]] void bad12();
62 void f12() {
63 // FIXME-expected-error@+2 {{the 'clang::sycl_kernel_entry_point' attribute argument must be a forward declarable class type}}
64 struct LS;
65 bad12<LS>();
66 }
67
68 struct B13_1;
69 struct B13_2;
70 // expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B13_2' vs 'B13_1'}}
71 // expected-note@+1 {{'bad13' declared here}}
72 [[clang::sycl_kernel_entry_point(B13_1)]] void bad13();
73 [[clang::sycl_kernel_entry_point(B13_2)]] void bad13() {}
74
75 struct B14_1;
76 struct B14_2;
77 // expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B14_2' vs 'B14_1'}}
78 // expected-note@+1 {{previous attribute is here}}
79 [[clang::sycl_kernel_entry_point(B14_1),
80 clang::sycl_kernel_entry_point(B14_2)]]
81 void bad14();
82
83 struct B15;
84 // expected-error@+3 {{the 'clang::sycl_kernel_entry_point' kernel name argument conflicts with a previous declaration}}
85 // expected-note@+1 {{previous declaration is here}}
86 [[clang::sycl_kernel_entry_point(B15)]] void bad15_1();
87 [[clang::sycl_kernel_entry_point(B15)]] void bad15_2();
88
89 struct B16_1;
90 struct B16_2;
91 // expected-error@+4 {{the 'clang::sycl_kernel_entry_point' kernel name argument does not match prior declaration: 'B16_2' vs 'B16_1'}}
92 // expected-note@+1 {{'bad16' declared here}}
93 [[clang::sycl_kernel_entry_point(B16_1)]] void bad16();
94 void bad16(); // The attribute from the previous declaration is inherited.
95 [[clang::sycl_kernel_entry_point(B16_2)]] void bad16();
96
97 template<int>
98 struct B17 {
99 // expected-error@+1 {{'int' is not a valid SYCL kernel name type; a non-union class type is required}}
100 [[clang::sycl_kernel_entry_point(int)]]
101 static void bad17();
102 };
103
104 template<int>
105 struct B18 {
106 // expected-error@+1 {{'int' is not a valid SYCL kernel name type; a non-union class type is required}}
107 [[clang::sycl_kernel_entry_point(int)]]
108 friend void bad18() {}
109 };
110
111 template<typename KNT>
112 struct B19 {
113 // expected-error@+1 {{'int' is not a valid SYCL kernel name type; a non-union class type is required}}
114 [[clang::sycl_kernel_entry_point(KNT)]]
115 friend void bad19() {}
116 };
117 // expected-note@+1 {{in instantiation of template class 'B19<int>' requested here}}
118 B19<int> b19;