1 // RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only -triple spir-unknown-unknown
2 // RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only -triple spir-unknown-unknown -DUNSAFEKERNELPARAMETER
4 #ifdef UNSAFEKERNELPARAMETER
5 #pragma OPENCL EXTENSION __cl_clang_non_portable_kernel_param_types : enable
9 kernel void m(); //expected-error{{kernel functions cannot be class members}}
13 //expected-error@+1{{'T' cannot be used as the type of a kernel parameter}}
14 kernel void templ(T par) { //expected-error{{kernel functions cannot be used in a template declaration, instantiation or specialization}}
18 kernel void bar(int par) { //expected-error{{kernel functions cannot be used in a template declaration, instantiation or specialization}}
21 kernel void foo(int); //expected-note{{previous declaration is here}}
23 kernel void foo(float); //expected-error{{conflicting types for 'foo'}}
25 kernel void int_v(int in);
26 kernel void int_p(__global int *in);
27 kernel void int_r(__global int &in);
28 kernel void int_p_p(__global int *__global *in);
29 kernel void int_p_r(__global int *__global &in);
30 kernel void int_p_p_r(__global int *__global *__global &in);
32 kernel void k_atomic_v(atomic_int in);
33 #ifndef UNSAFEKERNELPARAMETER
34 // expected-error@-2{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
36 kernel void k_atomic_p(__global atomic_int *in);
37 kernel void k_atomic_r(__global atomic_int &in);
39 kernel void k_pipe(read_only pipe int in, write_only pipe int out);
40 kernel void k_sampler(sampler_t in);
41 kernel void k_void(__global void *in);
43 typedef int int4 __attribute__((ext_vector_type(4)));
45 kernel void int4_v(int4 in);
46 kernel void int4_p(__global int4 *in);
47 kernel void int4_p_p(__global int4 *__global *in);
48 kernel void int4_r(__global int4 &in);
55 kernel void pod_v(POD in) {}
56 kernel void pod_p(__global POD *in) {}
57 kernel void pod_p_p(__global POD *__global *in) {}
58 kernel void pod_r(__global POD &in) {}
60 struct StandardLayout {
63 StandardLayout(int a, int b) : a(a), b(b) {}
66 kernel void standard_v(StandardLayout in) {}
67 #ifndef UNSAFEKERNELPARAMETER
68 //expected-error@-2{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
70 kernel void standard_p(__global StandardLayout *in) {}
71 kernel void standard_p_p(__global StandardLayout *__global *in) {}
72 kernel void standard_r(__global StandardLayout &in) {}
80 kernel void trivial_v(Trivial in) {}
81 #ifndef UNSAFEKERNELPARAMETER
82 //expected-error@-2{{'__private Trivial' cannot be used as the type of a kernel parameter}}
84 kernel void trivial_p(__global Trivial *in) {}
85 #ifndef UNSAFEKERNELPARAMETER
86 //expected-error@-2{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
88 kernel void trivial_p_p(__global Trivial *__global *in) {}
89 #ifndef UNSAFEKERNELPARAMETER
90 //expected-error@-2{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
92 kernel void trivial_r(__global Trivial &in) {}
93 #ifndef UNSAFEKERNELPARAMETER
94 //expected-error@-2{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
97 // Nested types and templates
109 // FIXME: (PR58590) Use of template parameter dependent types doesn't
110 // work yet due to lazy instantiation of reference types.
116 extern kernel void nested(constant Outer::Inner& r1, constant OuterTempl<int>::Inner& r2/*, constant Templ<int>& r3*/);