Bug 48779 - -Wunused-but-set-variable does not report unread unit-static variables
Summary: -Wunused-but-set-variable does not report unread unit-static variables
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.6.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: Wunused
  Show dependency treegraph
 
Reported: 2011-04-26 20:47 UTC by Diego Elio Pettenò
Modified: 2019-02-03 22:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-07-23 22:40:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Elio Pettenò 2011-04-26 20:47:38 UTC
I know this is likely cumbersome to support as a case, as it requires to look at all the functions in the given unit to report it, but since GCC already reports unused functions in the unit I guess it is feasible.

Simple test case:

static unsigned int done = 0;

int main() {
  done = 1;

  return 0;
}

The warning works fine if done is function-static though.

Thanks,
Diego
Comment 1 Andrew Pinski 2011-07-23 22:40:07 UTC
To do this warning, we need an IPA pass which goes through all static referenced variables and see if they are only written to.