1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
typedef char char16 __attribute__ ((__vector_size__ (16)));
typedef long long longlong16 __attribute__ ((__vector_size__ (16)));
typedef char char16_e __attribute__ ((__ext_vector_type__ (16)));
typedef long long longlong16_e __attribute__ ((__ext_vector_type__ (2)));
// Test overloading and function calls with vector types.
void f0(char16);
void f0_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
f0(c16);
f0(ll16);
f0(c16e);
f0(ll16e);
}
int &f1(char16); // expected-note 2{{candidate function}}
float &f1(longlong16); // expected-note 2{{candidate function}}
void f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
int &ir1 = f1(c16);
float &fr1 = f1(ll16);
f1(c16e); // expected-error{{call to 'f1' is ambiguous}}
f1(ll16e); // expected-error{{call to 'f1' is ambiguous}}
}
void f2(char16_e); // expected-note{{no known conversion from 'longlong16_e' to 'char16_e' for 1st argument}} \
// expected-note{{candidate function not viable: no known conversion from 'convertible_to<longlong16_e>' to 'char16_e' for 1st argument}}
void f2_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
f2(c16);
f2(ll16);
f2(c16e);
f2(ll16e); // expected-error{{no matching function}}
f2('a');
f2(17);
}
// Test the conditional operator with vector types.
void conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e,
longlong16_e ll16e) {
// Conditional operators with the same type.
__typeof__(Cond? c16 : c16) *c16p1 = &c16;
__typeof__(Cond? ll16 : ll16) *ll16p1 = &ll16;
__typeof__(Cond? c16e : c16e) *c16ep1 = &c16e;
__typeof__(Cond? ll16e : ll16e) *ll16ep1 = &ll16e;
// Conditional operators with similar types.
__typeof__(Cond? c16 : c16e) *c16ep2 = &c16e;
__typeof__(Cond? c16e : c16) *c16ep3 = &c16e;
__typeof__(Cond? ll16 : ll16e) *ll16ep2 = &ll16e;
__typeof__(Cond? ll16e : ll16) *ll16ep3 = &ll16e;
// Conditional operators with incompatible types.
(void)(Cond? c16 : ll16); // expected-error{{can't convert between vector values}}
(void)(Cond? ll16e : c16e); // expected-error{{can't convert between vector values}}
(void)(Cond? ll16e : c16); // expected-error{{can't convert between vector values}}
}
// Test C++ cast'ing of vector types.
void casts(longlong16 ll16, longlong16_e ll16e) {
// C-style casts.
(void)(char16)ll16;
(void)(char16_e)ll16;
(void)(longlong16)ll16;
(void)(longlong16_e)ll16;
(void)(char16)ll16e;
(void)(char16_e)ll16e;
(void)(longlong16)ll16e;
(void)(longlong16_e)ll16e;
// Function-style casts.
(void)char16(ll16);
(void)char16_e(ll16);
(void)longlong16(ll16);
(void)longlong16_e(ll16);
(void)char16(ll16e);
(void)char16_e(ll16e);
(void)longlong16(ll16e);
(void)longlong16_e(ll16e);
// static_cast
(void)static_cast<char16>(ll16);
(void)static_cast<char16_e>(ll16);
(void)static_cast<longlong16>(ll16);
(void)static_cast<longlong16_e>(ll16);
(void)static_cast<char16>(ll16e);
(void)static_cast<char16_e>(ll16e); // expected-error{{static_cast from 'longlong16_e' to 'char16_e' is not allowed}}
(void)static_cast<longlong16>(ll16e);
(void)static_cast<longlong16_e>(ll16e);
// reinterpret_cast
(void)reinterpret_cast<char16>(ll16);
(void)reinterpret_cast<char16_e>(ll16);
(void)reinterpret_cast<longlong16>(ll16);
(void)reinterpret_cast<longlong16_e>(ll16);
(void)reinterpret_cast<char16>(ll16e);
(void)reinterpret_cast<char16_e>(ll16e);
(void)reinterpret_cast<longlong16>(ll16e);
(void)reinterpret_cast<longlong16_e>(ll16e);
}
template<typename T>
struct convertible_to { // expected-note 3 {{candidate function (the implicit copy assignment operator)}}
operator T() const;
};
void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16,
char16_e c16e, longlong16_e ll16e,
convertible_to<char16> to_c16,
convertible_to<longlong16> to_ll16,
convertible_to<char16_e> to_c16e,
convertible_to<longlong16_e> to_ll16e,
convertible_to<char16&> rto_c16,
convertible_to<char16_e&> rto_c16e) {
f0(to_c16);
f0(to_ll16);
f0(to_c16e);
f0(to_ll16e);
f2(to_c16);
f2(to_ll16);
f2(to_c16e);
f2(to_ll16e); // expected-error{{no matching function}}
(void)(c16 == c16e);
(void)(c16 == to_c16);
(void)+to_c16;
(void)-to_c16;
(void)~to_c16;
(void)(to_c16 == to_c16e);
(void)(to_c16 != to_c16e);
(void)(to_c16 < to_c16e);
(void)(to_c16 <= to_c16e);
(void)(to_c16 > to_c16e);
(void)(to_c16 >= to_c16e);
(void)(to_c16 + to_c16);
(void)(to_c16 - to_c16);
(void)(to_c16 * to_c16);
(void)(to_c16 / to_c16);
(void)(rto_c16 = to_c16); // expected-error{{no viable overloaded '='}}
(void)(rto_c16 += to_c16);
(void)(rto_c16 -= to_c16);
(void)(rto_c16 *= to_c16);
(void)(rto_c16 /= to_c16);
(void)+to_c16e;
(void)-to_c16e;
(void)~to_c16e;
(void)(to_c16e == to_c16e);
(void)(to_c16e != to_c16e);
(void)(to_c16e < to_c16e);
(void)(to_c16e <= to_c16e);
(void)(to_c16e > to_c16e);
(void)(to_c16e >= to_c16e);
(void)(to_c16e + to_c16);
(void)(to_c16e - to_c16);
(void)(to_c16e * to_c16);
(void)(to_c16e / to_c16);
(void)(rto_c16e = to_c16); // expected-error{{no viable overloaded '='}}
(void)(rto_c16e += to_c16);
(void)(rto_c16e -= to_c16);
(void)(rto_c16e *= to_c16);
(void)(rto_c16e /= to_c16);
(void)+to_c16;
(void)-to_c16;
(void)~to_c16;
(void)(to_c16 == to_c16e);
(void)(to_c16 != to_c16e);
(void)(to_c16 < to_c16e);
(void)(to_c16 <= to_c16e);
(void)(to_c16 > to_c16e);
(void)(to_c16 >= to_c16e);
(void)(to_c16 + to_c16e);
(void)(to_c16 - to_c16e);
(void)(to_c16 * to_c16e);
(void)(to_c16 / to_c16e);
(void)(rto_c16 = c16e); // expected-error{{no viable overloaded '='}}
(void)(rto_c16 += to_c16e); // expected-error{{expression is not assignable}}
(void)(rto_c16 -= to_c16e); // expected-error{{expression is not assignable}}
(void)(rto_c16 *= to_c16e); // expected-error{{expression is not assignable}}
(void)(rto_c16 /= to_c16e); // expected-error{{expression is not assignable}}
(void)(Cond? to_c16 : to_c16e);
(void)(Cond? to_ll16e : to_ll16);
(void)(Cond? to_c16 : to_ll16); // expected-error{{can't convert between vector values of different size}}
(void)(Cond? to_c16e : to_ll16e); // expected-error{{can't convert between vector values of different size}}
}
|