r294313 - [OpenCL] Accept logical NOT for pointer types in CL1.1
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 7 08:09:41 PST 2017
Author: stulova
Date: Tue Feb 7 10:09:41 2017
New Revision: 294313
URL: http://llvm.org/viewvc/llvm-project?rev=294313&view=rev
Log:
[OpenCL] Accept logical NOT for pointer types in CL1.1
Fix for bug 30217 - incorrect error given for logical
NOT operation with a pointer type: corrected sema check
and improved related tests.
Review: D29038
Added:
cfe/trunk/test/SemaOpenCL/logical-ops.cl
Removed:
cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl
cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=294313&r1=294312&r2=294313&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Feb 7 10:09:41 2017
@@ -11686,7 +11686,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(So
Context.getLangOpts().OpenCLVersion < 120) {
// OpenCL v1.1 6.3.h: The logical operator not (!) does not
// operate on scalar float types.
- if (!resultType->isIntegerType())
+ if (!resultType->isIntegerType() && !resultType->isPointerType())
return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
<< resultType << Input.get()->getSourceRange());
}
Removed: cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl?rev=294312&view=auto
==============================================================================
--- cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.1.cl (removed)
@@ -1,57 +0,0 @@
-// RUN: %clang_cc1 %s -verify -cl-std=CL1.1 -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; // expected-error {{invalid operands}}
- int flof = 0.0f || 0.0f; // expected-error {{invalid operands}}
- 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; // expected-error {{invalid operands}}
- int floi = 0.0f || 0; // expected-error {{invalid operands}}
- 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; // expected-error {{invalid argument type}}
-}
-
-kernel void vec_float_ops() {
- float4 f4 = (float4)(0, 0, 0, 0);
- int4 f4laf = f4 && 0.0f; // expected-error {{invalid operands}}
- int4 f4lof = f4 || 0.0f; // expected-error {{invalid operands}}
- 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; // expected-error {{invalid argument type}}
-}
-
-kernel void double_ops() {
- int flaf = 0.0 && 0.0; // expected-error {{invalid operands}}
- int flof = 0.0 || 0.0; // expected-error {{invalid operands}}
- 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; // expected-error {{invalid operands}}
- int floi = 0.0 || 0; // expected-error {{invalid operands}}
- 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; // expected-error {{invalid argument type}}
-}
-
-kernel void vec_double_ops() {
- double4 f4 = (double4)(0, 0, 0, 0);
- long4 f4laf = f4 && 0.0; // expected-error {{invalid operands}}
- long4 f4lof = f4 || 0.0; // expected-error {{invalid operands}}
- 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; // expected-error {{invalid argument type}}
-}
Removed: cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl?rev=294312&view=auto
==============================================================================
--- cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl (removed)
@@ -1,58 +0,0 @@
-// RUN: %clang_cc1 %s -verify -cl-std=CL1.2 -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;
- int flof = 0.0f || 0.0f;
- 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;
- int floi = 0.0f || 0;
- 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;
-}
-
-kernel void vec_float_ops() {
- float4 f4 = (float4)(0, 0, 0, 0);
- int4 f4laf = f4 && 0.0f;
- int4 f4lof = f4 || 0.0f;
- 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;
-}
-
-kernel void double_ops() {
- int flaf = 0.0 && 0.0;
- int flof = 0.0 || 0.0;
- 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;
- int floi = 0.0 || 0;
- 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;
-}
-
-kernel void vec_double_ops() {
- double4 f4 = (double4)(0, 0, 0, 0);
- long4 f4laf = f4 && 0.0;
- long4 f4lof = f4 || 0.0;
- 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;
-}
Added: cfe/trunk/test/SemaOpenCL/logical-ops.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/logical-ops.cl?rev=294313&view=auto
==============================================================================
--- cfe/trunk/test/SemaOpenCL/logical-ops.cl (added)
+++ cfe/trunk/test/SemaOpenCL/logical-ops.cl Tue Feb 7 10:09:41 2017
@@ -0,0 +1,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 at -2{{invalid operands}}
+#endif
+ int flof = 0.0f || 0.0f;
+#if __OPENCL_C_VERSION__ < 120
+// expected-error at -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 at -2{{invalid operands}}
+#endif
+ int floi = 0.0f || 0;
+#if __OPENCL_C_VERSION__ < 120
+// expected-error at -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 at -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 at -2{{invalid operands}}
+#endif
+ int4 f4lof = f4 || 0.0f;
+#if __OPENCL_C_VERSION__ < 120
+// expected-error at -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 at -2{{invalid argument type}}
+#endif
+}
+
+kernel void double_ops() {
+ int flaf = 0.0 && 0.0;
+#if __OPENCL_C_VERSION__ < 120
+// expected-error at -2{{invalid operands}}
+#endif
+ int flof = 0.0 || 0.0;
+#if __OPENCL_C_VERSION__ < 120
+// expected-error at -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 at -2{{invalid operands}}
+#endif
+ int floi = 0.0 || 0;
+#if __OPENCL_C_VERSION__ < 120
+// expected-error at -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 at -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 at -2{{invalid operands}}
+#endif
+ long4 f4lof = f4 || 0.0;
+#if __OPENCL_C_VERSION__ < 120
+// expected-error at -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 at -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;
+}
More information about the cfe-commits
mailing list