1// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
2
3// Variadic functions
4void vararg_f(int, ...);                    // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
5void __vararg_f(int, ...);
6typedef 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}}
8int printf(__constant const char *st, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
9
10// Struct type with function pointer field
11typedef 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
17void foo(void*);
18
19void bar()
20{
21  // declaring a function pointer is an error
22  void (*fptr)(int); // expected-error{{pointers to functions are not allowed}}
23
24  // taking the address of a function is an error
25  foo((void*)foo); // expected-error{{taking address of function is not allowed}}
26  foo(&foo); // expected-error{{taking address of function is not allowed}}
27
28  // initializing an array with the address of functions is an error
29  void* vptrarr[2] = {foo, &foo}; // expected-error{{taking address of function is not allowed}} expected-error{{taking address of function is not allowed}}
30
31  // just calling a function is correct
32  foo(0);
33}
34