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)));
7 struct S
{ }; // expected-note 3 {{candidate constructor}}
9 enum E
: long long { Evalue
};
16 unsigned long long ll
;
21 (void)reinterpret_cast<__v2si
>(v4hi
);
23 (void)reinterpret_cast<__v4hi
>(v2si
);
25 (void)reinterpret_cast<unsigned long long>(v2si
);
26 (void)(unsigned long long)v2si
;
27 (void)reinterpret_cast<__v2si
>(ll
);
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)}}
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}}
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}}
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}}
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}}
61 void madd(const testvec
& rhs
) {
62 v
= v
+ rhs
; // expected-error {{cannot convert between vector and non-scalar values}}
64 void madd2(testvec rhs
) {
65 v
= v
+ rhs
; // expected-error {{cannot convert between vector and non-scalar values}}
69 // Conversions for return values.
70 __v4hi
threeToFour(__v3hi v
) { // expected-note {{not viable}}
71 return v
; // expected-error {{cannot initialize return object}}
73 __v3hi
fourToThree(__v4hi v
) { // expected-note {{not viable}}
74 return v
; // expected-error {{cannot initialize return object}}
76 // Conversions for calls.
77 void call3to4(__v4hi v
) {
78 (void) threeToFour(v
); // expected-error {{no matching function for call}}
80 void call4to3(__v3hi v
) {
81 (void) fourToThree(v
); // expected-error {{no matching function for call}}