[llvm-branch-commits] [clang] 7c77b53 - [OpenCL] Improve OpenCL operator tests
Sven van Haastregt via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jan 13 06:55:35 PST 2021
Author: Sven van Haastregt
Date: 2021-01-13T14:50:49Z
New Revision: 7c77b536efdd953d6d97bffbd9ca320c517b26d7
URL: https://github.com/llvm/llvm-project/commit/7c77b536efdd953d6d97bffbd9ca320c517b26d7
DIFF: https://github.com/llvm/llvm-project/commit/7c77b536efdd953d6d97bffbd9ca320c517b26d7.diff
LOG: [OpenCL] Improve OpenCL operator tests
Extend testing of increment/decrement operators and make sure these
operators are tested in only one dedicated test file.
Rename logical-ops.cl to operators.cl, as it was already containing
more than just logical operators.
Add testing for the remainder operator on floating point types.
Added:
clang/test/SemaOpenCL/operators.cl
Modified:
clang/test/SemaOpenCL/invalid-vector-literals.cl
clang/test/SemaOpenCL/vector_inc_dec_ops.cl
Removed:
clang/test/SemaOpenCL/logical-ops.cl
################################################################################
diff --git a/clang/test/SemaOpenCL/invalid-vector-literals.cl b/clang/test/SemaOpenCL/invalid-vector-literals.cl
index 4e502aad3bad..1d82fedf29de 100644
--- a/clang/test/SemaOpenCL/invalid-vector-literals.cl
+++ b/clang/test/SemaOpenCL/invalid-vector-literals.cl
@@ -8,7 +8,6 @@ void vector_literals_invalid()
{
int4 a = (int4)(1,2,3); // expected-error{{too few elements}}
int4 b = (int4)(1,2,3,4,5); // expected-error{{excess elements in vector}}
- ((float4)(1.0f))++; // expected-error{{cannot increment value of type 'float4'}}
int8 d = (int8)(a,(float4)(1)); // expected-error{{initializing 'int' with an expression of incompatible type 'float4'}}
((int4)(0)).x = 8; // expected-error{{expression is not assignable}}
}
diff --git a/clang/test/SemaOpenCL/logical-ops.cl b/clang/test/SemaOpenCL/operators.cl
similarity index 90%
rename from clang/test/SemaOpenCL/logical-ops.cl
rename to clang/test/SemaOpenCL/operators.cl
index f6972c46e2ad..cf359acd5acb 100644
--- a/clang/test/SemaOpenCL/logical-ops.cl
+++ b/clang/test/SemaOpenCL/operators.cl
@@ -36,6 +36,8 @@ kernel void float_ops() {
#if __OPENCL_C_VERSION__ < 120
// expected-error at -2{{invalid argument type}}
#endif
+ float fcst = 5.5f;
+ float fremainder = fcst % 2.0f; // expected-error {{invalid operands to binary expression}}
}
kernel void vec_float_ops() {
@@ -56,6 +58,8 @@ kernel void vec_float_ops() {
#if __OPENCL_C_VERSION__ < 120
// expected-error at -2{{invalid argument type}}
#endif
+ float4 f4cst = (float4)(5.5f, 5.5f, 5.5f, 5.5f);
+ float4 f4remainder = f4cst % (float4)(2.0f, 2.0f, 2.0f, 2.0f); // expected-error {{invalid operands to binary expression}}
}
kernel void double_ops() {
@@ -85,6 +89,8 @@ kernel void double_ops() {
#if __OPENCL_C_VERSION__ < 120
// expected-error at -2{{invalid argument type}}
#endif
+ double dcst = 5.5;
+ double dremainder = dcst % 2.0; // expected-error {{invalid operands to binary expression}}
}
kernel void vec_double_ops() {
diff --git a/clang/test/SemaOpenCL/vector_inc_dec_ops.cl b/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
index c65bbcb5b749..533253ee696f 100644
--- a/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
+++ b/clang/test/SemaOpenCL/vector_inc_dec_ops.cl
@@ -1,9 +1,9 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-// expected-no-diagnostics
typedef __attribute__((ext_vector_type(2))) char char2;
typedef __attribute__((ext_vector_type(4))) unsigned int uint4;
typedef __attribute__((ext_vector_type(8))) long long8;
+typedef __attribute__((ext_vector_type(4))) float float4;
void vectorIncrementDecrementOps()
{
@@ -17,3 +17,10 @@ void vectorIncrementDecrementOps()
++B;
C++;
}
+
+void invalidIncrementDecrementOps() {
+ ((float4)(1.0f))++; // expected-error{{cannot increment value of type 'float4'}}
+ float4 i;
+ ++i; // expected-error{{cannot increment value of type '__private float4'}}
+ i--; // expected-error{{cannot decrement value of type '__private float4'}}
+}
More information about the llvm-branch-commits
mailing list