analyzer: fix sense in range::add_bound [PR94362]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 25 Jan 2022 16:35:24 +0000 (11:35 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 26 Jan 2022 14:41:58 +0000 (09:41 -0500)
commite966a508e03fe28bfca65a1e60e579fa90355ea6
treeeee404ca818d8d841e878e152b3719f636904a4e
parent192e4a9fa0880ef153631d5b0de864bc4bbb6a91
analyzer: fix sense in range::add_bound [PR94362]

Mikael Morin spotted that I got the sense wrong when discarding
redundant constraints in
r12-6782-gc4b8f3730a80025192fdb485ad2535c165340e41.

Fixed as follows, which also moves the rejection of contradictory
constraints in range::add_bound to earlier, so that this code can
be self-tested.

gcc/analyzer/ChangeLog:
PR analyzer/94362
* constraint-manager.cc (range::add_bound): Fix tests for
discarding redundant constraints.  Perform test for rejecting
unsatisfiable constraints earlier so that they don't update
the object on failure.
(selftest::test_range): New.
(selftest::test_constant_comparisons): Add test coverage for
existing constraints becoming narrower until they are
unsatisfiable.
(selftest::run_constraint_manager_tests): Call test_range.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/constraint-manager.cc