1fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
2fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregortypedef char char16 __attribute__ ((__vector_size__ (16)));
3fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregortypedef long long longlong16 __attribute__ ((__vector_size__ (16)));
4fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregortypedef char char16_e __attribute__ ((__ext_vector_type__ (16)));
5fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregortypedef long long longlong16_e __attribute__ ((__ext_vector_type__ (2)));
6fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
7fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor// Test overloading and function calls with vector types.
8fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid f0(char16);
9fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
10fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid f0_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
11fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f0(c16);
12fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f0(ll16);
13fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f0(c16e);
14fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f0(ll16e);
15fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor}
16fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
17fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorint &f1(char16); // expected-note 2{{candidate function}}
18fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorfloat &f1(longlong16); // expected-note 2{{candidate function}}
19fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
20fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
21fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  int &ir1 = f1(c16);
22fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  float &fr1 = f1(ll16);
23fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f1(c16e); // expected-error{{call to 'f1' is ambiguous}}
24fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f1(ll16e); // expected-error{{call to 'f1' is ambiguous}}
25fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor}
26fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
276bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesvoid f2(char16_e); // expected-note{{no known conversion from 'longlong16_e' (vector of 2 'long long' values) to 'char16_e' (vector of 16 'char' values) for 1st argument}} \
286bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines       // expected-note{{candidate function not viable: no known conversion from 'convertible_to<longlong16_e>' to 'char16_e' (vector of 16 'char' values) for 1st argument}}
29fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
30fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid f2_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
31fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f2(c16);
32fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f2(ll16);
33fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f2(c16e);
34fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f2(ll16e); // expected-error{{no matching function}}
35fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f2('a');
36fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  f2(17);
37fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor}
38fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
39fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor// Test the conditional operator with vector types.
40b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballmanvoid conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e,
41fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor                 longlong16_e ll16e) {
42fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  // Conditional operators with the same type.
43fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  __typeof__(Cond? c16 : c16) *c16p1 = &c16;
44fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  __typeof__(Cond? ll16 : ll16) *ll16p1 = &ll16;
45fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  __typeof__(Cond? c16e : c16e) *c16ep1 = &c16e;
46fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  __typeof__(Cond? ll16e : ll16e) *ll16ep1 = &ll16e;
47fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
48fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  // Conditional operators with similar types.
49fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  __typeof__(Cond? c16 : c16e) *c16ep2 = &c16e;
50fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  __typeof__(Cond? c16e : c16) *c16ep3 = &c16e;
51fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  __typeof__(Cond? ll16 : ll16e) *ll16ep2 = &ll16e;
52fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  __typeof__(Cond? ll16e : ll16) *ll16ep3 = &ll16e;
53fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
54e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher  // Conditional operators with compatible types under -flax-vector-conversions (default)
55e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher  (void)(Cond? c16 : ll16);
56e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher  (void)(Cond? ll16e : c16e);
57e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher  (void)(Cond? ll16e : c16);
58fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor}
59fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
60fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor// Test C++ cast'ing of vector types.
61fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid casts(longlong16 ll16, longlong16_e ll16e) {
62fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  // C-style casts.
63fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)(char16)ll16;
64fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)(char16_e)ll16;
65fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)(longlong16)ll16;
66fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)(longlong16_e)ll16;
67fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)(char16)ll16e;
68fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)(char16_e)ll16e;
69fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)(longlong16)ll16e;
70fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)(longlong16_e)ll16e;
71fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
72fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  // Function-style casts.
73fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)char16(ll16);
74fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)char16_e(ll16);
75fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)longlong16(ll16);
76fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)longlong16_e(ll16);
77fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)char16(ll16e);
78fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)char16_e(ll16e);
79fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)longlong16(ll16e);
80fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)longlong16_e(ll16e);
81fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
82fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  // static_cast
83fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)static_cast<char16>(ll16);
84fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)static_cast<char16_e>(ll16);
85fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)static_cast<longlong16>(ll16);
86fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)static_cast<longlong16_e>(ll16);
87fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)static_cast<char16>(ll16e);
886bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  (void)static_cast<char16_e>(ll16e); // expected-error{{static_cast from 'longlong16_e' (vector of 2 'long long' values) to 'char16_e' (vector of 16 'char' values) is not allowed}}
89fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)static_cast<longlong16>(ll16e);
90fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)static_cast<longlong16_e>(ll16e);
91fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor
92fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  // reinterpret_cast
93fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)reinterpret_cast<char16>(ll16);
94fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)reinterpret_cast<char16_e>(ll16);
95fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)reinterpret_cast<longlong16>(ll16);
96fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)reinterpret_cast<longlong16_e>(ll16);
97fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)reinterpret_cast<char16>(ll16e);
98fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)reinterpret_cast<char16_e>(ll16e);
99fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)reinterpret_cast<longlong16>(ll16e);
100fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor  (void)reinterpret_cast<longlong16_e>(ll16e);
101fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor}
102a1158558305290c461f874757eedb68913b5420fDouglas Gregor
103a1158558305290c461f874757eedb68913b5420fDouglas Gregortemplate<typename T>
10426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregorstruct convertible_to { // expected-note 3 {{candidate function (the implicit copy assignment operator)}}
105a1158558305290c461f874757eedb68913b5420fDouglas Gregor  operator T() const;
106a1158558305290c461f874757eedb68913b5420fDouglas Gregor};
107a1158558305290c461f874757eedb68913b5420fDouglas Gregor
108b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballmanvoid test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16,
10926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor                               char16_e c16e, longlong16_e ll16e,
110b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman                               convertible_to<char16> to_c16,
111b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman                               convertible_to<longlong16> to_ll16,
112b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman                               convertible_to<char16_e> to_c16e,
11326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor                               convertible_to<longlong16_e> to_ll16e,
11426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor                               convertible_to<char16&> rto_c16,
11526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor                               convertible_to<char16_e&> rto_c16e) {
116a1158558305290c461f874757eedb68913b5420fDouglas Gregor  f0(to_c16);
117a1158558305290c461f874757eedb68913b5420fDouglas Gregor  f0(to_ll16);
118a1158558305290c461f874757eedb68913b5420fDouglas Gregor  f0(to_c16e);
119a1158558305290c461f874757eedb68913b5420fDouglas Gregor  f0(to_ll16e);
120a1158558305290c461f874757eedb68913b5420fDouglas Gregor  f2(to_c16);
121a1158558305290c461f874757eedb68913b5420fDouglas Gregor  f2(to_ll16);
122a1158558305290c461f874757eedb68913b5420fDouglas Gregor  f2(to_c16e);
123a1158558305290c461f874757eedb68913b5420fDouglas Gregor  f2(to_ll16e); // expected-error{{no matching function}}
12426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor
12526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(c16 == c16e);
12626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(c16 == to_c16);
12726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)+to_c16;
12826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)-to_c16;
12926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)~to_c16;
13026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 == to_c16e);
13126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 != to_c16e);
13226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 <  to_c16e);
13326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 <= to_c16e);
13426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 >  to_c16e);
13526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 >= to_c16e);
13626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 + to_c16);
13726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 - to_c16);
13826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 * to_c16);
13926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 / to_c16);
14026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16 = to_c16); // expected-error{{no viable overloaded '='}}
14126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16 += to_c16);
14226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16 -= to_c16);
14326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16 *= to_c16);
14426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16 /= to_c16);
14526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor
14626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)+to_c16e;
14726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)-to_c16e;
14826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)~to_c16e;
14926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e == to_c16e);
15026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e != to_c16e);
15126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e <  to_c16e);
15226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e <= to_c16e);
15326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e >  to_c16e);
15426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e >= to_c16e);
15526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e + to_c16);
15626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e - to_c16);
15726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e * to_c16);
15826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16e / to_c16);
15926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16e = to_c16); // expected-error{{no viable overloaded '='}}
16026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16e += to_c16);
16126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16e -= to_c16);
16226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16e *= to_c16);
16326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16e /= to_c16);
16426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor
16526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)+to_c16;
16626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)-to_c16;
16726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)~to_c16;
16826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 == to_c16e);
16926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 != to_c16e);
17026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 <  to_c16e);
17126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 <= to_c16e);
17226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 >  to_c16e);
17326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 >= to_c16e);
17426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 + to_c16e);
17526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 - to_c16e);
17626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 * to_c16e);
17726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(to_c16 / to_c16e);
17826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(rto_c16 = c16e); // expected-error{{no viable overloaded '='}}
179b9b4b789ebd28d6fde1c42de820b036ffaf95162Eli Friedman  (void)(rto_c16 += to_c16e);
180b9b4b789ebd28d6fde1c42de820b036ffaf95162Eli Friedman  (void)(rto_c16 -= to_c16e);
181b9b4b789ebd28d6fde1c42de820b036ffaf95162Eli Friedman  (void)(rto_c16 *= to_c16e);
182b9b4b789ebd28d6fde1c42de820b036ffaf95162Eli Friedman  (void)(rto_c16 /= to_c16e);
18326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor
18426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(Cond? to_c16 : to_c16e);
18526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor  (void)(Cond? to_ll16e : to_ll16);
186b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman
187e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher  // These 2 are convertable with -flax-vector-conversions (default)
188e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher  (void)(Cond? to_c16 : to_ll16);
189e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher  (void)(Cond? to_c16e : to_ll16e);
190a1158558305290c461f874757eedb68913b5420fDouglas Gregor}
1917c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor
1927c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregortypedef float fltx2 __attribute__((__vector_size__(8)));
1937c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregortypedef float fltx4 __attribute__((__vector_size__(16)));
1947c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregortypedef double dblx2 __attribute__((__vector_size__(16)));
1957c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregortypedef double dblx4 __attribute__((__vector_size__(32)));
1967c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor
1976bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesvoid accept_fltx2(fltx2); // expected-note{{candidate function not viable: no known conversion from 'double' to 'fltx2' (vector of 2 'float' values) for 1st argument}}
1987c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregorvoid accept_fltx4(fltx4);
1997c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregorvoid accept_dblx2(dblx2);
2007c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregorvoid accept_dblx4(dblx4);
2016bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesvoid accept_bool(bool); // expected-note{{candidate function not viable: no known conversion from 'fltx2' (vector of 2 'float' values) to 'bool' for 1st argument}}
2027c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor
2037c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregorvoid test(fltx2 fltx2_val, fltx4 fltx4_val, dblx2 dblx2_val, dblx4 dblx4_val) {
2047c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  // Exact matches
2057c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  accept_fltx2(fltx2_val);
2067c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  accept_fltx4(fltx4_val);
2077c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  accept_dblx2(dblx2_val);
2087c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  accept_dblx4(dblx4_val);
2097c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor
2107c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  // Same-size conversions
2117c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  // FIXME: G++ rejects these conversions, we accept them. Revisit this!
2127c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  accept_fltx4(dblx2_val);
2137c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  accept_dblx2(fltx4_val);
2147c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor
2157c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  // Conversion to bool.
2167c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  accept_bool(fltx2_val); // expected-error{{no matching function for call to 'accept_bool'}}
2177c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor
2187c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  // Scalar-to-vector conversions.
2197c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor  accept_fltx2(1.0); // expected-error{{no matching function for call to 'accept_fltx2'}}
2207c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor}
2219c129f818038e0269ba6b095722aa70176dc321dRichard Smith
2229c129f818038e0269ba6b095722aa70176dc321dRichard Smithtypedef int intx4 __attribute__((__vector_size__(16)));
2239c129f818038e0269ba6b095722aa70176dc321dRichard Smithtypedef int inte4 __attribute__((__ext_vector_type__(4)));
2249c129f818038e0269ba6b095722aa70176dc321dRichard Smithtypedef int flte4 __attribute__((__ext_vector_type__(4)));
2259c129f818038e0269ba6b095722aa70176dc321dRichard Smith
2269c129f818038e0269ba6b095722aa70176dc321dRichard Smithvoid test_mixed_vector_types(fltx4 f, intx4 n, flte4 g, flte4 m) {
2279c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f == g);
2289c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(g != f);
2299c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f <= g);
2309c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(g >= f);
2319c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f < g);
2329c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(g > f);
2339c129f818038e0269ba6b095722aa70176dc321dRichard Smith
2349c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(+g);
2359c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(-g);
2369c129f818038e0269ba6b095722aa70176dc321dRichard Smith
2379c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f + g);
2389c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f - g);
2399c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f * g);
2409c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f / g);
2419c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f = g);
2429c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f += g);
2439c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f -= g);
2449c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f *= g);
2459c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(f /= g);
2469c129f818038e0269ba6b095722aa70176dc321dRichard Smith
2479c129f818038e0269ba6b095722aa70176dc321dRichard Smith
2489c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n == m);
2499c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(m != n);
2509c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n <= m);
2519c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(m >= n);
2529c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n < m);
2539c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(m > n);
2549c129f818038e0269ba6b095722aa70176dc321dRichard Smith
2559c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(+m);
2569c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(-m);
2579c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(~m);
2589c129f818038e0269ba6b095722aa70176dc321dRichard Smith
2599c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n + m);
2609c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n - m);
2619c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n * m);
2629c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n / m);
2639c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n % m);
2649c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n = m);
2659c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n += m);
2669c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n -= m);
2679c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n *= m);
2689c129f818038e0269ba6b095722aa70176dc321dRichard Smith  (void)(n /= m);
2699c129f818038e0269ba6b095722aa70176dc321dRichard Smith}
2700cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor
2710cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregortemplate<typename T> void test_pseudo_dtor_tmpl(T *ptr) {
2720cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor  ptr->~T();
2730cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor  (*ptr).~T();
2740cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor}
2750cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor
2760cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregorvoid test_pseudo_dtor(fltx4 *f) {
2770cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor  f->~fltx4();
2780cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor  (*f).~fltx4();
2790cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor  test_pseudo_dtor_tmpl(f);
2800cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor}
28126e51781f9d55cdae764facf8fe773aa2adb4569Eli Friedman
28226e51781f9d55cdae764facf8fe773aa2adb4569Eli Friedman// PR16204
28326e51781f9d55cdae764facf8fe773aa2adb4569Eli Friedmantypedef __attribute__((ext_vector_type(4))) int vi4;
28426e51781f9d55cdae764facf8fe773aa2adb4569Eli Friedmanconst int &reference_to_vec_element = vi4(1).x;
285b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman
286b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman// PR12649
287b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballmantypedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
288