[Ada] Fix missing Constraint_Error for Enum_Val attribute
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 22 Jul 2019 13:57:04 +0000 (13:57 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 22 Jul 2019 13:57:04 +0000 (13:57 +0000)
commitfd90c808628cead705bb4521d9b8beea0edcf2bf
treef8e4700d32a319c8b8d65fa46b4b2173abe99297
parent7ddc639b7717278075ab1989568d1769ccc040e1
[Ada] Fix missing Constraint_Error for Enum_Val attribute

This fixes an old issue involving the Enum_Val attribute: it does not
always raise a Constraint_Error exception when the specified value is
not valid for the enumeration type (instead a modulo computation is
applied to the value).

2019-07-22  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_attr.adb (Expand_N_Attribute_Reference)
<Attribute_Enum_Val>: Set No_Truncation on the
N_Unchecked_Type_Conversion built around the argument passed to
the attribute.

gcc/testsuite/

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

From-SVN: r273676
gcc/ada/ChangeLog
gcc/ada/exp_attr.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/enum_val1.adb [new file with mode: 0644]