aboutsummaryrefslogtreecommitdiff
path: root/test/SemaOpenCL/logical-ops.cl
blob: 42501b14413e9df7d9df138cd4924aee4632b3e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// RUN: %clang_cc1 %s -verify -cl-std=CL1.1 -triple x86_64-unknown-linux-gnu
// RUN: %clang_cc1 %s -verify -cl-std=CL1.2 -triple x86_64-unknown-linux-gnu
// RUN: %clang_cc1 %s -verify -cl-std=CL2.0 -triple x86_64-unknown-linux-gnu

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

typedef __attribute__((ext_vector_type(4))) float float4;
typedef __attribute__((ext_vector_type(4))) double double4;
typedef __attribute__((ext_vector_type(4))) int int4;
typedef __attribute__((ext_vector_type(4))) long long4;

kernel void float_ops() {
  int flaf = 0.0f && 0.0f;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  int flof = 0.0f || 0.0f;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  float fbaf = 0.0f & 0.0f; // expected-error {{invalid operands}}
  float fbof = 0.0f | 0.0f; // expected-error {{invalid operands}}
  float fbxf = 0.0f ^ 0.0f; // expected-error {{invalid operands}}
  int flai = 0.0f && 0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  int floi = 0.0f || 0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  float ibaf = 0 & 0.0f; // expected-error {{invalid operands}}
  float ibof = 0 | 0.0f; // expected-error {{invalid operands}}
  float bnf = ~0.0f;// expected-error {{invalid argument type}}
  float lnf = !0.0f;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid argument type}}
#endif
}

kernel void vec_float_ops() {
  float4 f4 = (float4)(0, 0, 0, 0);
  int4 f4laf = f4 && 0.0f;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  int4 f4lof = f4 || 0.0f;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  float4 f4baf = f4 & 0.0f; // expected-error {{invalid operands}}
  float4 f4bof = f4 | 0.0f; // expected-error {{invalid operands}}
  float4 f4bxf = f4 ^ 0.0f; // expected-error {{invalid operands}}
  float bnf4 = ~f4; // expected-error {{invalid argument type}}
  int4 lnf4 = !f4;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid argument type}}
#endif
}

kernel void double_ops() {
  int flaf = 0.0 && 0.0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  int flof = 0.0 || 0.0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  double fbaf = 0.0 & 0.0; // expected-error {{invalid operands}}
  double fbof = 0.0 | 0.0; // expected-error {{invalid operands}}
  double fbxf = 0.0 ^ 0.0; // expected-error {{invalid operands}}
  int flai = 0.0 && 0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  int floi = 0.0 || 0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  double ibaf = 0 & 0.0; // expected-error {{invalid operands}}
  double ibof = 0 | 0.0; // expected-error {{invalid operands}}
  double bnf = ~0.0; // expected-error {{invalid argument type}}
  double lnf = !0.0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid argument type}}
#endif
}

kernel void vec_double_ops() {
  double4 f4 = (double4)(0, 0, 0, 0);
  long4 f4laf = f4 && 0.0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  long4 f4lof = f4 || 0.0;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid operands}}
#endif
  double4 f4baf = f4 & 0.0; // expected-error {{invalid operands}}
  double4 f4bof = f4 | 0.0; // expected-error {{invalid operands}}
  double4 f4bxf = f4 ^ 0.0; // expected-error {{invalid operands}}
  double bnf4 = ~f4; // expected-error {{invalid argument type}}
  long4 lnf4 = !f4;
#if __OPENCL_C_VERSION__ < 120
// expected-error@-2{{invalid argument type}}
#endif
}

kernel void pointer_ops(){
  global int* p;
  bool b = !p;
  b = p==0;
  int i;
  b = !&i;
  b = &i==(int *)1;
}