[clang] [Matrix][Clang][HLSL] Move MaxMatrixDimension to a LangOpt (PR #163307)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 15 07:57:38 PDT 2025
llvm-beanz wrote:
The behavior change is that in HLSL-mode the `matrix_type` attribute has reduced size limits.
> We are confirming that the constraint is applied on matrix<int, 5, 5> mat3;
>
> https://github.com/llvm/llvm-project/blob/b358af10a7b783e771a1e5ad6ded3e3535648b06/clang/test/SemaHLSL/BuiltIns/matrix-basic_types-errors.hlsl#L10-L12
This is enforced by the `matrix` template, you're changing the implementation to _also_ enforce this on the `matrix_type` attribute.
> Since the behavior differences are tested. I’ve just added an explicit compiler invocation test to confirm this number changes When we change the language mode to HLSL. I think that’s all you wanted?
With this PR, clang should generate an error on this code:
```c++
using float8x8 = __attribute__((matrix_type(8,8))) float;
```
Which would not have been generated without this PR (See [Compiler Explorer](https://godbolt.org/z/Gh53nEGEs))
https://github.com/llvm/llvm-project/pull/163307
More information about the cfe-commits
mailing list