blob: dc5b44057b19ffbacb60c3ed973e40f322adced1 [file] [log] [blame]
Pekka Jaaskelainen8690a682014-02-20 13:52:08 +00001// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
2
Anastasia Stulova7c305332016-10-28 12:59:39 +00003// 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}}
Alexey Bader037dbe952017-06-02 18:08:58 +00007 // expected-error@-1{{pointers to functions are not allowed}}
Anastasia Stulova7c305332016-10-28 12:59:39 +00008int printf(__constant const char *st, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
9
Alexey Bader037dbe952017-06-02 18:08:58 +000010// 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
Anastasia Stulova7c305332016-10-28 12:59:39 +000016//Function pointer
Pekka Jaaskelainen8690a682014-02-20 13:52:08 +000017void 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
Anastasia Stulovacf04d042016-01-05 14:39:27 +000028 // 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
Pekka Jaaskelainen8690a682014-02-20 13:52:08 +000031 // just calling a function is correct
32 foo(0);
33}