11d23c4219527d9a2bc75f5cdb1ffcaefb8bcc61bDavid Blaikie// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
2f60946222721d9ba3c059563935c17b84703187aDouglas Gregortypedef unsigned int v2u __attribute__ ((vector_size (8)));
3f60946222721d9ba3c059563935c17b84703187aDouglas Gregortypedef int v2s __attribute__ ((vector_size (8)));
4f60946222721d9ba3c059563935c17b84703187aDouglas Gregortypedef float v2f __attribute__ ((vector_size(8)));
5f60946222721d9ba3c059563935c17b84703187aDouglas Gregor
6f60946222721d9ba3c059563935c17b84703187aDouglas Gregorvoid test1(v2u v2ua, v2s v2sa, v2f v2fa) {
7f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  // Bitwise binary operators
8f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  (void)(v2ua & v2ua);
9f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  (void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}}
10f60946222721d9ba3c059563935c17b84703187aDouglas Gregor
11f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  // Unary operators
12f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  (void)(~v2ua);
13f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  (void)(~v2fa); // expected-error{{invalid argument type 'v2f' to unary}}
14f60946222721d9ba3c059563935c17b84703187aDouglas Gregor
157870b133ac7b03bd53388f51250d009325f43399Anton Yartsev  // Comparison operators
167ad5c996e9519ed4e9afd1f0166be1cd2be8415aArgyrios Kyrtzidis  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' from 'int __attribute__((ext_vector_type(2)))'}}
176ec96438ede86b1a00f80dff25027f5a876613a8Tanya Lattner  v2sa = (v2ua==v2sa);
186ec96438ede86b1a00f80dff25027f5a876613a8Tanya Lattner
19f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  // Arrays
20f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u'}}
21f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  int array2[17];
22f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  // FIXME: error message below needs type!
23f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}}
24f60946222721d9ba3c059563935c17b84703187aDouglas Gregor
25f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  v2u *v2u_ptr = 0;
26f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  v2s *v2s_ptr;
27f60946222721d9ba3c059563935c17b84703187aDouglas Gregor  v2s_ptr = v2u_ptr; // expected-warning{{converts between pointers to integer types with different sign}}
28f60946222721d9ba3c059563935c17b84703187aDouglas Gregor}
29f60946222721d9ba3c059563935c17b84703187aDouglas Gregor
30