1 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
2 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DFUNCPTREXT
3 // RUN
: %clang_cc1 %s -cl-std
=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DVARARGEXT
6 #pragma OPENCL EXTENSION __cl_clang_function_pointers
: enable
9 #pragma OPENCL EXTENSION __cl_clang_variadic_functions
: enable
13 void vararg_f
(int, ...
);
15 // expected-error
@-
2 {{invalid prototype
, variadic arguments are not allowed in OpenCL
}}
17 void __vararg_f
(int, ...
);
18 typedef void
(*vararg_fptr_t
)(int, ...
);
20 // expected-error
@-
2 {{invalid prototype
, variadic arguments are not allowed in OpenCL
}}
23 // expected-error
@-
5 {{pointers to functions are not allowed
}}
25 int printf
(__constant const char
*st
, ...
);
27 // expected-error
@-
2 {{invalid prototype
, variadic arguments are not allowed in OpenCL
}}
30 // Struct type with function pointer field
33 void
(*f
)(struct s
*self
, int
*i
);
35 // expected-error
@-
2 {{pointers to functions are not allowed
}}
42 //expected-note
@-
2{{passing argument to parameter here
}}
45 // Expect no diagnostics for an empty parameter list.
50 // declaring a function pointer is an error
53 // expected-error
@-
2 {{pointers to functions are not allowed
}}
56 // taking the address of a function is an error
59 // expected-error
@-
2{{taking address of function is not allowed
}}
61 // FIXME
: Functions should probably be in the address space defined by the
62 // implementation. It might make sense to put them into the Default address
63 // space that is bind to a physical segment by the target rather than fixing
64 // it to any of the concrete OpenCL address spaces during parsing.
65 // expected-error
@-
8{{casting
'void
(*)(__private void
*__private
)' to type
'__private void
*' changes address space
}}
70 // expected-error
@-
2{{taking address of function is not allowed
}}
72 // expected-error
@-
4{{passing
'void
(*)(__private void
*__private
)' to parameter of type
'__private void
*' changes address space of pointer
}}
75 // FIXME
: If we stop rejecting the line below a bug
(PR49315) gets
76 // hit due to incorrectly handled pointer conversion.
78 // initializing an array with the address of functions is an error
79 void
* vptrarr
[2] = {foo, &foo}; // expected-error{{taking address of function is not allowed}} expected-error{{taking address of function is not allowed}}
82 // just calling a function is correct