1 // RUN
: %clang_cc1 -fsyntax-only -verify %s
3 #pragma OPENCL EXTENSION cl_khr_fp16
: enable
6 // Disallowed
: parameters with type
7 // bool
, half
, size_t
, ptrdiff_t
, intptr_t
, and uintptr_t
8 // or a struct
/ union with any of these types in them
10 // TODO
: Ban int types
, size_t
, ptrdiff_t ...
12 kernel void bool_arg
(bool x
) { } // expected-error
{{'bool
' cannot be used as the type of a kernel parameter
}}
14 kernel void half_arg
(half x
) { } // expected-error
{{'half
' cannot be used as the type of a kernel parameter
}}
16 typedef struct ContainsBool
// expected-note
{{within field of type
'ContainsBool
' declared here
}}
18 bool x
; // expected-note{{field of illegal type 'bool' declared here}}
21 kernel void bool_in_struct_arg
(ContainsBool x
) { } // expected-error
{{'ContainsBool
' (aka 'struct ContainsBool
') cannot be used as the type of a kernel parameter
}}
25 typedef struct FooImage2D
// expected-note
{{within field of type
'FooImage2D
' declared here
}}
27 image2d_t imageField
; // expected-note{{field of illegal type 'image2d_t' declared here}}
30 kernel void image_in_struct_arg
(FooImage2D arg
) { } // expected-error
{{struct kernel parameters may not contain pointers
}}
32 typedef struct Foo
// expected-note
{{within field of type
'Foo
' declared here
}}
34 int
* ptrField
; // expected-note{{field of illegal pointer type 'int *' declared here}}
37 kernel void pointer_in_struct_arg
(Foo arg
) { } // expected-error
{{struct kernel parameters may not contain pointers
}}
39 typedef union FooUnion
// expected-note
{{within field of type
'FooUnion
' declared here
}}
41 int
* ptrField
; // expected-note{{field of illegal pointer type 'int *' declared here}}
44 kernel void pointer_in_union_arg
(FooUnion arg
) { }// expected-error
{{union kernel parameters may not contain pointers
}}
46 typedef struct NestedPointer
// expected-note
2 {{within field of type
'NestedPointer
' declared here
}}
49 struct InnerNestedPointer
51 int
* ptrField
; // expected-note 3 {{field of illegal pointer type 'int *' declared here}}
52 } inner
; // expected-note 3 {{within field of type 'struct InnerNestedPointer' declared here}}
55 kernel void pointer_in_nested_struct_arg
(NestedPointer arg
) { }// expected-error
{{struct kernel parameters may not contain pointers
}}
57 struct NestedPointerComplex
// expected-note
{{within field of type
'NestedPointerComplex
' declared here
}}
62 struct InnerNestedPointerComplex
65 int
* innerPtrField
; // expected-note{{field of illegal pointer type 'int *' declared here}}
66 } inner
; // expected-note{{within field of type 'struct InnerNestedPointerComplex' declared here}}
72 kernel void pointer_in_nested_struct_arg_complex(struct NestedPointerComplex arg) { }// expected-error{{struct kernel parameters may not contain pointers}}
74 typedef struct NestedBool // expected-note 2 {{within field of type 'NestedBool' declared here}}
77 struct InnerNestedBool
79 bool boolField; // expected-note 2 {{field of illegal type 'bool' declared here}}
80 } inner; // expected-note 2 {{within field of type 'struct InnerNestedBool' declared here}}
83 kernel void bool_in_nested_struct_arg(NestedBool arg) { } // expected-error{{'NestedBool' (aka 'struct NestedBool') cannot be used as the type of a kernel parameter}}
85 // Warning emitted again for argument used in other kernel
86 kernel void bool_in_nested_struct_arg_again(NestedBool arg) { } // expected-error{{'NestedBool' (aka 'struct NestedBool') cannot be used as the type of a kernel parameter}}
89 // Check for note with a struct not defined inside the struct
90 typedef struct NestedBool2Inner
92 bool boolField; // expected-note{{field of illegal type 'bool' declared here}}
95 typedef struct NestedBool2 // expected-note{{within field of type 'NestedBool2' declared here}}
98 NestedBool2Inner inner; // expected-note{{within field of type 'NestedBool2Inner' (aka 'struct NestedBool2Inner') declared here}}
101 kernel void bool_in_nested_struct_2_arg(NestedBool2 arg) { } // expected-error{{'NestedBool2' (aka 'struct NestedBool2') cannot be used as the type of a kernel parameter}}
124 struct AlsoUser // expected-note{{within field of type 'AlsoUser' declared here}}
129 struct NestedPointer aaaa; // expected-note{{within field of type 'struct NestedPointer' declared here}}
132 kernel void pointer_in_nested_struct_arg_2(struct Valid valid, struct NestedPointer arg, struct AlsoUser also) { } // expected-error 2 {{struct kernel parameters may not contain pointers}}