[Ada] Enumeration types with non-standard representation
authorJavier Miranda <miranda@adacore.com>
Tue, 21 Aug 2018 14:44:35 +0000 (14:44 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 21 Aug 2018 14:44:35 +0000 (14:44 +0000)
commitf20b5ef46d7338e626286721a74e3fd3385e8be0
tree90b400fa0a8757343f0323e28a62e180ef2bd8dc
parentb7e875ce96282a9c4ecc6cfd4f043c1039e5b7e3
[Ada] Enumeration types with non-standard representation

The compiler may report errors on enumeration types with non-standard
representation (i.e. at least one literal has a representation value
different from its 'Pos value) processing attribute 'Enum_Rep.

It may also generate wrong code for the evaluation of 'Enum_Rep raising
Constraint_Error at runtime.

2018-08-21  Javier Miranda  <miranda@adacore.com>

gcc/ada/

* checks.ads (Determine_Range): Adding documentation.
* checks.adb (Determine_Range): Don't deal with enumerated types
with non-standard representation.
(Convert_And_Check_Range): For conversion of enumeration types
with non standard representation to an integer type perform a
direct conversion to the target integer type.

gcc/testsuite/

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

From-SVN: r263708
gcc/ada/ChangeLog
gcc/ada/checks.adb
gcc/ada/checks.ads
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/enum4.adb [new file with mode: 0644]