1fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s 2a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++98 %s 3a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++11 %s 4a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar 5fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregortypedef char char16 __attribute__ ((__vector_size__ (16))); 6fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregortypedef long long longlong16 __attribute__ ((__vector_size__ (16))); 7fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregortypedef char char16_e __attribute__ ((__ext_vector_type__ (16))); 8fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregortypedef long long longlong16_e __attribute__ ((__ext_vector_type__ (2))); 9fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 10fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor// Test overloading and function calls with vector types. 11fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid f0(char16); 12fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 13fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid f0_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { 14fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f0(c16); 15fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f0(ll16); 16fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f0(c16e); 17fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f0(ll16e); 18fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor} 19fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 20fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorint &f1(char16); // expected-note 2{{candidate function}} 21fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorfloat &f1(longlong16); // expected-note 2{{candidate function}} 22fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 23fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { 24fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor int &ir1 = f1(c16); 25fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor float &fr1 = f1(ll16); 26fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f1(c16e); // expected-error{{call to 'f1' is ambiguous}} 27fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f1(ll16e); // expected-error{{call to 'f1' is ambiguous}} 28fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor} 29fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 306bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen 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}} \ 316bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen 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}} 32fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 33fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid f2_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { 34fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f2(c16); 35fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f2(ll16); 36fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f2(c16e); 37fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f2(ll16e); // expected-error{{no matching function}} 38fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f2('a'); 39fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor f2(17); 40fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor} 41fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 42fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor// Test the conditional operator with vector types. 43b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballmanvoid conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e, 44fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor longlong16_e ll16e) { 45fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor // Conditional operators with the same type. 46fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor __typeof__(Cond? c16 : c16) *c16p1 = &c16; 47fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor __typeof__(Cond? ll16 : ll16) *ll16p1 = &ll16; 48fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor __typeof__(Cond? c16e : c16e) *c16ep1 = &c16e; 49fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor __typeof__(Cond? ll16e : ll16e) *ll16ep1 = &ll16e; 50fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 51fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor // Conditional operators with similar types. 52fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor __typeof__(Cond? c16 : c16e) *c16ep2 = &c16e; 53fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor __typeof__(Cond? c16e : c16) *c16ep3 = &c16e; 54fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor __typeof__(Cond? ll16 : ll16e) *ll16ep2 = &ll16e; 55fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor __typeof__(Cond? ll16e : ll16) *ll16ep3 = &ll16e; 56fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 57e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher // Conditional operators with compatible types under -flax-vector-conversions (default) 58e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher (void)(Cond? c16 : ll16); 59e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher (void)(Cond? ll16e : c16e); 60e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher (void)(Cond? ll16e : c16); 61fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor} 62fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 63fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor// Test C++ cast'ing of vector types. 64fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregorvoid casts(longlong16 ll16, longlong16_e ll16e) { 65fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor // C-style casts. 66fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)(char16)ll16; 67fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)(char16_e)ll16; 68fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)(longlong16)ll16; 69fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)(longlong16_e)ll16; 70fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)(char16)ll16e; 71fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)(char16_e)ll16e; 72fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)(longlong16)ll16e; 73fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)(longlong16_e)ll16e; 74fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 75fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor // Function-style casts. 76fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)char16(ll16); 77fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)char16_e(ll16); 78fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)longlong16(ll16); 79fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)longlong16_e(ll16); 80fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)char16(ll16e); 81fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)char16_e(ll16e); 82fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)longlong16(ll16e); 83fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)longlong16_e(ll16e); 84fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 85fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor // static_cast 86fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)static_cast<char16>(ll16); 87fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)static_cast<char16_e>(ll16); 88fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)static_cast<longlong16>(ll16); 89fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)static_cast<longlong16_e>(ll16); 90fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)static_cast<char16>(ll16e); 916bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen 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}} 92fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)static_cast<longlong16>(ll16e); 93fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)static_cast<longlong16_e>(ll16e); 94fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor 95fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor // reinterpret_cast 96fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)reinterpret_cast<char16>(ll16); 97fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)reinterpret_cast<char16_e>(ll16); 98fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)reinterpret_cast<longlong16>(ll16); 99fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)reinterpret_cast<longlong16_e>(ll16); 100fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)reinterpret_cast<char16>(ll16e); 101fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)reinterpret_cast<char16_e>(ll16e); 102fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)reinterpret_cast<longlong16>(ll16e); 103fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor (void)reinterpret_cast<longlong16_e>(ll16e); 104fb4a5436839aae5f5599f2970997e23ee6b895b6Douglas Gregor} 105a1158558305290c461f874757eedb68913b5420fDouglas Gregor 106a1158558305290c461f874757eedb68913b5420fDouglas Gregortemplate<typename T> 107a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainarstruct convertible_to { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable}} 108a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar#if __cplusplus >= 201103L // C++11 or later 109a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar// expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}} 110a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar#endif 111a1158558305290c461f874757eedb68913b5420fDouglas Gregor operator T() const; 112a1158558305290c461f874757eedb68913b5420fDouglas Gregor}; 113a1158558305290c461f874757eedb68913b5420fDouglas Gregor 114b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballmanvoid test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16, 11526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor char16_e c16e, longlong16_e ll16e, 116b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman convertible_to<char16> to_c16, 117b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman convertible_to<longlong16> to_ll16, 118b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman convertible_to<char16_e> to_c16e, 11926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor convertible_to<longlong16_e> to_ll16e, 12026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor convertible_to<char16&> rto_c16, 12126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor convertible_to<char16_e&> rto_c16e) { 122a1158558305290c461f874757eedb68913b5420fDouglas Gregor f0(to_c16); 123a1158558305290c461f874757eedb68913b5420fDouglas Gregor f0(to_ll16); 124a1158558305290c461f874757eedb68913b5420fDouglas Gregor f0(to_c16e); 125a1158558305290c461f874757eedb68913b5420fDouglas Gregor f0(to_ll16e); 126a1158558305290c461f874757eedb68913b5420fDouglas Gregor f2(to_c16); 127a1158558305290c461f874757eedb68913b5420fDouglas Gregor f2(to_ll16); 128a1158558305290c461f874757eedb68913b5420fDouglas Gregor f2(to_c16e); 129a1158558305290c461f874757eedb68913b5420fDouglas Gregor f2(to_ll16e); // expected-error{{no matching function}} 13026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor 13126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(c16 == c16e); 13226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(c16 == to_c16); 13326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)+to_c16; 13426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)-to_c16; 13526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)~to_c16; 13626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 == to_c16e); 13726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 != to_c16e); 13826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 < to_c16e); 13926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 <= to_c16e); 14026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 > to_c16e); 14126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 >= to_c16e); 14226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 + to_c16); 14326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 - to_c16); 14426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 * to_c16); 14526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 / to_c16); 14626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16 = to_c16); // expected-error{{no viable overloaded '='}} 14726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16 += to_c16); 14826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16 -= to_c16); 14926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16 *= to_c16); 15026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16 /= to_c16); 15126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor 15226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)+to_c16e; 15326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)-to_c16e; 15426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)~to_c16e; 15526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e == to_c16e); 15626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e != to_c16e); 15726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e < to_c16e); 15826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e <= to_c16e); 15926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e > to_c16e); 16026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e >= to_c16e); 16126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e + to_c16); 16226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e - to_c16); 16326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e * to_c16); 16426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16e / to_c16); 16526bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16e = to_c16); // expected-error{{no viable overloaded '='}} 16626bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16e += to_c16); 16726bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16e -= to_c16); 16826bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16e *= to_c16); 16926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16e /= to_c16); 17026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor 17126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)+to_c16; 17226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)-to_c16; 17326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)~to_c16; 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)(to_c16 > to_c16e); 17926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 >= to_c16e); 18026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 + to_c16e); 18126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 - to_c16e); 18226bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 * to_c16e); 18326bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(to_c16 / to_c16e); 18426bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(rto_c16 = c16e); // expected-error{{no viable overloaded '='}} 185b9b4b789ebd28d6fde1c42de820b036ffaf95162Eli Friedman (void)(rto_c16 += to_c16e); 186b9b4b789ebd28d6fde1c42de820b036ffaf95162Eli Friedman (void)(rto_c16 -= to_c16e); 187b9b4b789ebd28d6fde1c42de820b036ffaf95162Eli Friedman (void)(rto_c16 *= to_c16e); 188b9b4b789ebd28d6fde1c42de820b036ffaf95162Eli Friedman (void)(rto_c16 /= to_c16e); 18926bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor 19026bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(Cond? to_c16 : to_c16e); 19126bcf67d0156e2aec6ea184f8c2fb6186ec7b1e3Douglas Gregor (void)(Cond? to_ll16e : to_ll16); 192b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman 193e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher // These 2 are convertable with -flax-vector-conversions (default) 194e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher (void)(Cond? to_c16 : to_ll16); 195e84f9ebf8c89d5600f5930b65a0df0de890791b2Eric Christopher (void)(Cond? to_c16e : to_ll16e); 196a1158558305290c461f874757eedb68913b5420fDouglas Gregor} 1977c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor 1987c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregortypedef float fltx2 __attribute__((__vector_size__(8))); 1997c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregortypedef float fltx4 __attribute__((__vector_size__(16))); 2007c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregortypedef double dblx2 __attribute__((__vector_size__(16))); 2017c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregortypedef double dblx4 __attribute__((__vector_size__(32))); 2027c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor 2036bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen 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}} 2047c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregorvoid accept_fltx4(fltx4); 2057c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregorvoid accept_dblx2(dblx2); 2067c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregorvoid accept_dblx4(dblx4); 2076bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen 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}} 2087c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor 2097c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregorvoid test(fltx2 fltx2_val, fltx4 fltx4_val, dblx2 dblx2_val, dblx4 dblx4_val) { 2107c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor // Exact matches 2117c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor accept_fltx2(fltx2_val); 2127c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor accept_fltx4(fltx4_val); 2137c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor accept_dblx2(dblx2_val); 2147c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor accept_dblx4(dblx4_val); 2157c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor 2167c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor // Same-size conversions 2177c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor // FIXME: G++ rejects these conversions, we accept them. Revisit this! 2187c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor accept_fltx4(dblx2_val); 2197c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor accept_dblx2(fltx4_val); 2207c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor 2217c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor // Conversion to bool. 2227c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor accept_bool(fltx2_val); // expected-error{{no matching function for call to 'accept_bool'}} 2237c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor 2247c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor // Scalar-to-vector conversions. 2257c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor accept_fltx2(1.0); // expected-error{{no matching function for call to 'accept_fltx2'}} 2267c5b1097f5833326b4f5046d6a7d5cb7b9060145Douglas Gregor} 2279c129f818038e0269ba6b095722aa70176dc321dRichard Smith 2289c129f818038e0269ba6b095722aa70176dc321dRichard Smithtypedef int intx4 __attribute__((__vector_size__(16))); 2299c129f818038e0269ba6b095722aa70176dc321dRichard Smithtypedef int inte4 __attribute__((__ext_vector_type__(4))); 2309c129f818038e0269ba6b095722aa70176dc321dRichard Smithtypedef int flte4 __attribute__((__ext_vector_type__(4))); 2319c129f818038e0269ba6b095722aa70176dc321dRichard Smith 2329c129f818038e0269ba6b095722aa70176dc321dRichard Smithvoid test_mixed_vector_types(fltx4 f, intx4 n, flte4 g, flte4 m) { 2339c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f == g); 2349c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(g != f); 2359c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f <= g); 2369c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(g >= f); 2379c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f < g); 2389c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(g > f); 2399c129f818038e0269ba6b095722aa70176dc321dRichard Smith 2409c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(+g); 2419c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(-g); 2429c129f818038e0269ba6b095722aa70176dc321dRichard Smith 2439c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f + g); 2449c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f - g); 2459c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f * g); 2469c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f / g); 2479c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f = g); 2489c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f += g); 2499c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f -= g); 2509c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f *= g); 2519c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(f /= g); 2529c129f818038e0269ba6b095722aa70176dc321dRichard Smith 2539c129f818038e0269ba6b095722aa70176dc321dRichard Smith 2549c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n == m); 2559c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(m != n); 2569c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n <= m); 2579c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(m >= n); 2589c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n < m); 2599c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(m > n); 2609c129f818038e0269ba6b095722aa70176dc321dRichard Smith 2619c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(+m); 2629c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(-m); 2639c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(~m); 2649c129f818038e0269ba6b095722aa70176dc321dRichard Smith 2659c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n + m); 2669c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n - m); 2679c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n * m); 2689c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n / m); 2699c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n % m); 2709c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n = m); 2719c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n += m); 2729c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n -= m); 2739c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n *= m); 2749c129f818038e0269ba6b095722aa70176dc321dRichard Smith (void)(n /= m); 2759c129f818038e0269ba6b095722aa70176dc321dRichard Smith} 2760cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor 2770cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregortemplate<typename T> void test_pseudo_dtor_tmpl(T *ptr) { 2780cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor ptr->~T(); 2790cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor (*ptr).~T(); 2800cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor} 2810cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor 2820cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregorvoid test_pseudo_dtor(fltx4 *f) { 2830cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor f->~fltx4(); 2840cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor (*f).~fltx4(); 2850cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor test_pseudo_dtor_tmpl(f); 2860cb8939851364eb37a0f8bf8bb47874b7d966915Douglas Gregor} 28726e51781f9d55cdae764facf8fe773aa2adb4569Eli Friedman 28826e51781f9d55cdae764facf8fe773aa2adb4569Eli Friedman// PR16204 28926e51781f9d55cdae764facf8fe773aa2adb4569Eli Friedmantypedef __attribute__((ext_vector_type(4))) int vi4; 29026e51781f9d55cdae764facf8fe773aa2adb4569Eli Friedmanconst int &reference_to_vec_element = vi4(1).x; 291b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman 292b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballman// PR12649 293b445cb9662067b7c7586815937b07828ede9bb49Aaron Ballmantypedef bool bad __attribute__((__vector_size__(16))); // expected-error {{invalid vector element type 'bool'}} 294