Skip to content

Commit

Permalink
[Sema] Add signed/unsigned integer mismatch tests for min/max element…
Browse files Browse the repository at this point in the history
…wise builtins

As suggested on D117898

Differential Revision: https://reviews.llvm.org/D118464
  • Loading branch information
RKSimon committed Jan 28, 2022
1 parent 8b36c43 commit 9d75ee1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions clang/test/Sema/builtins-elementwise-math.c
Expand Up @@ -2,6 +2,7 @@

typedef float float4 __attribute__((ext_vector_type(4)));
typedef int int3 __attribute__((ext_vector_type(3)));
typedef unsigned unsigned3 __attribute__((ext_vector_type(3)));
typedef unsigned unsigned4 __attribute__((ext_vector_type(4)));

struct Foo {
Expand Down Expand Up @@ -32,7 +33,7 @@ void test_builtin_elementwise_abs(int i, double d, float4 v, int3 iv, unsigned u
// expected-error@-1 {{1st argument must be a signed integer or floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
}

void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, int *p) {
void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
i = __builtin_elementwise_max(p, d);
// expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}

Expand All @@ -51,6 +52,9 @@ void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, i
i = __builtin_elementwise_max(v, iv);
// expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}

i = __builtin_elementwise_max(uv, iv);
// expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}

s = __builtin_elementwise_max(i, s);

enum e { one,
Expand Down Expand Up @@ -84,7 +88,7 @@ void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, i
// expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
}

void test_builtin_elementwise_min(int i, short s, double d, float4 v, int3 iv, int *p) {
void test_builtin_elementwise_min(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
i = __builtin_elementwise_min(p, d);
// expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}

Expand All @@ -103,6 +107,9 @@ void test_builtin_elementwise_min(int i, short s, double d, float4 v, int3 iv, i
i = __builtin_elementwise_min(v, iv);
// expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}

i = __builtin_elementwise_min(uv, iv);
// expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}

s = __builtin_elementwise_min(i, s);

enum e { one,
Expand Down

0 comments on commit 9d75ee1

Please sign in to comment.