-
Notifications
You must be signed in to change notification settings - Fork 72
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
Diagnostics for detection of endless loops #634
Conversation
…store multiple symbol usage flags
I don't follow why that needs two warnings. The second warning covers the first case as well, so only 251 is needed. |
Could I also suggest a test for the case where one loop variable is passed by reference to a function? I know there's no way to determine if that function actually modifies it, but it would just be nice to confirm that the warning isn't given in that case. |
The first one tells which variable exactly needs to be modified. Even when there's only one variable used inside the loop condition, I think it would be more convenient to have that variable pointed at right away than having to inspect the code every time to determine which variable it is. Simply removing warning 250 would mean sacrificing the said convenience. Another option would be to merge both warnings into one, but they are two completely different messages. I mean, I could do something like this: /*250*/ "%s modified in loop body" so warning 250 could be both "
Done. |
Another thing worth mentioning is that warnings 250 and 251 don't work on |
f827d9d
to
a16b351
Compare
The new diagnostics seem to work on |
…e a loop condition
…uments don't conflict with the new warnings
e3f5f76
to
64b2cda
Compare
Amended and force-pushed some of the commits; the changes are the following:
|
What this PR does / why we need it:
This PR implements new diagnostics for detection of endless loops:
Helps to detects the cases when the user forgot to modify the loop counter variable.
The same as the previous diagnostic, but works when multiple variables are used inside a loop condition and none of them gets modified.
For the compiler there's no reasonable way to know which variable should be modified and which shouldn't, which is why I had to create a distinct warning for such situations.
Which issue(s) this PR fixes:
Fixes #
What kind of pull this is:
Additional Documentation: