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