]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Representation clause for derived enumeration type is mishandled
authorEd Schonberg <schonberg@adacore.com>
Mon, 19 Aug 2019 08:35:40 +0000 (08:35 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 19 Aug 2019 08:35:40 +0000 (08:35 +0000)
commitd9ef7b974555fe62f3e93835720edde6ff889ac5
tree3eb2f1ffd416c81140e3d463688c9d510657cfbd
parentc811dd91e184db204073d04c28ed107888b39518
[Ada] Representation clause for derived enumeration type is mishandled

This patch fixes an old-standing problem with premature freezing. When a
derived type declaration includes a constraint, we generate a subtype
declaration of an anonymous base type, with the constraint given in the
original type declaration, Conceptually, the bounds are converted to the
new base type, and this conversion freezes (prematurely) that base type,
when the bounds are simply literals.  As a result, a representation
clause for the derived type is then rejected or ignared. This procedure
recognizes the simple case of literal bounds in derived enumeration type
declarations, which allows us to indicate that the conversions are not
freeze points, and the subsequent representation clause can be accepted.

2019-08-19  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* sem_ch3.adb (Derived_Enumeration_Type): Do no freeze anonymous
base type if the bounds in the derived type declaration are
literals of the type.

gcc/testsuite/

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

From-SVN: r274641
gcc/ada/ChangeLog
gcc/ada/sem_ch3.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/rep_clause9.adb [new file with mode: 0644]