File: invalid-kernel.clcpp

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (95 lines) | stat: -rw-r--r-- 3,301 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only -triple spir-unknown-unknown
// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only -triple spir-unknown-unknown -DUNSAFEKERNELPARAMETER

#ifdef UNSAFEKERNELPARAMETER
#pragma OPENCL EXTENSION __cl_clang_non_portable_kernel_param_types : enable
#endif

struct C {
  kernel void m(); //expected-error{{kernel functions cannot be class members}}
};

template <typename T>
//expected-error@+1{{'T' cannot be used as the type of a kernel parameter}}
kernel void templ(T par) { //expected-error{{kernel functions cannot be used in a template declaration, instantiation or specialization}}
}

template <int>
kernel void bar(int par) { //expected-error{{kernel functions cannot be used in a template declaration, instantiation or specialization}}
}

kernel void foo(int); //expected-note{{previous declaration is here}}

kernel void foo(float); //expected-error{{conflicting types for 'foo'}}

kernel void int_v(int in);
kernel void int_p(__global int *in);
kernel void int_r(__global int &in);
kernel void int_p_p(__global int *__global *in);
kernel void int_p_r(__global int *__global &in);
kernel void int_p_p_r(__global int *__global *__global &in);

kernel void k_atomic_v(atomic_int in);
#ifndef UNSAFEKERNELPARAMETER
// expected-error@-2{{'__private atomic_int' (aka '__private _Atomic(int)') cannot be used as the type of a kernel parameter}}
#endif
kernel void k_atomic_p(__global atomic_int *in);
kernel void k_atomic_r(__global atomic_int &in);

kernel void k_pipe(read_only pipe int in, write_only pipe int out);
kernel void k_sampler(sampler_t in);
kernel void k_void(__global void *in);

typedef int int4 __attribute__((ext_vector_type(4)));

kernel void int4_v(int4 in);
kernel void int4_p(__global int4 *in);
kernel void int4_p_p(__global int4 *__global *in);
kernel void int4_r(__global int4 &in);

struct POD {
  int a;
  int b;
};

kernel void pod_v(POD in) {}
kernel void pod_p(__global POD *in) {}
kernel void pod_p_p(__global POD *__global *in) {}
kernel void pod_r(__global POD &in) {}

struct StandardLayout {
  int a;
  int b;
  StandardLayout(int a, int b) : a(a), b(b) {}
};

kernel void standard_v(StandardLayout in) {}
#ifndef UNSAFEKERNELPARAMETER
//expected-error@-2{{'__private StandardLayout' cannot be used as the type of a kernel parameter}}
#endif
kernel void standard_p(__global StandardLayout *in) {}
kernel void standard_p_p(__global StandardLayout *__global *in) {}
kernel void standard_r(__global StandardLayout &in) {}

struct Trivial {
  int a;
private:
  int b;
};

kernel void trivial_v(Trivial in) {}
#ifndef UNSAFEKERNELPARAMETER
//expected-error@-2{{'__private Trivial' cannot be used as the type of a kernel parameter}}
#endif
kernel void trivial_p(__global Trivial *in) {}
#ifndef UNSAFEKERNELPARAMETER
//expected-error@-2{{'__global Trivial *__private' cannot be used as the type of a kernel parameter}}
#endif
kernel void trivial_p_p(__global Trivial *__global *in) {}
#ifndef UNSAFEKERNELPARAMETER
//expected-error@-2{{'__global Trivial *__global *__private' cannot be used as the type of a kernel parameter}}
#endif
kernel void trivial_r(__global Trivial &in) {}
#ifndef UNSAFEKERNELPARAMETER
//expected-error@-2{{'__global Trivial &__private' cannot be used as the type of a kernel parameter}}
#endif