compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Misc. fixes and improvements for unused assignment detection

Open Daniel-Cortez opened this issue 4 years ago • 3 comments

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 goto is 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:

Daniel-Cortez avatar Sep 30 '21 14:09 Daniel-Cortez

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Jan 09 '22 02:01 stale[bot]

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 avatar Jun 07 '22 15:06 Y-Less

@Y-Less Thanks, I forgot to reset the "modified" flag when using #pragma unused/unread. This should be fixed now.

Daniel-Cortez avatar Jun 18 '22 17:06 Daniel-Cortez