avoid useless warning for 'bool <- restricted type' conversion
commita6aaa59cec44972513f1544eb4c2d389eadf14a6
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Thu, 11 May 2017 12:23:11 +0000 (11 14:23 +0200)
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Thu, 11 May 2017 20:11:20 +0000 (11 22:11 +0200)
treea30ea4333afbd60cc4daa0aa94c314f2313f1389
parente35efe330c6ae7d154197c29b127560d569016d0
avoid useless warning for 'bool <- restricted type' conversion

Conversion to bool is special in C since this conversion
is essentially the result of the comparison with zero.
As such, some operations which are normally unsafe to
do with restricted types, like casting to an unrestricted
type, are in fact safe to do when converting to bool
and issuing a warning in those case is useless, confusing
and causes people to add useless casts in the code in
order to shut up the warning.

Fix this by catching such 'bool <- restricted type' conversion
and avoid such warnings.

CC: Al Viro <viro@zeniv.linux.org.uk>
Originally-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
evaluate.c
validation/bool-cast-bad.c
validation/bool-cast-implicit.c
validation/bool-cast-restricted.c [new file with mode: 0644]