1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 3 #pragma OPENCL EXTENSION cl_khr_fp16 : enable 4 5 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 9 10 // TODO: Ban int types, size_t, ptrdiff_t ... 11 12 kernel void bool_arg(bool x) { } // expected-error{{'bool' cannot be used as the type of a kernel parameter}} 13 14 kernel void half_arg(half x) { } // expected-error{{'half' cannot be used as the type of a kernel parameter}} 15 16 typedef struct ContainsBool // expected-note{{within field of type 'ContainsBool' declared here}} 17 { 18 bool x; // expected-note{{field of illegal type 'bool' declared here}} 19 } ContainsBool; 20 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}} 22 23 24 25 typedef struct FooImage2D // expected-note{{within field of type 'FooImage2D' declared here}} 26 { 27 image2d_t imageField; // expected-note{{field of illegal type 'image2d_t' declared here}} 28 } FooImage2D; 29 30 kernel void image_in_struct_arg(FooImage2D arg) { } // expected-error{{struct kernel parameters may not contain pointers}} 31 32 typedef struct Foo // expected-note{{within field of type 'Foo' declared here}} 33 { 34 int* ptrField; // expected-note{{field of illegal pointer type 'int *' declared here}} 35 } Foo; 36 37 kernel void pointer_in_struct_arg(Foo arg) { } // expected-error{{struct kernel parameters may not contain pointers}} 38 39 typedef union FooUnion // expected-note{{within field of type 'FooUnion' declared here}} 40 { 41 int* ptrField; // expected-note{{field of illegal pointer type 'int *' declared here}} 42 } FooUnion; 43 44 kernel void pointer_in_union_arg(FooUnion arg) { }// expected-error{{union kernel parameters may not contain pointers}} 45 46 typedef struct NestedPointer // expected-note 2 {{within field of type 'NestedPointer' declared here}} 47 { 48 int x; 49 struct InnerNestedPointer 50 { 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}} 53 } NestedPointer; 54 55 kernel void pointer_in_nested_struct_arg(NestedPointer arg) { }// expected-error{{struct kernel parameters may not contain pointers}} 56 57 struct NestedPointerComplex // expected-note{{within field of type 'NestedPointerComplex' declared here}} 58 { 59 int foo; 60 float bar; 61 62 struct InnerNestedPointerComplex 63 { 64 int innerFoo; 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}} 67 68 float y; 69 float z[4]; 70 }; 71 72 kernel void pointer_in_nested_struct_arg_complex(struct NestedPointerComplex arg) { }// expected-error{{struct kernel parameters may not contain pointers}} 73 74 typedef struct NestedBool // expected-note 2 {{within field of type 'NestedBool' declared here}} 75 { 76 int x; 77 struct InnerNestedBool 78 { 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}} 81 } NestedBool; 82 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}} 84 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}} 87 88 89 // Check for note with a struct not defined inside the struct 90 typedef struct NestedBool2Inner 91 { 92 bool boolField; // expected-note{{field of illegal type 'bool' declared here}} 93 } NestedBool2Inner; 94 95 typedef struct NestedBool2 // expected-note{{within field of type 'NestedBool2' declared here}} 96 { 97 int x; 98 NestedBool2Inner inner; // expected-note{{within field of type 'NestedBool2Inner' (aka 'struct NestedBool2Inner') declared here}} 99 } NestedBool2; 100 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}} 102 103 104 struct InnerInner 105 { 106 int* foo; 107 bool x; 108 }; 109 110 struct Valid 111 { 112 float c; 113 float d; 114 }; 115 116 struct Inner 117 { 118 struct Valid v; 119 struct InnerInner a; 120 struct Valid g; 121 struct InnerInner b; 122 }; 123 124 struct AlsoUser // expected-note{{within field of type 'AlsoUser' declared here}} 125 { 126 float x; 127 struct Valid valid1; 128 struct Valid valid2; 129 struct NestedPointer aaaa; // expected-note{{within field of type 'struct NestedPointer' declared here}} 130 }; 131 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}} 133