xref: /aosp_15_r20/external/clang/test/SemaOpenCL/func_ptr.cl (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
2*67e74705SXin Li
3*67e74705SXin Livoid foo(void*);
4*67e74705SXin Li
5*67e74705SXin Livoid bar()
6*67e74705SXin Li{
7*67e74705SXin Li  // declaring a function pointer is an error
8*67e74705SXin Li  void (*fptr)(int); // expected-error{{pointers to functions are not allowed}}
9*67e74705SXin Li
10*67e74705SXin Li  // taking the address of a function is an error
11*67e74705SXin Li  foo((void*)foo); // expected-error{{taking address of function is not allowed}}
12*67e74705SXin Li  foo(&foo); // expected-error{{taking address of function is not allowed}}
13*67e74705SXin Li
14*67e74705SXin Li  // initializing an array with the address of functions is an error
15*67e74705SXin Li  void* vptrarr[2] = {foo, &foo}; // expected-error{{taking address of function is not allowed}} expected-error{{taking address of function is not allowed}}
16*67e74705SXin Li
17*67e74705SXin Li  // just calling a function is correct
18*67e74705SXin Li  foo(0);
19*67e74705SXin Li}
20