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 12kernel void bool_arg(bool x) { } // expected-error{{'bool' cannot be used as the type of a kernel parameter}} 13 14kernel void half_arg(half x) { } // expected-error{{'half' cannot be used as the type of a kernel parameter}} 15 16typedef 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 21kernel 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 25typedef 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 30kernel void image_in_struct_arg(FooImage2D arg) { } // expected-error{{struct kernel parameters may not contain pointers}} 31 32typedef 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 37kernel void pointer_in_struct_arg(Foo arg) { } // expected-error{{struct kernel parameters may not contain pointers}} 38 39typedef 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 44kernel void pointer_in_union_arg(FooUnion arg) { }// expected-error{{union kernel parameters may not contain pointers}} 45 46typedef 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 55kernel void pointer_in_nested_struct_arg(NestedPointer arg) { }// expected-error{{struct kernel parameters may not contain pointers}} 56 57struct 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 72kernel void pointer_in_nested_struct_arg_complex(struct NestedPointerComplex arg) { }// expected-error{{struct kernel parameters may not contain pointers}} 73 74typedef 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 83kernel 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 86kernel 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 90typedef struct NestedBool2Inner 91{ 92 bool boolField; // expected-note{{field of illegal type 'bool' declared here}} 93} NestedBool2Inner; 94 95typedef 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 101kernel 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 104struct InnerInner 105{ 106 int* foo; 107 bool x; 108}; 109 110struct Valid 111{ 112 float c; 113 float d; 114}; 115 116struct Inner 117{ 118 struct Valid v; 119 struct InnerInner a; 120 struct Valid g; 121 struct InnerInner b; 122}; 123 124struct 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 132kernel 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