func.cl 1.5 KB

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