1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -fsyntax-only -verify %s 2 typedef int __v2si __attribute__((__vector_size__(8))); 3 typedef short __v4hi __attribute__((__vector_size__(8))); 4 typedef short __v8hi __attribute__((__vector_size__(16))); 5 typedef short __v3hi __attribute__((__ext_vector_type__(3))); 6 7 struct S { }; // expected-note 3 {{candidate constructor}} 8 9 enum E : long long { Evalue }; 10 11 void f() { 12 __v2si v2si; 13 __v3hi v3hi; 14 __v4hi v4hi; 15 __v8hi v8hi; 16 unsigned long long ll; 17 unsigned char c; 18 S s; 19 E e; 20 21 (void)reinterpret_cast<__v2si>(v4hi); 22 (void)(__v2si)v4hi; 23 (void)reinterpret_cast<__v4hi>(v2si); 24 (void)(__v4hi)v2si; 25 (void)reinterpret_cast<unsigned long long>(v2si); 26 (void)(unsigned long long)v2si; 27 (void)reinterpret_cast<__v2si>(ll); 28 (void)(__v2si)(ll); 29 30 (void)(E)v2si; // expected-error {{C-style cast from '__v2si' (vector of 2 'int' values) to 'E' is not allowed}} 31 (void)(__v2si)e; // expected-error {{C-style cast from 'E' to '__v2si' (vector of 2 'int' values)}} 32 (void)reinterpret_cast<E>(v2si); // expected-error {{reinterpret_cast from '__v2si' (vector of 2 'int' values) to 'E' is not allowed}} 33 (void)reinterpret_cast<__v2si>(e); // expected-error {{reinterpret_cast from 'E' to '__v2si' (vector of 2 'int' values)}} 34 35 (void)reinterpret_cast<S>(v2si); // expected-error {{reinterpret_cast from '__v2si' (vector of 2 'int' values) to 'S' is not allowed}} 36 (void)(S)v2si; // expected-error {{no matching conversion for C-style cast from '__v2si' (vector of 2 'int' values) to 'S'}} 37 (void)reinterpret_cast<__v2si>(s); // expected-error {{reinterpret_cast from 'S' to '__v2si' (vector of 2 'int' values) is not allowed}} 38 (void)(__v2si)s; // expected-error {{cannot convert 'S' to '__v2si' (vector of 2 'int' values) without a conversion operator}} 39 40 (void)reinterpret_cast<unsigned char>(v2si); // expected-error {{reinterpret_cast from vector '__v2si' (vector of 2 'int' values) to scalar 'unsigned char' of different size}} 41 (void)(unsigned char)v2si; // expected-error {{C-style cast from vector '__v2si' (vector of 2 'int' values) to scalar 'unsigned char' of different size}} 42 (void)reinterpret_cast<__v2si>(c); // expected-error {{reinterpret_cast from scalar 'unsigned char' to vector '__v2si' (vector of 2 'int' values) of different size}} 43 44 (void)reinterpret_cast<__v8hi>(v4hi); // expected-error {{reinterpret_cast from vector '__v4hi' (vector of 4 'short' values) to vector '__v8hi' (vector of 8 'short' values) of different size}} 45 (void)(__v8hi)v4hi; // expected-error {{C-style cast from vector '__v4hi' (vector of 4 'short' values) to vector '__v8hi' (vector of 8 'short' values) of different size}} 46 (void)reinterpret_cast<__v4hi>(v8hi); // expected-error {{reinterpret_cast from vector '__v8hi' (vector of 8 'short' values) to vector '__v4hi' (vector of 4 'short' values) of different size}} 47 (void)(__v4hi)v8hi; // expected-error {{C-style cast from vector '__v8hi' (vector of 8 'short' values) to vector '__v4hi' (vector of 4 'short' values) of different size}} 48 49 (void)(__v3hi)v4hi; // expected-error {{C-style cast from vector '__v4hi' (vector of 4 'short' values) to vector '__v3hi' (vector of 3 'short' values) of different size}} 50 (void)(__v3hi)v2si; // expected-error {{C-style cast from vector '__v2si' (vector of 2 'int' values) to vector '__v3hi' (vector of 3 'short' values) of different size}} 51 (void)(__v4hi)v3hi; // expected-error {{C-style cast from vector '__v3hi' (vector of 3 'short' values) to vector '__v4hi' (vector of 4 'short' values) of different size}} 52 (void)(__v2si)v3hi; // expected-error {{C-style cast from vector '__v3hi' (vector of 3 'short' values) to vector '__v2si' (vector of 2 'int' values) of different size}} 53 (void)reinterpret_cast<__v3hi>(v4hi); // expected-error {{reinterpret_cast from vector '__v4hi' (vector of 4 'short' values) to vector '__v3hi' (vector of 3 'short' values) of different size}} 54 (void)reinterpret_cast<__v3hi>(v2si); // expected-error {{reinterpret_cast from vector '__v2si' (vector of 2 'int' values) to vector '__v3hi' (vector of 3 'short' values) of different size}} 55 (void)reinterpret_cast<__v4hi>(v3hi); // expected-error {{reinterpret_cast from vector '__v3hi' (vector of 3 'short' values) to vector '__v4hi' (vector of 4 'short' values) of different size}} 56 (void)reinterpret_cast<__v2si>(v3hi); // expected-error {{reinterpret_cast from vector '__v3hi' (vector of 3 'short' values) to vector '__v2si' (vector of 2 'int' values) of different size}} 57 } 58 59 struct testvec { 60 __v2si v; 61 void madd(const testvec& rhs) { 62 v = v + rhs; // expected-error {{cannot convert between vector and non-scalar values}} 63 } 64 void madd2(testvec rhs) { 65 v = v + rhs; // expected-error {{cannot convert between vector and non-scalar values}} 66 } 67 }; 68 69 // rdar://15931426 70 // Conversions for return values. 71 __v4hi threeToFour(__v3hi v) { // expected-note {{not viable}} 72 return v; // expected-error {{cannot initialize return object}} 73 } 74 __v3hi fourToThree(__v4hi v) { // expected-note {{not viable}} 75 return v; // expected-error {{cannot initialize return object}} 76 } 77 // Conversions for calls. 78 void call3to4(__v4hi v) { 79 (void) threeToFour(v); // expected-error {{no matching function for call}} 80 } 81 void call4to3(__v3hi v) { 82 (void) fourToThree(v); // expected-error {{no matching function for call}} 83 } 84