[clang] 9d75ee1 - [Sema] Add signed/unsigned integer mismatch tests for min/max elementwise builtins

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 28 06:31:55 PST 2022


Author: Simon Pilgrim
Date: 2022-01-28T14:31:36Z
New Revision: 9d75ee1cd597a762c75e6b680e5af8039850a522

URL: https://github.com/llvm/llvm-project/commit/9d75ee1cd597a762c75e6b680e5af8039850a522
DIFF: https://github.com/llvm/llvm-project/commit/9d75ee1cd597a762c75e6b680e5af8039850a522.diff

LOG: [Sema] Add signed/unsigned integer mismatch tests for min/max elementwise builtins

As suggested on D117898

Differential Revision: https://reviews.llvm.org/D118464

Added: 
    

Modified: 
    clang/test/Sema/builtins-elementwise-math.c

Removed: 
    


################################################################################
diff  --git a/clang/test/Sema/builtins-elementwise-math.c b/clang/test/Sema/builtins-elementwise-math.c
index 4243ddd1d71d7..f2da7a0327259 100644
--- a/clang/test/Sema/builtins-elementwise-math.c
+++ b/clang/test/Sema/builtins-elementwise-math.c
@@ -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 {
@@ -32,7 +33,7 @@ void test_builtin_elementwise_abs(int i, double d, float4 v, int3 iv, unsigned u
   // expected-error at -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 at -1 {{arguments are of 
diff erent types ('int *' vs 'double')}}
 
@@ -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 at -1 {{arguments are of 
diff erent types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
 
+  i = __builtin_elementwise_max(uv, iv);
+  // expected-error at -1 {{arguments are of 
diff erent types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
+
   s = __builtin_elementwise_max(i, s);
 
   enum e { one,
@@ -84,7 +88,7 @@ void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, i
   // expected-error at -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 at -1 {{arguments are of 
diff erent types ('int *' vs 'double')}}
 
@@ -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 at -1 {{arguments are of 
diff erent types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
 
+  i = __builtin_elementwise_min(uv, iv);
+  // expected-error at -1 {{arguments are of 
diff erent types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
+
   s = __builtin_elementwise_min(i, s);
 
   enum e { one,


        


More information about the cfe-commits mailing list