1 | // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown |
2 | |
3 | // Variadic functions |
4 | void vararg_f(int, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} |
5 | void __vararg_f(int, ...); |
6 | typedef void (*vararg_fptr_t)(int, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} |
7 | // expected-error@-1{{pointers to functions are not allowed}} |
8 | int printf(__constant const char *st, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} |
9 | |
10 | // Struct type with function pointer field |
11 | typedef struct s |
12 | { |
13 | void (*f)(struct s *self, int *i); // expected-error{{pointers to functions are not allowed}} |
14 | } s_t; |
15 | |
16 | //Function pointer |
17 | void foo(void*); |
18 | |
19 | // Expect no diagnostics for an empty parameter list. |
20 | void bar(); |
21 | |
22 | void bar() |
23 | { |
24 | // declaring a function pointer is an error |
25 | void (*fptr)(int); // expected-error{{pointers to functions are not allowed}} |
26 | |
27 | // taking the address of a function is an error |
28 | foo((void*)foo); // expected-error{{taking address of function is not allowed}} |
29 | foo(&foo); // expected-error{{taking address of function is not allowed}} |
30 | |
31 | // initializing an array with the address of functions is an error |
32 | void* vptrarr[2] = {foo, &foo}; // expected-error{{taking address of function is not allowed}} expected-error{{taking address of function is not allowed}} |
33 | |
34 | // just calling a function is correct |
35 | foo(0); |
36 | } |
37 | |