annotate clang/test/Sema/vector-ops.c @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10
anatofuz
parents:
diff changeset
2 typedef unsigned int v2u __attribute__ ((vector_size (8)));
anatofuz
parents:
diff changeset
3 typedef int v2s __attribute__ ((vector_size (8)));
anatofuz
parents:
diff changeset
4 typedef float v2f __attribute__ ((vector_size(8)));
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 void test1(v2u v2ua, v2s v2sa, v2f v2fa) {
anatofuz
parents:
diff changeset
7 // Bitwise binary operators
anatofuz
parents:
diff changeset
8 (void)(v2ua & v2ua);
anatofuz
parents:
diff changeset
9 (void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}}
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 // Unary operators
anatofuz
parents:
diff changeset
12 (void)(~v2ua);
anatofuz
parents:
diff changeset
13 (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}}
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 // Comparison operators
anatofuz
parents:
diff changeset
16 v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int)))) int' (vector of 2 'int' values}}
anatofuz
parents:
diff changeset
17 v2sa = (v2ua==v2sa);
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 // Arrays
anatofuz
parents:
diff changeset
20 int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values}}
anatofuz
parents:
diff changeset
21 int array2[17];
anatofuz
parents:
diff changeset
22 // FIXME: error message below needs type!
anatofuz
parents:
diff changeset
23 (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}}
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 v2u *v2u_ptr = 0;
anatofuz
parents:
diff changeset
26 v2s *v2s_ptr;
anatofuz
parents:
diff changeset
27 v2s_ptr = v2u_ptr; // expected-warning{{converts between pointers to integer types with different sign}}
anatofuz
parents:
diff changeset
28 }
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 void testLogicalVecVec(v2u v2ua, v2s v2sa, v2f v2fa) {
anatofuz
parents:
diff changeset
31 // Logical operators
anatofuz
parents:
diff changeset
32 v2ua = v2ua && v2ua; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2u'}}
anatofuz
parents:
diff changeset
33 v2ua = v2ua || v2ua; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2u'}}
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 v2ua = v2sa && v2ua; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2u' (vector of 2 'unsigned int' values)}}
anatofuz
parents:
diff changeset
36 v2ua = v2sa || v2ua; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2u' (vector of 2 'unsigned int' values)}}
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 v2ua = v2ua && v2fa; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
39 v2ua = v2ua || v2fa; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 v2ua = v2sa && v2fa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
42 v2ua = v2sa || v2fa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
43
anatofuz
parents:
diff changeset
44 v2sa = v2sa && v2sa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2s'}}
anatofuz
parents:
diff changeset
45 v2sa = v2sa || v2sa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2s'}}
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 v2sa = v2ua && v2ua; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2u'}}
anatofuz
parents:
diff changeset
48 v2sa = v2ua || v2ua; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2u'}}
anatofuz
parents:
diff changeset
49
anatofuz
parents:
diff changeset
50 v2sa = v2sa && v2ua; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2u' (vector of 2 'unsigned int' values)}}
anatofuz
parents:
diff changeset
51 v2sa = v2sa || v2ua; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2u' (vector of 2 'unsigned int' values)}}
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 v2sa = v2sa && v2fa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
54 v2sa = v2sa || v2fa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
55
anatofuz
parents:
diff changeset
56 v2sa = v2ua && v2fa; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
57 v2sa = v2ua || v2fa; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 v2fa = v2fa && v2fa; // expected-error {{logical expression with vector types 'v2f' (vector of 2 'float' values) and 'v2f'}}
anatofuz
parents:
diff changeset
60 v2fa = v2fa || v2fa; // expected-error {{logical expression with vector types 'v2f' (vector of 2 'float' values) and 'v2f'}}
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 v2fa = v2sa && v2fa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
63 v2fa = v2sa || v2fa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
64
anatofuz
parents:
diff changeset
65 v2fa = v2ua && v2fa; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
66 v2fa = v2ua || v2fa; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2f' (vector of 2 'float' values)}}
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 v2fa = v2ua && v2ua; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2u'}}
anatofuz
parents:
diff changeset
69 v2fa = v2ua || v2ua; // expected-error {{logical expression with vector types 'v2u' (vector of 2 'unsigned int' values) and 'v2u'}}
anatofuz
parents:
diff changeset
70
anatofuz
parents:
diff changeset
71 v2fa = v2sa && v2sa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2s'}}
anatofuz
parents:
diff changeset
72 v2fa = v2sa || v2sa; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2s'}}
anatofuz
parents:
diff changeset
73
anatofuz
parents:
diff changeset
74 v2fa = v2sa && v2ua; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2u' (vector of 2 'unsigned int' values)}}
anatofuz
parents:
diff changeset
75 v2fa = v2sa || v2ua; // expected-error {{logical expression with vector types 'v2s' (vector of 2 'int' values) and 'v2u' (vector of 2 'unsigned int' values)}}
anatofuz
parents:
diff changeset
76 }
anatofuz
parents:
diff changeset
77
anatofuz
parents:
diff changeset
78 void testLogicalVecScalar(v2u v2ua, v2s v2sa, v2f v2fa) {
anatofuz
parents:
diff changeset
79 unsigned u1;
anatofuz
parents:
diff changeset
80 v2ua = v2ua && u1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'unsigned int' is only supported in C++}}
anatofuz
parents:
diff changeset
81 v2ua = v2ua || u1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'unsigned int' is only supported in C++}}
anatofuz
parents:
diff changeset
82
anatofuz
parents:
diff changeset
83 v2sa = v2sa && u1; // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'v2s' (vector of 2 'int' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'unsigned int')}}
anatofuz
parents:
diff changeset
84 v2sa = v2sa || u1; // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'v2s' (vector of 2 'int' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'unsigned int')}}
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 v2ua = v2sa && u1; // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'v2s' (vector of 2 'int' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'unsigned int')}}
anatofuz
parents:
diff changeset
87 v2ua = v2sa || u1; // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'v2s' (vector of 2 'int' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2s' (vector of 2 'int' values) and 'unsigned int')}}
anatofuz
parents:
diff changeset
88 v2sa = v2ua && u1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'unsigned int' is only supported in C++}}
anatofuz
parents:
diff changeset
89 v2sa = v2ua || u1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'unsigned int' is only supported in C++}}
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 v2ua = v2fa && u1; // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'v2f' (vector of 2 'float' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'unsigned int')}}
anatofuz
parents:
diff changeset
92 v2ua = v2fa || u1; // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'v2f' (vector of 2 'float' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'unsigned int')}}
anatofuz
parents:
diff changeset
93
anatofuz
parents:
diff changeset
94 v2sa = v2fa && u1; // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'v2f' (vector of 2 'float' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'unsigned int')}}
anatofuz
parents:
diff changeset
95 v2sa = v2fa || u1; // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'v2f' (vector of 2 'float' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'unsigned int')}}
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 int s1;
anatofuz
parents:
diff changeset
98 v2ua = v2ua && s1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'int' is only supported in C++}}
anatofuz
parents:
diff changeset
99 v2ua = v2ua || s1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'int' is only supported in C++}}
anatofuz
parents:
diff changeset
100
anatofuz
parents:
diff changeset
101 v2sa = v2sa && s1; // expected-error {{logical expression with vector type 'v2s' (vector of 2 'int' values) and non-vector type 'int' is only supported in C++}}
anatofuz
parents:
diff changeset
102 v2sa = v2sa || s1; // expected-error {{logical expression with vector type 'v2s' (vector of 2 'int' values) and non-vector type 'int' is only supported in C++}}
anatofuz
parents:
diff changeset
103
anatofuz
parents:
diff changeset
104 v2ua = v2sa && s1; // expected-error {{logical expression with vector type 'v2s' (vector of 2 'int' values) and non-vector type 'int' is only supported in C++}}
anatofuz
parents:
diff changeset
105 v2ua = v2sa || s1; // expected-error {{logical expression with vector type 'v2s' (vector of 2 'int' values) and non-vector type 'int' is only supported in C++}}
anatofuz
parents:
diff changeset
106
anatofuz
parents:
diff changeset
107 v2sa = v2ua && s1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'int' is only supported in C++}}
anatofuz
parents:
diff changeset
108 v2sa = v2ua || s1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'int' is only supported in C++}}
anatofuz
parents:
diff changeset
109
anatofuz
parents:
diff changeset
110 v2ua = v2fa && s1; // expected-error {{cannot convert between scalar type 'int' and vector type 'v2f' (vector of 2 'float' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'int'}}
anatofuz
parents:
diff changeset
111 v2ua = v2fa || s1; // expected-error {{cannot convert between scalar type 'int' and vector type 'v2f' (vector of 2 'float' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'int'}}
anatofuz
parents:
diff changeset
112
anatofuz
parents:
diff changeset
113 v2sa = v2fa && s1; // expected-error {{cannot convert between scalar type 'int' and vector type 'v2f' (vector of 2 'float' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'int'}}
anatofuz
parents:
diff changeset
114 v2sa = v2fa || s1; // expected-error {{cannot convert between scalar type 'int' and vector type 'v2f' (vector of 2 'float' values) as implicit conversion would cause truncation}} expected-error {{invalid operands to binary expression ('v2f' (vector of 2 'float' values) and 'int'}}
anatofuz
parents:
diff changeset
115
anatofuz
parents:
diff changeset
116 float f1;
anatofuz
parents:
diff changeset
117 v2ua = v2ua && f1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
118 v2ua = v2ua || f1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
119
anatofuz
parents:
diff changeset
120 v2sa = v2sa && f1; // expected-error {{logical expression with vector type 'v2s' (vector of 2 'int' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
121 v2sa = v2sa || f1; // expected-error {{logical expression with vector type 'v2s' (vector of 2 'int' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
122
anatofuz
parents:
diff changeset
123 v2ua = v2sa && f1; // expected-error {{logical expression with vector type 'v2s' (vector of 2 'int' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
124 v2ua = v2sa || f1; // expected-error {{logical expression with vector type 'v2s' (vector of 2 'int' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
125
anatofuz
parents:
diff changeset
126 v2sa = v2ua && f1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
127 v2sa = v2ua || f1; // expected-error {{logical expression with vector type 'v2u' (vector of 2 'unsigned int' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
128
anatofuz
parents:
diff changeset
129 v2ua = v2fa && f1; // expected-error {{logical expression with vector type 'v2f' (vector of 2 'float' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
130 v2ua = v2fa || f1; // expected-error {{logical expression with vector type 'v2f' (vector of 2 'float' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
131
anatofuz
parents:
diff changeset
132 v2sa = v2fa && f1; // expected-error {{logical expression with vector type 'v2f' (vector of 2 'float' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
133 v2sa = v2fa || f1; // expected-error {{logical expression with vector type 'v2f' (vector of 2 'float' values) and non-vector type 'float' is only supported in C++}}
anatofuz
parents:
diff changeset
134
anatofuz
parents:
diff changeset
135 }