1// RUN: %clang_cc1 %s -verify -cl-std=CL1.1 -triple x86_64-unknown-linux-gnu 2// RUN: %clang_cc1 %s -verify -cl-std=CL1.2 -triple x86_64-unknown-linux-gnu 3// RUN: %clang_cc1 %s -verify -cl-std=CL2.0 -triple x86_64-unknown-linux-gnu 4 5#pragma OPENCL EXTENSION cl_khr_fp64 : enable 6 7typedef __attribute__((ext_vector_type(4))) float float4; 8typedef __attribute__((ext_vector_type(4))) double double4; 9typedef __attribute__((ext_vector_type(4))) int int4; 10typedef __attribute__((ext_vector_type(4))) long long4; 11 12kernel void float_ops() { 13 int flaf = 0.0f && 0.0f; 14#if __OPENCL_C_VERSION__ < 120 15// expected-error@-2{{invalid operands}} 16#endif 17 int flof = 0.0f || 0.0f; 18#if __OPENCL_C_VERSION__ < 120 19// expected-error@-2{{invalid operands}} 20#endif 21 float fbaf = 0.0f & 0.0f; // expected-error {{invalid operands}} 22 float fbof = 0.0f | 0.0f; // expected-error {{invalid operands}} 23 float fbxf = 0.0f ^ 0.0f; // expected-error {{invalid operands}} 24 int flai = 0.0f && 0; 25#if __OPENCL_C_VERSION__ < 120 26// expected-error@-2{{invalid operands}} 27#endif 28 int floi = 0.0f || 0; 29#if __OPENCL_C_VERSION__ < 120 30// expected-error@-2{{invalid operands}} 31#endif 32 float ibaf = 0 & 0.0f; // expected-error {{invalid operands to binary expression ('int' and 'float')}} 33 float ibof = 0 | 0.0f; // expected-error {{invalid operands}} 34 float bnf = ~0.0f;// expected-error {{invalid argument type}} 35 float lnf = !0.0f; 36#if __OPENCL_C_VERSION__ < 120 37// expected-error@-2{{invalid argument type}} 38#endif 39 float fcst = 5.5f; 40 float fremainder = fcst % 2.0f; // expected-error {{invalid operands to binary expression}} 41} 42 43kernel void vec_float_ops() { 44 float4 f4 = (float4)(0, 0, 0, 0); 45 int4 f4laf = f4 && 0.0f; 46#if __OPENCL_C_VERSION__ < 120 47// expected-error@-2{{invalid operands}} 48#endif 49 int4 f4lof = f4 || 0.0f; 50#if __OPENCL_C_VERSION__ < 120 51// expected-error@-2{{invalid operands}} 52#endif 53 float4 f4baf = f4 & 0.0f; // expected-error {{invalid operands}} 54 float4 f4bof = f4 | 0.0f; // expected-error {{invalid operands}} 55 float4 f4bxf = f4 ^ 0.0f; // expected-error {{invalid operands}} 56 float bnf4 = ~f4; // expected-error {{invalid argument type}} 57 int4 lnf4 = !f4; 58#if __OPENCL_C_VERSION__ < 120 59// expected-error@-2{{invalid argument type}} 60#endif 61 float4 f4cst = (float4)(5.5f, 5.5f, 5.5f, 5.5f); 62 float4 f4remainder = f4cst % (float4)(2.0f, 2.0f, 2.0f, 2.0f); // expected-error {{invalid operands to binary expression}} 63} 64 65kernel void double_ops() { 66 int flaf = 0.0 && 0.0; 67#if __OPENCL_C_VERSION__ < 120 68// expected-error@-2{{invalid operands}} 69#endif 70 int flof = 0.0 || 0.0; 71#if __OPENCL_C_VERSION__ < 120 72// expected-error@-2{{invalid operands}} 73#endif 74 double fbaf = 0.0 & 0.0; // expected-error {{invalid operands}} 75 double fbof = 0.0 | 0.0; // expected-error {{invalid operands}} 76 double fbxf = 0.0 ^ 0.0; // expected-error {{invalid operands}} 77 int flai = 0.0 && 0; 78#if __OPENCL_C_VERSION__ < 120 79// expected-error@-2{{invalid operands}} 80#endif 81 int floi = 0.0 || 0; 82#if __OPENCL_C_VERSION__ < 120 83// expected-error@-2{{invalid operands}} 84#endif 85 double ibaf = 0 & 0.0; // expected-error {{invalid operands}} 86 double ibof = 0 | 0.0; // expected-error {{invalid operands}} 87 double bnf = ~0.0; // expected-error {{invalid argument type}} 88 double lnf = !0.0; 89#if __OPENCL_C_VERSION__ < 120 90// expected-error@-2{{invalid argument type}} 91#endif 92 double dcst = 5.5; 93 double dremainder = dcst % 2.0; // expected-error {{invalid operands to binary expression}} 94} 95 96kernel void vec_double_ops() { 97 double4 f4 = (double4)(0, 0, 0, 0); 98 long4 f4laf = f4 && 0.0; 99#if __OPENCL_C_VERSION__ < 120 100// expected-error@-2{{invalid operands}} 101#endif 102 long4 f4lof = f4 || 0.0; 103#if __OPENCL_C_VERSION__ < 120 104// expected-error@-2{{invalid operands}} 105#endif 106 double4 f4baf = f4 & 0.0; // expected-error {{invalid operands}} 107 double4 f4bof = f4 | 0.0; // expected-error {{invalid operands}} 108 double4 f4bxf = f4 ^ 0.0; // expected-error {{invalid operands}} 109 double bnf4 = ~f4; // expected-error {{invalid argument type}} 110 long4 lnf4 = !f4; 111#if __OPENCL_C_VERSION__ < 120 112// expected-error@-2{{invalid argument type}} 113#endif 114} 115 116kernel void pointer_ops(){ 117 global int* p; 118 bool b = !p; 119 b = p==0; 120 int i; 121 b = !&i; 122 b = &i==(int *)1; 123} 124