Emit error for user-defined conversion operators in HLSL#6
Draft
Emit error for user-defined conversion operators in HLSL#6
Conversation
…soft#5103) Add err_hlsl_unsupported_conversion_operator diagnostic and check in CheckConversionDeclarator to reject conversion operators in HLSL. Previously these were silently ignored, misleading users into thinking their cast operator overloads were being used. Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue 5103 and add tests for validation
Emit error for user-defined conversion operators in HLSL
Feb 21, 2026
damyanp
requested changes
Feb 21, 2026
…oad is not allowed' Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
damyanp
approved these changes
Feb 21, 2026
Owner
|
@copilot add a short one-line description of this change to ReleaseNotes.md |
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
Author
Added in |
damyanp
pushed a commit
that referenced
this pull request
Mar 9, 2026
… for `vk::SampledTexture2D` type. (microsoft#8149) Part of microsoft#7979 ```hlsl TemplateType GatherRed(float2 Location, int2 Offset1, int2 Offset2, int2 Offset3, int2 Offset4, uint Status); TemplateType GatherGreen(float2 Location, int2 Offset1, int2 Offset2, int2 Offset3, int2 Offset4, uint Status); TemplateType GatherBlue(float2 Location, int2 Offset1, int2 Offset2, int2 Offset3, int2 Offset4, uint Status); TemplateType GatherAlpha(float2 Location, int2 Offset1, int2 Offset2, int2 Offset3, int2 Offset4, uint Status); TemplateType GatherCmp(float Location, float CompareValue, int2 Offset, uint Status); TemplateType GatherCmpRed(float Location, float CompareValue, int2 Offset1, int2 Offset2, int2 Offset3, int2 Offset4, uint Status); ``` GatherCmpGreen, GatherCmpBlue, GatherCmpAlpha, GatherRaw are not supported.
damyanp
requested changes
Mar 11, 2026
| // This test verifies that dxcompiler generates an error when defining | ||
| // a conversion operator (cast operator), which is not supported in HLSL. | ||
|
|
||
| struct MyStruct { |
Owner
There was a problem hiding this comment.
Should there be a test for the template-dependent case?
Author
There was a problem hiding this comment.
Added a template-dependent test case (template<typename T> struct TemplateStruct { operator T() { ... } }) in 2fcaf368. The error is caught at parse time in CheckConversionDeclarator, so it fires even without template instantiation.
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
This commit fixes 2 warnings showing on when building on MacOS: - CMP0135: setting which policy is applied on download freshness check - METAL_IRCONVERTER case not matching the FindPackage filename.
) Update `DxilStructAnnotation` to be aware of target types. Otherwise the annotation would declare a struct with a single LinAlg Matrix type as empty, leading to invalid codegen. Declaration names match the style of the surrounding code. Fixes microsoft#8279
Addresses outstanding cleanup requests from the initial LinAlg exec test PR --------- Co-authored-by: Damyan Pepper <damyanp@microsoft.com>
Updates the SPIR-V dependencies, and update an invalid test.
The experimental Cooperative Vector feature has been superseded by LinAlg. This change removes the code supporting the old feature. Fixes microsoft#8147 --------- Co-authored-by: Helena Kotas <hekotas@microsoft.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
DxilCounters.cpp wasn't getting updated when HLSL_COPY_GENERATED_SOURCES was set. This change fixes that, and includes the updated DxilCounters.cpp. add_hlsl_hctgen now adds the file extension to the target it creates, which allows us to generate both DxilCounters.h and DxilCounters.cpp. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
Previous docs were....misleading at best. This change makes them more accurate.
…oft#8174) (microsoft#8177) PR microsoft#7799 added debug info for global variables across all inlined subprograms, creating O(subprograms x globals) debug instructions. This caused 2-3x slower compilation for shaders with many globals and deeply-inlined functions. Fix: Instead of collecting ALL subprograms for a function (walking every instruction), only collect subprograms from the alloca's actual users -- the instructions that reference the specific global variable. This preserves the debug info feature (globals visible in inlined scopes that use them) while eliminating work for unrelated scopes. The 'Lower static global into Alloca' pass is 3.8x faster on a stress test (41ms -> 11ms), and overall debug compilation is ~10% faster. Fixes microsoft#8174 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…103-tests # Conflicts: # docs/ReleaseNotes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
operator float4()) are silently ignored in HLSL instead of producing an errorerr_hlsl_unsupported_conversion_operatorinDiagnosticSemaKinds.tdCheckConversionDeclaratorinSemaDeclCXX.cppto emit error when a conversion operator is definedtools/clang/test/SemaHLSL/conversion-operator-errors.hlslfollowing existing patternserr_hlsl_overloading_operator_disalloweddocs/ReleaseNotes.md🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.