Douglas Gregor | 4618868 | 2010-05-18 22:42:18 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s |
| 2 | typedef char char16 __attribute__ ((__vector_size__ (16))); |
| 3 | typedef long long longlong16 __attribute__ ((__vector_size__ (16))); |
| 4 | typedef char char16_e __attribute__ ((__ext_vector_type__ (16))); |
| 5 | typedef long long longlong16_e __attribute__ ((__ext_vector_type__ (2))); |
| 6 | |
| 7 | #if 1 |
| 8 | // Test overloading and function calls with vector types. |
| 9 | void f0(char16); |
| 10 | |
| 11 | void f0_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { |
| 12 | f0(c16); |
| 13 | f0(ll16); |
| 14 | f0(c16e); |
| 15 | f0(ll16e); |
| 16 | } |
| 17 | |
| 18 | int &f1(char16); // expected-note 2{{candidate function}} |
| 19 | float &f1(longlong16); // expected-note 2{{candidate function}} |
| 20 | |
| 21 | void f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { |
| 22 | int &ir1 = f1(c16); |
| 23 | float &fr1 = f1(ll16); |
| 24 | f1(c16e); // expected-error{{call to 'f1' is ambiguous}} |
| 25 | f1(ll16e); // expected-error{{call to 'f1' is ambiguous}} |
| 26 | } |
| 27 | |
| 28 | void f2(char16_e); // expected-note{{no known conversion from 'longlong16_e' to 'char16_e' for 1st argument}} |
| 29 | |
| 30 | void f2_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) { |
| 31 | f2(c16); |
| 32 | f2(ll16); |
| 33 | f2(c16e); |
| 34 | f2(ll16e); // expected-error{{no matching function}} |
| 35 | f2('a'); |
| 36 | f2(17); |
| 37 | } |
| 38 | #endif |
| 39 | |
| 40 | // Test the conditional operator with vector types. |
| 41 | void conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e, |
| 42 | longlong16_e ll16e) { |
| 43 | // Conditional operators with the same type. |
| 44 | __typeof__(Cond? c16 : c16) *c16p1 = &c16; |
| 45 | __typeof__(Cond? ll16 : ll16) *ll16p1 = &ll16; |
| 46 | __typeof__(Cond? c16e : c16e) *c16ep1 = &c16e; |
| 47 | __typeof__(Cond? ll16e : ll16e) *ll16ep1 = &ll16e; |
| 48 | |
| 49 | // Conditional operators with similar types. |
| 50 | __typeof__(Cond? c16 : c16e) *c16ep2 = &c16e; |
| 51 | __typeof__(Cond? c16e : c16) *c16ep3 = &c16e; |
| 52 | __typeof__(Cond? ll16 : ll16e) *ll16ep2 = &ll16e; |
| 53 | __typeof__(Cond? ll16e : ll16) *ll16ep3 = &ll16e; |
| 54 | |
| 55 | // Conditional operators with incompatible types. |
| 56 | (void)(Cond? c16 : ll16); // expected-error{{can't convert between vector values}} |
| 57 | (void)(Cond? ll16e : c16e); // expected-error{{can't convert between vector values}} |
| 58 | (void)(Cond? ll16e : c16); // expected-error{{can't convert between vector values}} |
| 59 | } |
| 60 | |
| 61 | // Test C++ cast'ing of vector types. |
| 62 | void casts(longlong16 ll16, longlong16_e ll16e) { |
| 63 | // C-style casts. |
| 64 | (void)(char16)ll16; |
| 65 | (void)(char16_e)ll16; |
| 66 | (void)(longlong16)ll16; |
| 67 | (void)(longlong16_e)ll16; |
| 68 | (void)(char16)ll16e; |
| 69 | (void)(char16_e)ll16e; |
| 70 | (void)(longlong16)ll16e; |
| 71 | (void)(longlong16_e)ll16e; |
| 72 | |
| 73 | // Function-style casts. |
| 74 | (void)char16(ll16); |
| 75 | (void)char16_e(ll16); |
| 76 | (void)longlong16(ll16); |
| 77 | (void)longlong16_e(ll16); |
| 78 | (void)char16(ll16e); |
| 79 | (void)char16_e(ll16e); |
| 80 | (void)longlong16(ll16e); |
| 81 | (void)longlong16_e(ll16e); |
| 82 | |
| 83 | // static_cast |
| 84 | (void)static_cast<char16>(ll16); |
| 85 | (void)static_cast<char16_e>(ll16); |
| 86 | (void)static_cast<longlong16>(ll16); |
| 87 | (void)static_cast<longlong16_e>(ll16); |
| 88 | (void)static_cast<char16>(ll16e); |
| 89 | (void)static_cast<char16_e>(ll16e); // expected-error{{static_cast from 'longlong16_e' to 'char16_e' is not allowed}} |
| 90 | (void)static_cast<longlong16>(ll16e); |
| 91 | (void)static_cast<longlong16_e>(ll16e); |
| 92 | |
| 93 | // reinterpret_cast |
| 94 | (void)reinterpret_cast<char16>(ll16); |
| 95 | (void)reinterpret_cast<char16_e>(ll16); |
| 96 | (void)reinterpret_cast<longlong16>(ll16); |
| 97 | (void)reinterpret_cast<longlong16_e>(ll16); |
| 98 | (void)reinterpret_cast<char16>(ll16e); |
| 99 | (void)reinterpret_cast<char16_e>(ll16e); |
| 100 | (void)reinterpret_cast<longlong16>(ll16e); |
| 101 | (void)reinterpret_cast<longlong16_e>(ll16e); |
| 102 | } |