analyzer: getchar has no side-effects
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 16 Sep 2020 17:12:39 +0000 (13:12 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 16 Sep 2020 22:56:50 +0000 (18:56 -0400)
commite097c9ab83192fc2f738ec6426a275282e9a51ea
treef50440aa428bda9f922ee6871aec460eb9043031
parent3f4b15f52f4d5f202a7f27bdbb41a8fff218d323
analyzer: getchar has no side-effects

Seen whilst debugging another issue, where the analyzer was assuming
conservatively that a call to getchar could clobber a global.

This is handled for most of the other stdio functions by the list
in sm-file.cc

gcc/analyzer/ChangeLog:
* region-model.cc (region_model::on_call_pre): Treat getchar as
having no side-effects.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/getchar-1.c: New test.
gcc/analyzer/region-model.cc
gcc/testsuite/gcc.dg/analyzer/getchar-1.c [new file with mode: 0644]