-
Notifications
You must be signed in to change notification settings - Fork 808
Fix typo of register -> registers crashes DXC with segfault #7729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+50
−0
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2bbd043
Register assignments with mismatching ': register()' syntax now doesn…
Nielsbishere 9e78ab3
Clang format
Nielsbishere 3d3574e
Merge branch 'main' of https://github.com/Microsoft/DirectXShaderComp…
Nielsbishere fdcc854
Added hlsl unit test to check if registers() crashes or produces the …
Nielsbishere 5a0391d
Greatly simplified the invalid hlsl annotation check to allow it to w…
Nielsbishere f835f7b
Changed packofset to packoffsets and added one where it also uses inv…
Nielsbishere 6cfc632
Fixed the error message
Nielsbishere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // RUN: %dxc -T lib_6_3 -verify %s | ||
|
|
||
| // expected-error@+1 {{Syntax similar to : register() was used but unexpected keyword 'registers' was used instead.}} | ||
| RWStructuredBuffer<float4> uav1 : registers(u3); | ||
|
|
||
| [shader("pixel")] | ||
| float4 main(): SV_Target | ||
| { | ||
| uav1[0] = 2; | ||
| return 0.xxxx; | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also work with
: register (u3);?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also would you be able to add a case for an incorrectly spelled pack offset?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I think you're correct there, I've never heard of that syntax before. Will fix it and add a test for it.
: register (u3)uses the same parsing as before (I only moved it), so that should still work. I can still add a test for it though.The pack offset is pretty annoying, because from what I saw in #hlsl code horrors... I'll let the code speak for itself:
So I can't automatically exclude this error when it's parsing a constant buffer. I guess the way would be to fallback to parsing that syntax (packoffset syntax) if it fails to be parsed as a register...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, HLSL horrors beyond comprehension.
I meant adding a test case for packoffset, not exactly sure what you mean by fix it.
You might consider making the error diagnostic more generic, like "unexpected identifier %s, expected an hlsl attribute " or something to that effect. That way if the packoffset parsing fails you can reuse the same error.
I'm not sure falling back would work either because we only attempt to parse the register if the next token is detected to be a register token.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and... packoffset allows unions apparently.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that packoffset likely will get unintentionally parsed as register() as you suggested. I think I might be able to correctly identify it's misspelled packoffset as long as the rest of the syntax is similar.