-
Notifications
You must be signed in to change notification settings - Fork 77
[MERGED] Further improvements for detection of unused assignments #533
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
Closed
Conversation
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 fixes `continue` and `break` not calling destructors properly in some situations.
…ED' flag when error messages are being silenced
…ctsymbols()` This fixes the problem with the same assignments being reported repeatedly if the function has multiple `return` statements.
…nt' nesting level for assignments
…side `if` and `switch` statements
…`while` and `for` statements Now unused previous assignments (warning 240) are detected by their "compound statement" nesting level.
… function arguments
…for" loops We already temporarily increase `pc_nestlevel` before the whole loop (to store the assignments on a separate compound level), so we don't need to do it again.
… end with the same kind of statement
…se" branch Previously we had to clear all assignments in the "true" branch if the "false" one was present, so the compiler won't report assignments in the "true" branch as unused if the "false" branch also contains assignments to the same variables.
…return` and `exit` This fixes a bug with assignments being falsely reported as unused after `return` or `exit`. Example: ``` ReturnValue(&arg) { if (/* ... */) { arg = 1; return; } arg = 2; // previous assignment "arg = 1" was falsely reported as unused on this line } ```
… `memoizeassignments()` and `restoreassignments()`
Fixed a bug with false positive warnings 204 and 240 printed with random (garbage) line numbers, e.g.:
The reason of this problem was the bug with local constants which broke the code in |
4 tasks
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.
What this PR does / why we need it:
This PR continues the work regarding detection of unused assignments (warnings 204 and 240), the first part of which was done in #480.
break
orcontinue
.Which issue(s) this PR fixes:
Fixes #479
What kind of pull this is:
Additional Documentation:
This PR relies on the fix from #532, so you'll probably want to review and merge that PR first.