llvm-project
73014a8d - [Clang] Fix assertion when instantiating a matrix type with an invalid element type (#224331)

Commit
25 days ago
[Clang] Fix assertion when instantiating a matrix type with an invalid element type (#224331) Fixes #202744 `Sema::BuildMatrixType` skips the element type check while the element type is dependent, so `template <typename Y> using matrix_5_5 = Y __attribute__((matrix_type(5, 5)));` gives a `ConstantMatrixType` whose element is still unchecked. On instantiation, `TreeTransform::RebuildConstantMatrixType` called `ASTContext::getConstantMatrixType` directly, so nothing ever validated the substituted type. `matrix_5_5<matrix_5_5<float>>` then hit the "need a valid element type" assertion. The dependent-dimension case (`matrix_type(R, C)`) was fine because `RebuildDependentSizedMatrixType` already goes through `BuildMatrixType`. `RebuildConstantMatrixType` now goes through `Sema::BuildMatrixType` as well, the same way `RebuildExtVectorType` does for vectors: it takes the attribute location and wraps the dimensions in integer literals. An invalid instantiated element type now gets the usual `invalid matrix element type` error instead of crashing, and the `_BitInt` element check that this path also skipped is applied too.
Parents
Loading