]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Suppress warnings on derived True/False
authorBob Duff <duff@adacore.com>
Thu, 13 Oct 2022 20:51:08 +0000 (16:51 -0400)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 7 Nov 2022 08:36:33 +0000 (09:36 +0100)
commit981848b598c8a35a76c7fc226ac07852d9061f43
tree38beba3b6c053dd4791a3d9c306fe6a7073d62d3
parent214b1cb8a829568c7ef675b7c3e6a2d8b9a96875
ada: Suppress warnings on derived True/False

GNAT normally warns on "return ...;" if the "..." is known to be True or
False, but not when it is a Boolean literal True or False. This patch
also suppresses the warning when the type is derived from Boolean, and
has convention C or Fortran (and therefore True is represented as
"nonzero").

Without this fix, GNAT would give warnings like "False is always False".

gcc/ada/

* sem_warn.adb
(Check_For_Warnings): Remove unnecessary exception handler.
(Warn_On_Known_Condition): Suppress warning when we detect a True
or False that has been turned into a more complex expression
because True is represented as "nonzero". (Note that the complex
expression will subsequently be constant-folded to a Boolean True
or False). Also simplify to always print "condition is always ..."
instead of special-casing object names. The special case was
unhelpful, and indeed wrong when the expression is a literal.
gcc/ada/sem_warn.adb