[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.
This commit is contained in:
Sven van Haastregt 2021-01-13 14:50:49 +00:00
parent ab57780716
commit 7c77b536ef
3 changed files with 14 additions and 2 deletions

View File

@ -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}}
}

View File

@ -36,6 +36,8 @@ kernel void float_ops() {
#if __OPENCL_C_VERSION__ < 120
// expected-error@-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@-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@-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() {

View File

@ -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'}}
}