1 // RUN: %clang_cc1 -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 2 {{candidate constructor}}
8
f()9 void f() {
10 __v2si v2si;
11 __v4hi v4hi;
12 __v8hi v8hi;
13 unsigned long long ll;
14 unsigned char c;
15 S s;
16
17 (void)reinterpret_cast<__v2si>(v4hi);
18 (void)(__v2si)v4hi;
19 (void)reinterpret_cast<__v4hi>(v2si);
20 (void)(__v4hi)v2si;
21 (void)reinterpret_cast<unsigned long long>(v2si);
22 (void)(unsigned long long)v2si;
23 (void)reinterpret_cast<__v2si>(ll);
24 (void)(__v2si)(ll);
25
26 (void)reinterpret_cast<S>(v2si); // expected-error {{reinterpret_cast from '__v2si' (vector of 2 'int' values) to 'S' is not allowed}}
27 (void)(S)v2si; // expected-error {{no matching conversion for C-style cast from '__v2si' (vector of 2 'int' values) to 'S'}}
28 (void)reinterpret_cast<__v2si>(s); // expected-error {{reinterpret_cast from 'S' to '__v2si' (vector of 2 'int' values) is not allowed}}
29 (void)(__v2si)s; // expected-error {{cannot convert 'S' to '__v2si' (vector of 2 'int' values) without a conversion operator}}
30
31 (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}}
32 (void)(unsigned char)v2si; // expected-error {{C-style cast from vector '__v2si' (vector of 2 'int' values) to scalar 'unsigned char' of different size}}
33 (void)reinterpret_cast<__v2si>(c); // expected-error {{reinterpret_cast from scalar 'unsigned char' to vector '__v2si' (vector of 2 'int' values) of different size}}
34
35 (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}}
36 (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}}
37 (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}}
38 (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}}
39 }
40
41 struct testvec {
42 __v2si v;
maddtestvec43 void madd(const testvec& rhs) {
44 v = v + rhs; // expected-error {{can't convert between vector and non-scalar values}}
45 }
madd2testvec46 void madd2(testvec rhs) {
47 v = v + rhs; // expected-error {{can't convert between vector and non-scalar values}}
48 }
49 };
50
51 // rdar://15931426
52 // Conversions for return values.
threeToFour(__v3hi v)53 __v4hi threeToFour(__v3hi v) { // expected-note {{not viable}}
54 return v; // expected-error {{cannot initialize return object}}
55 }
fourToThree(__v4hi v)56 __v3hi fourToThree(__v4hi v) { // expected-note {{not viable}}
57 return v; // expected-error {{cannot initialize return object}}
58 }
59 // Conversions for calls.
call3to4(__v4hi v)60 void call3to4(__v4hi v) {
61 (void) threeToFour(v); // expected-error {{no matching function for call}}
62 }
call4to3(__v3hi v)63 void call4to3(__v3hi v) {
64 (void) fourToThree(v); // expected-error {{no matching function for call}}
65 }
66