Skip to content

Commit da651f6

Browse files
committed
Added tests for dependent and non-dependent hidden friend functions.
1 parent 97f58f4 commit da651f6

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct S6 {
7878
static void ok6();
7979
};
8080

81-
// Dependent friend function.
81+
// Dependent hidden friend definition.
8282
template<typename KNT>
8383
struct S7 {
8484
[[clang::sycl_kernel_entry_point(KNT)]]
@@ -88,24 +88,35 @@ void test_ok7() {
8888
ok7(S7<KN<7>>{});
8989
}
9090

91+
// Non-dependent hidden friend definition.
92+
struct S8Base {};
93+
template<typename>
94+
struct S8 : S8Base {
95+
[[clang::sycl_kernel_entry_point(KN<8>)]]
96+
friend void ok8(const S8Base&) {}
97+
};
98+
void test_ok8() {
99+
ok8(S8<int>{});
100+
}
101+
91102
// The sycl_kernel_entry_point attribute must match across declarations and
92103
// cannot be added for the first time after a definition.
93-
[[clang::sycl_kernel_entry_point(KN<8>)]]
94-
void ok8();
95-
[[clang::sycl_kernel_entry_point(KN<8>)]]
96-
void ok8();
97104
[[clang::sycl_kernel_entry_point(KN<9>)]]
98105
void ok9();
99-
void ok9() {}
100-
void ok10();
106+
[[clang::sycl_kernel_entry_point(KN<9>)]]
107+
void ok9();
101108
[[clang::sycl_kernel_entry_point(KN<10>)]]
109+
void ok10();
102110
void ok10() {}
111+
void ok11();
112+
[[clang::sycl_kernel_entry_point(KN<11>)]]
113+
void ok11() {}
103114

104115
using VOID = void;
105-
[[clang::sycl_kernel_entry_point(KN<11>)]]
106-
VOID ok11();
107116
[[clang::sycl_kernel_entry_point(KN<12>)]]
108-
const void ok12();
117+
VOID ok12();
118+
[[clang::sycl_kernel_entry_point(KN<13>)]]
119+
const void ok13();
109120

110121

111122
////////////////////////////////////////////////////////////////////////////////

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,21 @@ template<int>
9898
struct B17 {
9999
// expected-error@+1 {{'int' is not a valid SYCL kernel name type; a non-union class type is required}}
100100
[[clang::sycl_kernel_entry_point(int)]]
101-
static void bad_17();
101+
static void bad17();
102102
};
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;

0 commit comments

Comments
 (0)