blob: 4bb58084397354545d6e26766585cf0c7da4d290 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Anders Carlsson0de51bc2009-09-16 19:19:43 +00002typedef int __v2si __attribute__((__vector_size__(8)));
3typedef short __v4hi __attribute__((__vector_size__(8)));
4typedef short __v8hi __attribute__((__vector_size__(16)));
5
6struct S { };
7
8void f() {
9 __v2si v2si;
10 __v4hi v4hi;
11 __v8hi v8hi;
12 unsigned long long ll;
13 unsigned char c;
14 S s;
15
16 (void)reinterpret_cast<__v2si>(v4hi);
17 (void)(__v2si)v4hi;
18 (void)reinterpret_cast<__v4hi>(v2si);
19 (void)(__v4hi)v2si;
20 (void)reinterpret_cast<unsigned long long>(v2si);
21 (void)(unsigned long long)v2si;
22 (void)reinterpret_cast<__v2si>(ll);
23 (void)(__v2si)(ll);
24
John McCall7c2342d2010-03-10 11:27:22 +000025 (void)reinterpret_cast<S>(v2si); // expected-error {{reinterpret_cast from '__v2si' to 'S' is not allowed}}
26 (void)(S)v2si; // expected-error {{C-style cast from '__v2si' to 'S' is not allowed}}
27 (void)reinterpret_cast<__v2si>(s); // expected-error {{reinterpret_cast from 'S' to '__v2si' is not allowed}}
28 (void)(__v2si)s; // expected-error {{C-style cast from 'S' to '__v2si' is not allowed}}
Anders Carlsson0de51bc2009-09-16 19:19:43 +000029
30 (void)reinterpret_cast<unsigned char>(v2si); // expected-error {{reinterpret_cast from vector '__v2si' to scalar 'unsigned char' of different size}}
31 (void)(unsigned char)v2si; // expected-error {{C-style cast from vector '__v2si' to scalar 'unsigned char' of different size}}
32 (void)reinterpret_cast<__v2si>(c); // expected-error {{reinterpret_cast from scalar 'unsigned char' to vector '__v2si' of different size}}
33
34 (void)reinterpret_cast<__v8hi>(v4hi); // expected-error {{reinterpret_cast from vector '__v4hi' to vector '__v8hi' of different size}}
35 (void)(__v8hi)v4hi; // expected-error {{C-style cast from vector '__v4hi' to vector '__v8hi' of different size}}
36 (void)reinterpret_cast<__v4hi>(v8hi); // expected-error {{reinterpret_cast from vector '__v8hi' to vector '__v4hi' of different size}}
37 (void)(__v4hi)v8hi; // expected-error {{C-style cast from vector '__v8hi' to vector '__v4hi' of different size}}
38}
39
40