| 1 |
// RUN: %clang_cc1 -fenable-matrix -fsyntax-only %s -verify |
| 2 |
|
| 3 |
typedef char cx4x4 __attribute__((matrix_type(4, 4))); |
| 4 |
typedef int ix4x4 __attribute__((matrix_type(4, 4))); |
| 5 |
typedef short sx4x4 __attribute__((matrix_type(4, 4))); |
| 6 |
typedef int ix5x5 __attribute__((matrix_type(5, 5))); |
| 7 |
typedef float fx5x5 __attribute__((matrix_type(5, 5))); |
| 8 |
typedef int vec __attribute__((vector_size(4))); |
| 9 |
typedef struct test_struct { |
| 10 |
} test_struct; |
| 11 |
|
| 12 |
void f1(void) { |
| 13 |
cx4x4 m1; |
| 14 |
ix4x4 m2; |
| 15 |
sx4x4 m3; |
| 16 |
ix5x5 m4; |
| 17 |
fx5x5 m5; |
| 18 |
int i; |
| 19 |
vec v; |
| 20 |
test_struct *s; |
| 21 |
|
| 22 |
m2 = (ix4x4)m1; |
| 23 |
m3 = (sx4x4)m2; |
| 24 |
m4 = (ix5x5)m3; // expected-error {{conversion between matrix types 'ix5x5' (aka 'int __attribute__\ |
| 25 |
((matrix_type(5, 5)))') and 'sx4x4' (aka 'short __attribute__((matrix_type(4, 4)))') of different size \ |
| 26 |
is not allowed}} |
| 27 |
m5 = (ix5x5)m4; // expected-error {{assigning to 'fx5x5' (aka \ |
| 28 |
'float __attribute__((matrix_type(5, 5)))') from incompatible type 'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))')}} |
| 29 |
i = (int)m4; // expected-error {{conversion between matrix type 'ix5x5' (aka 'int __attribute__\ |
| 30 |
((matrix_type(5, 5)))') and incompatible type 'int' is not allowed}} |
| 31 |
m4 = (ix5x5)i; // expected-error {{conversion between matrix type 'ix5x5' (aka 'int __attribute__\ |
| 32 |
((matrix_type(5, 5)))') and incompatible type 'int' is not allowed}} |
| 33 |
v = (vec)m4; // expected-error {{conversion between matrix type 'ix5x5' (aka 'int __attribute__\ |
| 34 |
((matrix_type(5, 5)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}} |
| 35 |
m4 = (ix5x5)v; // expected-error {{conversion between matrix type 'ix5x5' (aka 'int __attribute__\ |
| 36 |
((matrix_type(5, 5)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}} |
| 37 |
s = (test_struct *)m3; // expected-error {{conversion between matrix type 'sx4x4' (aka 'short \ |
| 38 |
__attribute__((matrix_type(4, 4)))') and incompatible type 'test_struct *' (aka 'struct test_struct *') is not allowed}} |
| 39 |
m3 = (sx4x4)s; // expected-error {{conversion between matrix type 'sx4x4' (aka 'short \ |
| 40 |
__attribute__((matrix_type(4, 4)))') and incompatible type 'test_struct *' (aka 'struct test_struct *') is not allowed}} |
| 41 |
|
| 42 |
m4 = (ix5x5)m5; |
| 43 |
} |
| 44 |
|
| 45 |
typedef float float2_8x8 __attribute__((matrix_type(8, 8))); |
| 46 |
typedef double double_10x10 __attribute__((matrix_type(10, 10))); |
| 47 |
typedef double double_8x8 __attribute__((matrix_type(8, 8))); |
| 48 |
typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12))); |
| 49 |
typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12))); |
| 50 |
typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10))); |
| 51 |
|
| 52 |
void f2(void) { |
| 53 |
float2_8x8 m1; |
| 54 |
double_10x10 m2; |
| 55 |
double_8x8 m3; |
| 56 |
signed_int_12x12 m4; |
| 57 |
unsigned_int_12x12 m5; |
| 58 |
unsigned_int_10x10 m6; |
| 59 |
float f; |
| 60 |
|
| 61 |
m2 = (double_10x10)m1; // expected-error {{conversion between matrix types 'double_10x10' \ |
| 62 |
(aka 'double __attribute__((matrix_type(10, 10)))') and 'float2_8x8' (aka 'float __attribute__\ |
| 63 |
((matrix_type(8, 8)))') of different size is not allowed}} |
| 64 |
m3 = (double_8x8)m1; |
| 65 |
|
| 66 |
m5 = (unsigned_int_12x12)m4; |
| 67 |
m4 = (signed_int_12x12)m5; |
| 68 |
m6 = (unsigned_int_10x10)m4; // expected-error {{conversion between matrix types 'unsigned_int_10x10' \ |
| 69 |
(aka 'unsigned int __attribute__((matrix_type(10, 10)))') and 'signed_int_12x12' (aka 'int __attribute__\ |
| 70 |
((matrix_type(12, 12)))') of different size is not allowed}} |
| 71 |
f = (float)m4; // expected-error {{conversion between matrix type 'signed_int_12x12' \ |
| 72 |
(aka 'int __attribute__((matrix_type(12, 12)))') and incompatible type 'float' is not allowed}} |
| 73 |
m4 = (signed_int_12x12)f; // expected-error {{conversion between matrix type 'signed_int_12x12' \ |
| 74 |
(aka 'int __attribute__((matrix_type(12, 12)))') and incompatible type 'float' is not allowed}} |
| 75 |
} |