]> gcc.gnu.org Git - gcc.git/commit
ada: Incorrect optimization for unconstrained limited record component type
authorSteve Baird <baird@adacore.com>
Thu, 8 Jun 2023 21:59:32 +0000 (14:59 -0700)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 1 Aug 2023 08:06:45 +0000 (10:06 +0200)
commit04c297101019316eb8c3191ffb2ff0bf34f4d869
treecea96f70d19cb28f92e07bb4787ea75daa250b91
parent46640bafbbe69fbd6960b21ed5a8ed635f99afa5
ada: Incorrect optimization for unconstrained limited record component type

If the discriminants of an immutably limited record type have defaults, then
it is safe to assume that a discriminant of an object of this type will never
change once it is initialized. In some cases, this means that the default
discriminant values can be treated like a constraint for purposes of
determining the amount of storage needed for an unconstrained object.
However, it is not safe to perform this optimization when determining
the size needed for an unconstrained component of an enclosing type. This
optimization was sometimes being incorrectly performed in this case. This could
save storage in some cases, but in other cases a constraint check could
incorrectly fail when initializing a component of an aggregate if the
discriminant values of the component differ from the default values.

gcc/ada/

* sem_ch3.adb (Analyze_Component_Declaration): Remove
Build_Default_Subtype_OK call and code that could only executed in
the case where the removed call would have returned True. Other
calls to Build_Default_Subtype_Ok are unaffected by this change.
gcc/ada/sem_ch3.adb
This page took 0.062276 seconds and 6 git commands to generate.