-
Notifications
You must be signed in to change notification settings - Fork 48
Generalize WNEGCONSTCOMP to warn for all constants outside a type's range #304
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
Open
mandolaerik
wants to merge
1
commit into
intel:main
Choose a base branch
from
mandolaerik:pr/generalize-wnegconstcomp-to-warn-for-all-constants-outside-a-type-s-range
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
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 was deleted.
Oops, something went wrong.
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,98 @@ | ||
/* | ||
© 2021 Intel Corporation | ||
SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
dml 1.4; | ||
|
||
device test; | ||
|
||
param inf = 1.0/+0.0; | ||
param nan = inf/inf; | ||
|
||
method init() { | ||
local uint64 a = -1; | ||
// Test all operands | ||
/// WARNING WTYPELIMITS | ||
assert a != -1; | ||
/// WARNING WTYPELIMITS | ||
assert -1 != a; | ||
/// WARNING WTYPELIMITS | ||
assert !(-1 == a); | ||
/// WARNING WTYPELIMITS | ||
assert a > -1; | ||
/// WARNING WTYPELIMITS | ||
assert !(a < -1); | ||
/// WARNING WTYPELIMITS | ||
assert a >= -1; | ||
/// WARNING WTYPELIMITS | ||
assert !(a <= -1); | ||
|
||
// Upper and lower bounds are tight, regardless if the constant is on RH or | ||
// LH side | ||
local uint8 a8 = -1; | ||
/// WARNING WTYPELIMITS | ||
assert a8 != -1; | ||
/// WARNING WTYPELIMITS | ||
assert -1 != a8; | ||
// no warning | ||
assert a8 != 0; | ||
assert 0 != a8; | ||
/// WARNING WTYPELIMITS | ||
assert a8 != 256; | ||
/// WARNING WTYPELIMITS | ||
assert 256 != a8; | ||
// no warning | ||
assert a8 == 255; | ||
assert 255 == a8; | ||
/// WARNING WTYPELIMITS | ||
assert a8 >= 0; | ||
/// WARNING WTYPELIMITS | ||
assert 0 <= a8; | ||
/// no warning | ||
assert a8 > 0; | ||
assert 0 < a8; | ||
/// WARNING WTYPELIMITS | ||
assert !(a8 > 255); | ||
/// WARNING WTYPELIMITS | ||
assert !(255 < a8); | ||
/// no warning | ||
assert a8 >= 255; | ||
assert 255 <= a8; | ||
|
||
// Limits for signed integers are tight | ||
local int8 i8 = 128; | ||
/// WARNING WTYPELIMITS | ||
assert i8 != 128; | ||
// no warning | ||
assert i8 != 127; | ||
/// WARNING WTYPELIMITS | ||
assert i8 != -129; | ||
// no warning | ||
assert i8 == -128; | ||
|
||
// Non-integer float constants also give warnings | ||
/// WARNING WTYPELIMITS | ||
assert i8 != 0.1; | ||
/// WARNING WTYPELIMITS | ||
assert 0.1 != i8; | ||
// no warning | ||
assert i8 != 0.0; | ||
assert 0.0 != i8; | ||
|
||
// Sanity | ||
local int64 b = -1; | ||
// No warning | ||
assert b == -1; | ||
// No warning | ||
assert !(b < -1); | ||
// No warnings for inf and nan, as they aren't considered constant by DML | ||
assert a < inf; | ||
assert a > -inf; | ||
assert a != -inf; | ||
assert !(a < nan); | ||
assert !(a > nan); | ||
assert a != nan; | ||
|
||
// Test workaround | ||
assert a == cast(-1, uint64); | ||
} |
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.