llvm-project/clang/test/SemaCXX/placement-new-matrix.cpp
Sirraide af0ee617fc
[Clang] Support MSPropertyRefExpr as placement arg to new-expression (#75883)
It seems we were forgetting to call `checkArgsForPlaceholders` on the
placement arguments of new-expressions in Sema. I don't think that was
intended—at least doing so doesn't seem to break anything—so this pr
adds that.

This also fixes #65053

---------

Co-authored-by: Erich Keane <ekeane@nvidia.com>
2024-01-17 15:09:31 -08:00

27 lines
742 B
C++

// RUN: %clang_cc1 -fenable-matrix -fsyntax-only -verify %s -std=c++11
using Matrix = int __attribute__((matrix_type(4, 3)));
template <__SIZE_TYPE__ a, __SIZE_TYPE__ b>
using TMatrix = int __attribute__((matrix_type(a, b)));
struct S {
void* operator new(__SIZE_TYPE__, int);
void* operator new(__SIZE_TYPE__, Matrix);
void* operator new(__SIZE_TYPE__, TMatrix<2, 2>);
};
int main() {
Matrix m;
TMatrix<2, 2> tm;
new (m) S {};
new (tm) S {};
new (m[1][1]) S {};
new (tm[1][1]) S {};
new (m[1]) S {}; // expected-error {{single subscript expressions are not allowed for matrix values}}
new (tm[1]) S {}; // expected-error {{single subscript expressions are not allowed for matrix values}}
}