microsoft / microsoft/DirectXShaderCompiler

`column_major` and `row_major` don't apply correctly to template-dependent types

Open
#4,722 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

hlsl2021 matrix-bug tech-debt
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

This is caused by the same issue as #4583, so the required transformation is similar.

This test case should cover the interesting cases:

// RUN: %clang_cc1 -HV 2021 -fsyntax-only -ffreestanding -verify %s

template <typename T, int X, int Y>
struct Matrices {
  row_major matrix<T, X, Y> RowMajor;
  column_major matrix<T, X, Y> RowMajor;

  row_major T NotAMatrix;        // expected-error {{'row_major' can only be used with a matrix type}}
  column_major T AlsoNotAMatrix; // expected-error {{'column_major' can only be used with a matrix type}}
};

struct AlsoMatrices {
  row_major matrix<float, 4, 4> RowMajor;
  column_major matrix<float, 4, 4> RowMajor;

  row_major float NotAMatrix;        // expected-error {{'row_major' can only be used with a matrix type}}
  column_major float AlsoNotAMatrix; // expected-error {{'column_major' can only be used with a matrix type}}
};

void fn() {
  Matrices<float, 4, 4> ShouldWork;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the template-dependent matrix declarations in this issue with the required transformation described in #4583. Run the provided clang_cc1 test case with -HV 2021 and -verify; done means the matrix qualifiers work for dependent types while the non-matrix declarations produce the shown diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.