1*532dc62bSNikita Popov // RUN: %clang_cc1 -no-opaque-pointers -fsycl-is-device -emit-llvm -triple spir64 -verify -emit-llvm %s -o - | FileCheck %s
24eaf5846SElizabeth Andrews 
34eaf5846SElizabeth Andrews // expected-no-diagnostics
44eaf5846SElizabeth Andrews 
54eaf5846SElizabeth Andrews template <typename Name, typename Func>
kernel_single_task(const Func & kernelFunc)64eaf5846SElizabeth Andrews __attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
74eaf5846SElizabeth Andrews   kernelFunc();
84eaf5846SElizabeth Andrews }
94eaf5846SElizabeth Andrews 
101b1c8d83Shyeongyu kim // CHECK: define dso_local spir_func{{.*}}invoke_function{{.*}}(i32 ()* noundef %fptr, i32 addrspace(4)* noundef %ptr)
invoke_function(int (* fptr)(),int * ptr)114eaf5846SElizabeth Andrews void invoke_function(int (*fptr)(), int *ptr) {}
124eaf5846SElizabeth Andrews 
f()134eaf5846SElizabeth Andrews int f() { return 0; }
144eaf5846SElizabeth Andrews 
main()154eaf5846SElizabeth Andrews int main() {
164eaf5846SElizabeth Andrews   kernel_single_task<class fake_kernel>([=]() {
174eaf5846SElizabeth Andrews     int (*p)() = f;
184eaf5846SElizabeth Andrews     int (&r)() = *p;
194eaf5846SElizabeth Andrews     int a = 10;
204eaf5846SElizabeth Andrews     invoke_function(p, &a);
214eaf5846SElizabeth Andrews     invoke_function(r, &a);
224eaf5846SElizabeth Andrews     invoke_function(f, &a);
234eaf5846SElizabeth Andrews   });
244eaf5846SElizabeth Andrews   return 0;
254eaf5846SElizabeth Andrews }
26