File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -244,8 +244,9 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
244
244
diag::err_builtin_target_unsupported)
245
245
<< Name << " SYCL device" ;
246
246
}
247
- } else if ((!SemaRef.getLangOpts ().SYCLAllowFuncPtr ) &&
248
- !e->isTypeDependent ())
247
+ } else if (!SemaRef.getLangOpts ().SYCLAllowFuncPtr &&
248
+ !e->isTypeDependent () &&
249
+ !isa<CXXPseudoDestructorExpr>(e->getCallee ()))
249
250
SemaRef.Diag (e->getExprLoc (), diag::err_sycl_restrict)
250
251
<< Sema::KernelCallFunctionPointer;
251
252
return true ;
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -fsycl-is-device -verify -fsyntax-only -x c++ %s
2
+
3
+ template <typename functor_t >
4
+ struct functor_wrapper {
5
+ functor_t f;
6
+
7
+ auto operator ()() -> void {
8
+ return ;
9
+ };
10
+ };
11
+
12
+ // expected-error@+1 2{{SYCL kernel cannot have a class with a virtual function table}}
13
+ struct S { virtual void foo (); };
14
+ // expected-error@+1 2{{SYCL kernel cannot have a class with a virtual function table}}
15
+ struct T { virtual ~T (); };
16
+
17
+ template <typename name, typename Func>
18
+ __attribute__ ((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
19
+ // expected-no-note@+1
20
+ using DATA_I = int ;
21
+ // expected-note@+1{{used here}}
22
+ using DATA_S = S;
23
+ // expected-note@+1{{used here}}
24
+ using DATA_T = T;
25
+ // this expression should be okay
26
+ auto functor = [](DATA_I & v1, DATA_S &v2, DATA_T& v3) {
27
+ // expected-no-error@+1
28
+ v1.~DATA_I ();
29
+ // expected-note@+1{{used here}}
30
+ v2.~DATA_S ();
31
+ // expected-error@+2{{SYCL kernel cannot call a virtual function}}
32
+ // expected-note@+1{{used here}}
33
+ v3.~DATA_T ();
34
+ };
35
+ auto wrapped_functor = functor_wrapper<decltype (functor)>{functor};
36
+ wrapped_functor ();
37
+ }
38
+
39
+ int main () {
40
+ kernel_single_task<class fake_kernel >([]() { });
41
+ return 0 ;
42
+ }
You can’t perform that action at this time.
0 commit comments