]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/ada/checks.adb
[Ada] Enumeration types with non-standard representation
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Aug 2018 14:44:35 +0000 (14:44 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Aug 2018 14:44:35 +0000 (14:44 +0000)
commitcdfda0e30dd513bf1ae7d6f30362175633472f19
tree90b400fa0a8757343f0323e28a62e180ef2bd8dc
parent4fa679e5f613bb63a45da6e728d1cf2acd55af90
[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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263708 138bc75d-0d04-0410-961f-82ee72b054a4
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]