2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-09-17 03:19:43 +08:00
|
|
|
typedef int __v2si __attribute__((__vector_size__(8)));
|
|
|
|
typedef short __v4hi __attribute__((__vector_size__(8)));
|
|
|
|
typedef short __v8hi __attribute__((__vector_size__(16)));
|
2014-02-05 07:58:19 +08:00
|
|
|
typedef short __v3hi __attribute__((__ext_vector_type__(3)));
|
2009-09-17 03:19:43 +08:00
|
|
|
|
2011-02-15 02:34:10 +08:00
|
|
|
struct S { }; // expected-note 2 {{candidate constructor}}
|
2009-09-17 03:19:43 +08:00
|
|
|
|
|
|
|
void f() {
|
|
|
|
__v2si v2si;
|
|
|
|
__v4hi v4hi;
|
|
|
|
__v8hi v8hi;
|
|
|
|
unsigned long long ll;
|
|
|
|
unsigned char c;
|
|
|
|
S s;
|
|
|
|
|
|
|
|
(void)reinterpret_cast<__v2si>(v4hi);
|
|
|
|
(void)(__v2si)v4hi;
|
|
|
|
(void)reinterpret_cast<__v4hi>(v2si);
|
|
|
|
(void)(__v4hi)v2si;
|
|
|
|
(void)reinterpret_cast<unsigned long long>(v2si);
|
|
|
|
(void)(unsigned long long)v2si;
|
|
|
|
(void)reinterpret_cast<__v2si>(ll);
|
|
|
|
(void)(__v2si)(ll);
|
|
|
|
|
2010-03-10 19:27:22 +08:00
|
|
|
(void)reinterpret_cast<S>(v2si); // expected-error {{reinterpret_cast from '__v2si' to 'S' is not allowed}}
|
2011-02-15 02:34:10 +08:00
|
|
|
(void)(S)v2si; // expected-error {{no matching conversion for C-style cast from '__v2si' to 'S'}}
|
2010-03-10 19:27:22 +08:00
|
|
|
(void)reinterpret_cast<__v2si>(s); // expected-error {{reinterpret_cast from 'S' to '__v2si' is not allowed}}
|
2011-02-15 02:34:10 +08:00
|
|
|
(void)(__v2si)s; // expected-error {{cannot convert 'S' to '__v2si' without a conversion operator}}
|
2009-09-17 03:19:43 +08:00
|
|
|
|
|
|
|
(void)reinterpret_cast<unsigned char>(v2si); // expected-error {{reinterpret_cast from vector '__v2si' to scalar 'unsigned char' of different size}}
|
|
|
|
(void)(unsigned char)v2si; // expected-error {{C-style cast from vector '__v2si' to scalar 'unsigned char' of different size}}
|
|
|
|
(void)reinterpret_cast<__v2si>(c); // expected-error {{reinterpret_cast from scalar 'unsigned char' to vector '__v2si' of different size}}
|
|
|
|
|
|
|
|
(void)reinterpret_cast<__v8hi>(v4hi); // expected-error {{reinterpret_cast from vector '__v4hi' to vector '__v8hi' of different size}}
|
|
|
|
(void)(__v8hi)v4hi; // expected-error {{C-style cast from vector '__v4hi' to vector '__v8hi' of different size}}
|
|
|
|
(void)reinterpret_cast<__v4hi>(v8hi); // expected-error {{reinterpret_cast from vector '__v8hi' to vector '__v4hi' of different size}}
|
|
|
|
(void)(__v4hi)v8hi; // expected-error {{C-style cast from vector '__v8hi' to vector '__v4hi' of different size}}
|
|
|
|
}
|
|
|
|
|
2014-01-07 15:59:31 +08:00
|
|
|
struct testvec {
|
|
|
|
__v2si v;
|
|
|
|
void madd(const testvec& rhs) {
|
|
|
|
v = v + rhs; // expected-error {{can't convert between vector and non-scalar values}}
|
|
|
|
}
|
|
|
|
void madd2(testvec rhs) {
|
|
|
|
v = v + rhs; // expected-error {{can't convert between vector and non-scalar values}}
|
|
|
|
}
|
|
|
|
};
|
2014-02-05 07:58:19 +08:00
|
|
|
|
|
|
|
// rdar://15931426
|
|
|
|
// Conversions for return values.
|
|
|
|
__v4hi threeToFour(__v3hi v) { // expected-note {{not viable}}
|
|
|
|
return v; // expected-error {{cannot initialize return object}}
|
|
|
|
}
|
|
|
|
__v3hi fourToThree(__v4hi v) { // expected-note {{not viable}}
|
|
|
|
return v; // expected-error {{cannot initialize return object}}
|
|
|
|
}
|
|
|
|
// Conversions for calls.
|
|
|
|
void call3to4(__v4hi v) {
|
|
|
|
(void) threeToFour(v); // expected-error {{no matching function for call}}
|
|
|
|
}
|
|
|
|
void call4to3(__v3hi v) {
|
|
|
|
(void) fourToThree(v); // expected-error {{no matching function for call}}
|
|
|
|
}
|