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
5 #pragma OPENCL EXTENSION cl_khr_fp64
: enable
7 typedef __attribute__
((ext_vector_type(4))) float float4
;
8 typedef __attribute__
((ext_vector_type(4))) double double4
;
9 typedef __attribute__
((ext_vector_type(4))) int int4
;
10 typedef __attribute__
((ext_vector_type(4))) long long4
;
12 kernel void float_ops
() {
13 int flaf
= 0.0f
&& 0.0f
;
14 #if __OPENCL_C_VERSION__
< 120
15 // expected-error
@-
2{{invalid operands
}}
17 int flof
= 0.0f ||
0.0f
;
18 #if __OPENCL_C_VERSION__
< 120
19 // expected-error
@-
2{{invalid operands
}}
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}}
25 #if __OPENCL_C_VERSION__
< 120
26 // expected-error
@-
2{{invalid operands
}}
29 #if __OPENCL_C_VERSION__
< 120
30 // expected-error
@-
2{{invalid operands
}}
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}}
36 #if __OPENCL_C_VERSION__
< 120
37 // expected-error
@-
2{{invalid argument type
}}
40 float fremainder
= fcst %
2.0f
; // expected-error {{invalid operands to binary expression}}
43 kernel 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
}}
49 int4 f4lof
= f4 ||
0.0f
;
50 #if __OPENCL_C_VERSION__
< 120
51 // expected-error
@-
2{{invalid operands
}}
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}}
58 #if __OPENCL_C_VERSION__
< 120
59 // expected-error
@-
2{{invalid argument type
}}
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}}
65 kernel void double_ops
() {
66 int flaf
= 0.0 && 0.0;
67 #if __OPENCL_C_VERSION__
< 120
68 // expected-error
@-
2{{invalid operands
}}
70 int flof
= 0.0 ||
0.0;
71 #if __OPENCL_C_VERSION__
< 120
72 // expected-error
@-
2{{invalid operands
}}
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}}
78 #if __OPENCL_C_VERSION__
< 120
79 // expected-error
@-
2{{invalid operands
}}
82 #if __OPENCL_C_VERSION__
< 120
83 // expected-error
@-
2{{invalid operands
}}
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}}
89 #if __OPENCL_C_VERSION__
< 120
90 // expected-error
@-
2{{invalid argument type
}}
93 double dremainder
= dcst %
2.0; // expected-error {{invalid operands to binary expression}}
96 kernel 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
}}
102 long4 f4lof
= f4 ||
0.0;
103 #if __OPENCL_C_VERSION__
< 120
104 // expected-error
@-
2{{invalid operands
}}
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}}
111 #if __OPENCL_C_VERSION__
< 120
112 // expected-error
@-
2{{invalid argument type
}}
116 kernel void pointer_ops
(){
121 b
= !&i
; // expected-warning {{address of 'i' will always evaluate to 'true'}}