xref: /llvm-project/clang/test/SemaCXX/placement-new-matrix.cpp (revision af0ee617fc5f69051297b0c23f8c818b20f02c3a)
1 // RUN: %clang_cc1 -fenable-matrix -fsyntax-only -verify %s -std=c++11
2 
3 using Matrix = int __attribute__((matrix_type(4, 3)));
4 
5 template <__SIZE_TYPE__ a, __SIZE_TYPE__ b>
6 using TMatrix = int __attribute__((matrix_type(a, b)));
7 
8 struct S {
9     void* operator new(__SIZE_TYPE__, int);
10     void* operator new(__SIZE_TYPE__, Matrix);
11     void* operator new(__SIZE_TYPE__, TMatrix<2, 2>);
12 };
13 
main()14 int main() {
15     Matrix m;
16     TMatrix<2, 2> tm;
17 
18     new (m) S {};
19     new (tm) S {};
20 
21     new (m[1][1]) S {};
22     new (tm[1][1]) S {};
23 
24     new (m[1]) S {}; // expected-error {{single subscript expressions are not allowed for matrix values}}
25     new (tm[1]) S {}; // expected-error {{single subscript expressions are not allowed for matrix values}}
26 }
27