analyzer: fix ICE on unary ops folding to casts of constants [PR104089]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 18 Jan 2022 16:41:19 +0000 (11:41 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 18 Jan 2022 20:56:23 +0000 (15:56 -0500)
commit2aefe248aa4160205c44808166393a42031d2dea
treec1ea9883541d783710f786487dcabe1370bf18ef
parent79e746bb05e432dcd1c18161469272d67c33d79d
analyzer: fix ICE on unary ops folding to casts of constants [PR104089]

gcc/analyzer/ChangeLog:
PR analyzer/104089
* region-model-manager.cc
(region_model_manager::get_or_create_constant_svalue): Assert that
we have a CONSTANT_CLASS_P.
(region_model_manager::maybe_fold_unaryop): Only fold a constant
when fold_unary's result is a constant or a cast of a constant.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/pr104089.c: New test.
PR analyzer/104089

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/region-model-manager.cc
gcc/testsuite/gcc.dg/analyzer/pr104089.c [new file with mode: 0644]