Skip to content

Commit 98a61b2

Browse files
committed
add more tests and cover the row and column size too large case with a new diagnostic
1 parent 1d1ff45 commit 98a61b2

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

clang/lib/Sema/SemaType.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,6 +2517,12 @@ QualType Sema::BuildMatrixType(QualType ElementTy, Expr *NumRows, Expr *NumCols,
25172517
Diag(AttrLoc, diag::err_attribute_zero_size) << "matrix" << ColRange;
25182518
return QualType();
25192519
}
2520+
if (MatrixRows > Context.getLangOpts().MaxMatrixDimension &&
2521+
MatrixColumns > Context.getLangOpts().MaxMatrixDimension) {
2522+
Diag(AttrLoc, diag::err_attribute_size_too_large)
2523+
<< RowRange << ColRange << "matrix row and column";
2524+
return QualType();
2525+
}
25202526
if (MatrixRows > Context.getLangOpts().MaxMatrixDimension) {
25212527
Diag(AttrLoc, diag::err_attribute_size_too_large)
25222528
<< RowRange << "matrix row";

clang/test/SemaCXX/matrix-type.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ void matrix_var_dimensions(int Rows, unsigned Columns, char C) {
1414
using matrix7_t = int __attribute__((matrix_type(1, 0))); // expected-error{{zero matrix size}}
1515
using matrix7_t = int __attribute__((matrix_type(char, 0))); // expected-error{{expected '(' for function-style cast or type construction}}
1616
using matrix8_t = int __attribute__((matrix_type(1048576, 1))); // expected-error{{matrix row size too large}}
17+
using matrix8_t = int __attribute__((matrix_type(1048576, 1048576))); // expected-error{{matrix row and column size too large}}
1718
}
1819

1920
struct S1 {};

clang/test/SemaHLSL/BuiltIns/matrix-basic_types-errors.hlsl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,20 @@ using float8x4 = __attribute__((matrix_type(8,4))) float;
1616

1717
using float4x8 = __attribute__((matrix_type(4,8))) float;
1818
// expected-error@-1 {{matrix column size too large}}
19+
20+
using float8x8 = __attribute__((matrix_type(8,8))) float;
21+
// expected-error@-1 {{matrix row and column size too large}}
22+
23+
using floatNeg1x4 = __attribute__((matrix_type(-1,4))) float;
24+
// expected-error@-1 {{matrix row size too large}}
25+
using float4xNeg1 = __attribute__((matrix_type(4,-1))) float;
26+
// expected-error@-1 {{matrix column size too large}}
27+
using floatNeg1xNeg1 = __attribute__((matrix_type(-1,-1))) float;
28+
// expected-error@-1 {{matrix row and column size too large}}
29+
30+
using float0x4 = __attribute__((matrix_type(0,4))) float;
31+
// expected-error@-1 {{zero matrix size}}
32+
using float4x0 = __attribute__((matrix_type(4,0))) float;
33+
// expected-error@-1 {{zero matrix size}}
34+
using float0x0 = __attribute__((matrix_type(0,0))) float;
35+
// expected-error@-1 {{zero matrix size}}

0 commit comments

Comments
 (0)