1 // RUN: %clang_cc1 %s -fenable-matrix -pedantic -verify -triple=x86_64-apple-darwin9
3 typedef float sx5x10_t
__attribute__((matrix_type(5, 10)));
4 typedef float sx10x5_t
__attribute__((matrix_type(10, 5)));
5 typedef float sx10x10_t
__attribute__((matrix_type(10, 10)));
7 void add(sx10x10_t a
, sx5x10_t b
, sx10x5_t c
) {
9 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
12 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
14 a
= b
+ b
; // expected-error {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
17 // expected-error@-1 {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
20 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*'))}}
21 // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
24 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*'))}}
25 // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
28 void sub(sx10x10_t a
, sx5x10_t b
, sx10x5_t c
) {
30 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
33 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t' (aka 'float __attribute__((matrix_type(10, 5)))'))}}
35 a
= b
- b
; // expected-error {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
38 // expected-error@-1 {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
41 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*'))}}
42 // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
45 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*'))}}
46 // expected-error@-2 {{casting 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
49 typedef int ix10x5_t
__attribute__((matrix_type(10, 5)));
50 typedef int ix10x10_t
__attribute__((matrix_type(10, 10)));
52 void matrix_matrix_multiply(sx10x10_t a
, sx5x10_t b
, ix10x5_t c
, ix10x10_t d
, float sf
, char *p
) {
53 // Check dimension mismatches.
55 // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))'))}}
57 // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))'))}}
59 // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'float __attribute__((matrix_type(10, 10)))'}}
61 // Check element type mismatches.
63 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
65 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
67 // expected-error@-1 {{assigning to 'ix10x10_t' (aka 'int __attribute__((matrix_type(10, 10)))') from incompatible type 'float __attribute__((matrix_type(10, 10)))'}}
70 // expected-error@-1 {{assigning to 'char *' from incompatible type 'float __attribute__((matrix_type(10, 10)))'}}
73 void mat_scalar_multiply(sx10x10_t a
, sx5x10_t b
, float sf
, char *p
) {
74 // Shape of multiplication result does not match the type of b.
76 // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
78 // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
81 // expected-error@-1 {{casting 'char *' to incompatible type 'float'}}
82 // expected-error@-2 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'char *')}}
84 // expected-error@-1 {{casting 'char *' to incompatible type 'float'}}
85 // expected-error@-2 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'char *')}}
87 // expected-error@-1 {{casting 'char *' to incompatible type 'float'}}
88 // expected-error@-2 {{invalid operands to binary expression ('char *' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
90 // expected-error@-1 {{casting 'char *' to incompatible type 'float'}}
91 // expected-error@-2 {{invalid operands to binary expression ('char *' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
94 // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
97 void mat_scalar_divide(sx10x10_t a
, sx5x10_t b
, float sf
, char *p
) {
98 // Shape of multiplication result does not match the type of b.
100 // expected-error@-1 {{assigning to 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
102 // expected-error@-1 {{invalid operands to binary expression ('float' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
105 // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'char *')}}
107 // expected-error@-1 {{invalid operands to binary expression ('char *' and 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))'))}}
110 // expected-error@-1 {{assigning to 'float' from incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))')}}
113 void matrix_matrix_divide(sx10x10_t a
, sx5x10_t b
, ix10x5_t c
, ix10x10_t d
, float sf
, char *p
) {
114 // Matrix by matrix division is not supported.
116 // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
119 // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
121 // Check element type mismatches.
123 // expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'ix10x5_t' (aka 'int __attribute__((matrix_type(10, 5)))'))}}
125 // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
128 // expected-error@-1 {{invalid operands to binary expression ('sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') and 'sx10x10_t')}}
131 sx5x10_t
get_matrix(void);
133 void insert(sx5x10_t a
, float f
) {
134 // Non integer indexes.
136 // expected-error@-1 {{matrix column index is not an integer}}
138 // expected-error@-1 {{matrix row index is not an integer}}
140 // expected-error@-1 {{matrix row index is not an integer}}
141 // expected-error@-2 {{matrix column index is not an integer}}
143 // expected-error@-1 {{matrix column index is not an integer}}
146 // expected-error@-1 {{matrix row index is not an integer}}
147 // expected-error@-2 {{matrix column index is not an integer}}
149 // Invalid element type.
151 // expected-error@-1 {{assigning to 'float' from incompatible type 'float *'; remove &}}
153 // Indexes outside allowed dimensions.
155 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
157 // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
159 // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
161 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
163 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
165 // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
167 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
169 // expected-error@-1 {{matrix row and column subscripts cannot be separated by any expression}}
172 // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
175 // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
177 get_matrix()[0][0] = f
;
178 // expected-error@-1 {{expression is not assignable}}
179 get_matrix()[5][1] = f
;
180 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
181 get_matrix()[3] = 5.0;
182 // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
184 (get_matrix()[5])[10.0] = f
;
185 // expected-error@-1 {{matrix row and column subscripts cannot be separated by any expression}}
186 (get_matrix()[3]) = 5.0;
187 // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
190 // expected-error@-1 {{expected expression}}
192 // expected-error@-1 {{expected expression}}
195 void extract(sx5x10_t a
, float f
) {
196 // Non integer indexes.
198 // expected-error@-1 {{matrix column index is not an integer}}
200 // expected-error@-1 {{matrix row index is not an integer}}
202 // expected-error@-1 {{matrix row index is not an integer}}
203 // expected-error@-2 {{matrix column index is not an integer}}
205 // Invalid element type.
207 // expected-error@-1 {{initializing 'char *' with an expression of incompatible type 'float'}}
209 // Indexes outside allowed dimensions.
211 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
213 // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
214 float v8
= a
[-1u][3];
215 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
217 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
218 float v10
= a
[4][10];
219 // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
221 // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
224 // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
227 float *address_of_element(sx5x10_t
*a
) {
229 // expected-error@-1 {{address of matrix element requested}}