[Ada] Improper behavior of floating-point attributes
authorEd Schonberg <schonberg@adacore.com>
Tue, 29 May 2018 09:42:05 +0000 (09:42 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 29 May 2018 09:42:05 +0000 (09:42 +0000)
commitef22a3b26940b059888ea409a53f5a91af44887d
tree05d1f19e7f5eb43fc4f1ec7e06934cd79cc17617
parent54e33e5f6a0f566e6b0e96da3d5f27449d807248
[Ada] Improper behavior of floating-point attributes

This patch fixes an error in the handling of attributes Pred qnd Succ when
applied to the limit values of a floating-point type. The RM mandates that
such operations must raise constraint_error, but GNAT generated in most cases
an infinite value, regardless of whether overflow checks were enabled.

2018-05-29  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* libgnat/s-fatgen.adb (Succ, Pred):  Raise Constraint_Error
unconditionally when applied to the largest positive (resp. largest
negative) value of a floating-point type.

gcc/testsuite/

* gnat.dg/float_attributes_overflows.adb: New testcase.

From-SVN: r260882
gcc/ada/ChangeLog
gcc/ada/libgnat/s-fatgen.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/float_attributes_overflows.adb [new file with mode: 0644]