-
Notifications
You must be signed in to change notification settings - Fork 795
Require complete types in some missing places #7511
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
llvm-beanz
merged 4 commits into
microsoft:main
from
llvm-beanz:cbieneman/sizeof-requires-type
Jun 5, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
33835fa
Require complete types in some missing places
llvm-beanz 5a2392c
Add more complete type checks and tests
tex3d 67acc56
Use Buffer instead of RayDesc for lazy-initialized type in test
tex3d 782b5f0
Handle null template type arg for templated Load/Store
tex3d 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
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
27 changes: 27 additions & 0 deletions
27
tools/clang/test/SemaHLSL/sizeof-requires-complete-type.hlsl
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,27 @@ | ||
// RUN: %dxc -T lib_6_3 -verify %s | ||
|
||
struct Complete {}; | ||
|
||
struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}} | ||
template<typename T> struct CompleteTemplate {}; | ||
|
||
void fn() { | ||
uint s; | ||
// Complete types are easy. They are complete before we get to the expression. | ||
s = sizeof(Complete); // This works! | ||
|
||
// A type may be incomplete for several reasons. | ||
|
||
// It may be incomplete because there is only a forward declaration, which | ||
// should produce an error since we can't materialize a definition. | ||
s = sizeof(Incomplete); // expected-error{{invalid application of 'sizeof' to an incomplete type 'Incomplete'}} | ||
|
||
// It may be incomplete because it is an un-instantiated template, which | ||
// should work because we can just instantiate it. | ||
s = sizeof(CompleteTemplate<int>); // This works! | ||
|
||
// It may be incomplete because it is a lazy-initialized type from HLSL, | ||
// which can be completed, and then will report a non-numeric type error. | ||
// expected-error@+1{{invalid application of 'sizeof' to non-numeric type 'Buffer'}} | ||
s = sizeof(Buffer); | ||
} |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.