Skip to content
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

Misc. fixes and improvements for unused assignment detection #679

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

Daniel-Cortez
Copy link
Contributor

@Daniel-Cortez Daniel-Cortez commented Sep 30, 2021

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"
}

Which issue(s) this PR fixes:

Fixes #669

What kind of pull this is:

  • A Bug Fix
  • A New Feature
  • Some repository meta (documentation, etc)
  • Other

Additional Documentation:

…while loop, so the code inside the loop condition won't be mixed with the code inside the loop body
… on a label defined after the use, inside of the same loop

MCVE:
```
main()
{
    for (new x = 5; --x != 0;)
    {
        if (x == 2)
        {
            x = 1;
            goto lbl_cont;
        }
        x = 3; // false-positive warning 240
    lbl_cont:
    }
}
```
@Daniel-Cortez Daniel-Cortez requested a review from a team as a code owner September 30, 2021 14:52
@stale
Copy link

stale bot commented Jan 9, 2022

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

@stale stale bot added the state: stale label Jan 9, 2022
@Y-Less
Copy link
Member

Y-Less commented Jun 7, 2022

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.

@stale stale bot removed the state: stale label Jun 7, 2022
@Daniel-Cortez
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants