Misc. fixes and improvements for unused assignment detection
What this PR does / why we need it:
This PR does the following:
- Introduces warning 252 for operators
++,--, and compound assignment operators (+=,-=,*=etc,)
Func(arg) {
return arg++; // warning 252: variable has its value modified but never used: "arg"
}
- Fixes warning 240 false-positives when
gotois used inside of a loop, on a label defined after the use, inside of the same loop (see https://github.com/pawn-lang/compiler/issues/669#issuecomment-895317894). - Makes the compiler print warning 240 on the line of the current assignment instead of the previous one (see https://github.com/pawn-lang/compiler/issues/669#issuecomment-895835974).
Which issue(s) this PR fixes:
Fixes #669
What kind of pull this is:
- [x] A Bug Fix
- [x] A New Feature
- [ ] Some repository meta (documentation, etc)
- [ ] Other
Additional Documentation:
This issue has been automatically marked as stale because it has not had recent activity.
It would be good if #pragma unused x could suppress this warning as well:
REMOTE_FUNC__ static void:yrt_7(&a, &b, c, &d)
{
//print("yrt_7 called");
a = 8;
b = a;
c += d;
d -= 4;
#pragma unused c
}
I get a warning on the c here (which is a correct warning), but the #pragma doesn't silence it. I'm actually testing that the value isn't propagated, so can't remove the assignment.
@Y-Less Thanks, I forgot to reset the "modified" flag when using #pragma unused/unread. This should be fixed now.