xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/vector-ops.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
2f4a2713aSLionel Sambuc typedef unsigned int v2u __attribute__ ((vector_size (8)));
3f4a2713aSLionel Sambuc typedef int v2s __attribute__ ((vector_size (8)));
4f4a2713aSLionel Sambuc typedef float v2f __attribute__ ((vector_size(8)));
5f4a2713aSLionel Sambuc 
test1(v2u v2ua,v2s v2sa,v2f v2fa)6f4a2713aSLionel Sambuc void test1(v2u v2ua, v2s v2sa, v2f v2fa) {
7f4a2713aSLionel Sambuc   // Bitwise binary operators
8f4a2713aSLionel Sambuc   (void)(v2ua & v2ua);
9f4a2713aSLionel Sambuc   (void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}}
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc   // Unary operators
12f4a2713aSLionel Sambuc   (void)(~v2ua);
13*0a6a1f1dSLionel Sambuc   (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}}
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc   // Comparison operators
16*0a6a1f1dSLionel Sambuc   v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'int __attribute__((ext_vector_type(2)))' (vector of 2 'int' values)}}
17f4a2713aSLionel Sambuc   v2sa = (v2ua==v2sa);
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc   // Arrays
20*0a6a1f1dSLionel Sambuc   int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values)}}
21f4a2713aSLionel Sambuc   int array2[17];
22f4a2713aSLionel Sambuc   // FIXME: error message below needs type!
23f4a2713aSLionel Sambuc   (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}}
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc   v2u *v2u_ptr = 0;
26f4a2713aSLionel Sambuc   v2s *v2s_ptr;
27f4a2713aSLionel Sambuc   v2s_ptr = v2u_ptr; // expected-warning{{converts between pointers to integer types with different sign}}
28f4a2713aSLionel Sambuc }
29f4a2713aSLionel Sambuc 
30