diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-04-09 18:03:58 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2021-04-13 18:25:43 +0200 |
| commit | d1ab4c40982ffcfadebf3155f498469aeb1355b0 (patch) | |
| tree | 3f1706a1471099852e748c2604970edde8955d04 /validation | |
| parent | 7a9fab6984f7bce3fd52809ecf6e21b79f115be3 (diff) | |
| download | sparse-dev-d1ab4c40982ffcfadebf3155f498469aeb1355b0.tar.gz | |
scheck: assert_eq()
Testing the equivalence of two sub-expressions can be done with
with a single assertion like __assert(A == B).
However, in some cases, Sparse can use the equality to simplify
the whole expression although it's unable to simplify one of
the two sub-expressions into the other.
So, add a new assertion, __assert_eq(), testing the equality of
the two expressions given in argument independently of each other.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/scheck/ok.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/validation/scheck/ok.c b/validation/scheck/ok.c index 113912e0..76c04c4f 100644 --- a/validation/scheck/ok.c +++ b/validation/scheck/ok.c @@ -3,6 +3,11 @@ static void ok(int x) __assert((~x) == (~0 - x)); // true but not simplified yet } +static void also_ok(int x) +{ + __assert_eq(~x, ~0 - x); +} + static void always(int x) { __assert((x - x) == 0); // true and simplified |
