brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · 3a23f68 Raw
84 lines · plain
1// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only2// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa3// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple spir-unknown-unknown4// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only5// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa6// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple spir-unknown-unknown7 8#define CLK_ADDRESS_CLAMP_TO_EDGE       29#define CLK_NORMALIZED_COORDS_TRUE      110#define CLK_FILTER_NEAREST              0x1011#define CLK_FILTER_LINEAR               0x2012 13typedef float float4 __attribute__((ext_vector_type(4)));14float4 read_imagef(read_only image1d_t, sampler_t, float);15 16constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;17constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}18global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}} expected-error {{global sampler requires a const or constant address space qualifier}}19const global sampler_t glb_smp3_const = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;  // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}20 21constant sampler_t glb_smp4 = 0;22#ifdef CHECK_SAMPLER_VALUE23// expected-warning@-2{{sampler initializer has invalid Filter Mode bits}}24#endif25 26constant sampler_t glb_smp5 = 0x1f;27#ifdef CHECK_SAMPLER_VALUE28// expected-warning@-2{{sampler initializer has invalid Addressing Mode bits}}29#endif30 31constant sampler_t glb_smp6 = glb_smp; // expected-error{{initializer element is not a compile-time constant}}32 33int f(void);34constant sampler_t glb_smp7 = f(); // expected-error{{initializer element is not a compile-time constant}}35 36constant sampler_t glb_smp8 = 1.0f; // expected-error{{initializing '__constant sampler_t' with an expression of incompatible type 'float'}}37 38constant sampler_t glb_smp9 = 0x100000000LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}39 40void foo(sampler_t); // expected-note{{passing argument to parameter here}}41 42void constant_sampler(constant sampler_t s); // expected-error{{parameter may not be qualified with an address space}}43 44constant struct sampler_s {45  sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}}46} sampler_str = {0};47 48sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}49 50sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires a const or constant address space qualifier}}51 52const sampler_t glb_smp10 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;53const constant sampler_t glb_smp11 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;54 55void kernel ker(sampler_t argsmp) {56  local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}57  const sampler_t const_smp5 = 1.0f; // expected-error{{initializing 'const sampler_t' with an expression of incompatible type 'float'}}58  const sampler_t const_smp6 = 0x100000000LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}59 60  foo(5.0f); // expected-error {{passing 'float' to parameter of incompatible type 'sampler_t'}}61  sampler_t sa[] = {argsmp, glb_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}62}63 64#if __OPENCL_C_VERSION__ == 20065void bad(sampler_t *); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}66#else67void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}68#endif69 70void bar(void) {71  sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;72  sampler_t smp2 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;73  smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}74  smp1+1; //expected-error{{invalid operands to binary expression ('sampler_t' and 'int')}}75  &smp1; //expected-error{{invalid argument type 'sampler_t' to unary expression}}76  *smp2; //expected-error{{invalid argument type 'sampler_t' to unary expression}}77  foo(smp1+1); //expected-error{{invalid operands to binary expression ('sampler_t' and 'int')}}78}79 80void smp_args(read_only image1d_t image) {81  // Test that parentheses around sampler arguments are ignored.82  float4 res = read_imagef(image, (glb_smp10), 0.0f);83}84