[all-commits] [llvm/llvm-project] 73014a: [Clang] Fix assertion when instantiating a matrix ...

Akash Manna via All-commits all-commits at lists.llvm.org
Mon Sep 28 11:13:18 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 73014a8d08f4b205fd1f09bc0eb3e0cba7c5eff0
      https://github.com/llvm/llvm-project/commit/73014a8d08f4b205fd1f09bc0eb3e0cba7c5eff0
  Author: Akash Manna <akash.manna.mymail at gmail.com>
  Date:   2026-09-28 (Mon, 28 Sep 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.md
    M clang/lib/Sema/TreeTransform.h
    M clang/test/SemaTemplate/matrix-type.cpp

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list