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

Simon Pilgrim via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 28 06:03:48 PST 2022


RKSimon created this revision.
RKSimon added reviewers: fhahn, scanon, craig.topper, aaron.ballman.
RKSimon requested review of this revision.
Herald added a project: clang.

As suggested on D117898 <https://reviews.llvm.org/D117898>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118464

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


Index: clang/test/Sema/builtins-elementwise-math.c
===================================================================
--- clang/test/Sema/builtins-elementwise-math.c
+++ 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 @@
   // 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 different types ('int *' vs 'double')}}
 
@@ -51,6 +52,9 @@
   i = __builtin_elementwise_max(v, iv);
   // expected-error at -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 at -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,
@@ -84,7 +88,7 @@
   // 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 different types ('int *' vs 'double')}}
 
@@ -103,6 +107,9 @@
   i = __builtin_elementwise_min(v, iv);
   // expected-error at -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 at -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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118464.403993.patch
Type: text/x-patch
Size: 2335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220128/a5e30e09/attachment-0001.bin>


More information about the cfe-commits mailing list