Skip to content

Fix clang errors blocking PCH compile and remaining Clang errors#58

Merged
jenatali merged 3 commits into
microsoft:masterfrom
ruiji-shi:user/ruishi/clang-fixes
Jun 13, 2026
Merged

Fix clang errors blocking PCH compile and remaining Clang errors#58
jenatali merged 3 commits into
microsoft:masterfrom
ruiji-shi:user/ruishi/clang-fixes

Conversation

@ruiji-shi

@ruiji-shi ruiji-shi commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix all Clang errors with 3 patterns below.

Pattern A — static constexprstatic const on arrays whose initializers are not constant expressions (2 sites)

Error message: error : constexpr variable 'map' must be initialized by a constant expression

Fix: Casting an integer to an unfixed enum where the result lies outside the enum's value range (e.g. (EnumType)-1 for an unsigned-underlying enum) is not a core constant expression. Demoting constexpr to const drops the strict constant-evaluation requirement; both arrays are only used at runtime, so nothing depended on their constexpr-ness during compile time.

Pattern B — disambiguate InitializeDeferredHandle<> partial specializations (1 site)

Error message: error: ambiguous partial specializations of 'InitializeDeferredHandle<void (*)(D3D10DDI_HDEVICE, const unsigned int *, D3D10DDI_HSHADER, D3D10DDI_HRTSHADER)>'

Fix: The TArgs...of the updated InitializeDeferredHandle is allowed to be empty, in which case its signature can collapse to the 4-arg form (HDEVICE, const UINT*, HSHADER, HRTSHADER) — which also matches the 1st 4-arg partial specialization InitializeDeferredHandle<void(*)(HDEVICE, TArgs, THandle, TRTHandle)> for PopulateDeferredShaderInit(m_pDDITable->pfnCreateComputeShader). Fix by adding one extra arg (TSignature) to exclude the 4-arg case from this specialization, and the 4-arg case is then unambiguously handled by the 1st specialization.

Pattern C — insert template keyword on dependent-template-name calls (30 sites)

Error message: error : expected expression

Fix: In Clang, when a dependent name is followed by < and is intended as a template-id, it must be preceded by the template keyword — otherwise the compiler parses < as the less-than operator and reports error: expected expression.

Validation

Local build for both Clang and MSVC build pass.

ruiji-shi and others added 3 commits June 12, 2026 11:08
…te lookups

Fixes the clang-cl errors that surface when building D3D11On12 under USE_CLANG=1.
MSVC accepts all of these forms; clang strictly enforces the standard. Behavior
on MSVC is byte-identical after the changes.

Three patterns are fixed:

* Pattern A - `static constexpr` -> `static const` on lookup arrays whose
  initializers are not core constant expressions (`(EnumType)<out-of-range-int>`
  casts).
  - include/VideoTranslate.hpp:86 (`VideoDecodeArgumentType::map`)
  - src/device.cpp:34 (local `D3D12_FORMAT_SUPPORT1_CAPTURE`)

* Pattern B - eliminate the partial-specialization ambiguity in
  `InitializeDeferredHandle<>` by forcing the 5+-arg specialization to require
  at least one extra arg (parameter pack must be non-empty), so the 4-arg case
  is unambiguously handled by the existing 4-arg partial specialization.
  - include/DeviceChild.hpp:50-57

* Pattern C - insert the `template` keyword on dependent-template-name calls in
  the `FillContextDDIs<TDevice>` function template, so clang parses the `<` as
  the start of a template-id rather than as less-than.
  - src/device.cpp:358-391 (30 sites: SetShader, SetShaderWithIfaces,
    SetShaderResources, SetConstantBuffers, SetSamplers, six shader stages each)

Validated against an OS enlistment by building
onecoreuap\windows\DirectX\dxg\d3d11\d3d11on12 (24 files compiled, 0 errors)
and the sibling onecoreuap\windows\DirectX\dxg\d3d11\D3D11On12Internal (6 files,
0 errors) under USE_CLANG=1, plus an MSVC build at the same scope (49 files,
0 errors) to confirm no regression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…te lookups

Fixes the clang-cl errors that surface when building D3D11On12 under USE_CLANG=1.
MSVC accepts all of these forms; clang strictly enforces the standard. Behavior
on MSVC is byte-identical after the changes.

Three patterns are fixed:

* Pattern A - `static constexpr` -> `static const` on lookup arrays whose
  initializers are not core constant expressions (`(EnumType)<out-of-range-int>`
  casts).
  - include/VideoTranslate.hpp:86 (`VideoDecodeArgumentType::map`)
  - src/device.cpp:34 (local `D3D12_FORMAT_SUPPORT1_CAPTURE`)

* Pattern B - eliminate the partial-specialization ambiguity in
  `InitializeDeferredHandle<>` by forcing the 5+-arg specialization to require
  the trailing shader IO signatures pointer. The 4-arg form (which only
  pfnCreateComputeShader hits, since Compute is the only shader stage without
  an IO signatures argument) is then unambiguously handled by the existing
  4-arg partial specialization, whose Initialize body for that instantiation
  produces the same memory write.
  - include/DeviceChild.hpp:50-57

* Pattern C - insert the `template` keyword on dependent-template-name calls in
  the `FillContextDDIs<TDevice>` function template, so clang parses the `<` as
  the start of a template-id rather than as less-than.
  - src/device.cpp:358-391 (30 sites: SetShader, SetShaderWithIfaces,
    SetShaderResources, SetConstantBuffers, SetSamplers, six shader stages each)

Validated against an OS enlistment by building
onecoreuap\windows\DirectX\dxg\d3d11\d3d11on12 (24 files compiled, 0 errors)
and the sibling onecoreuap\windows\DirectX\dxg\d3d11\D3D11On12Internal (6 files,
0 errors) under USE_CLANG=1, plus an MSVC build at the same scope (49 files,
0 errors) to confirm no regression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ruiji-shi ruiji-shi marked this pull request as ready for review June 12, 2026 22:06
@jenatali jenatali merged commit ee5d15d into microsoft:master Jun 13, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants