From 95a7771da2c0d9ac1f78f25fed40caef4ea3ab56 Mon Sep 17 00:00:00 2001 From: Ronan Desplanques Date: Tue, 7 Nov 2023 08:50:03 +0100 Subject: ada: Restore object constraint optimization This patch relaxes the requirement that discriminants values should be known at compile time for a particular optimization to be applied. That optimization is the one that treats an unconstrained object as constrained when the object is of a limited type, in order to reduce the size of the object. What makes it possible to relax this requirement is that the set of cases where the optimization is applied was narrowed in a previous patch. gcc/ada/ * sem_util.adb (Build_Default_Subtype_OK): Relax known-at-compile-time requirement. * sem_util.ads (Build_Default_Subtype_OK): Bring documentation comment up-to-date. --- gcc/ada/sem_util.ads | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'gcc/ada/sem_util.ads') diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 081217a..2dc75a1 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -282,14 +282,13 @@ package Sem_Util is -- subtype. Otherwise, simply return T. function Build_Default_Subtype_OK (T : Entity_Id) return Boolean; - -- When analyzing components or object declarations, it is possible, in - -- some cases, to build subtypes for discriminated types. This is - -- worthwhile to avoid the backend allocating the maximum possible size for - -- objects of the type. + -- When analyzing object declarations, it is possible, in some cases, to + -- build subtypes for discriminated types. This is worthwhile to avoid the + -- backend allocating the maximum possible size for objects of the type. -- In particular, when T is limited, the discriminants and therefore the -- size of an object of type T cannot change. Furthermore, if T is definite - -- with statically initialized defaulted discriminants, we are able and - -- want to build a constrained subtype of the right size. + -- with initialized defaulted discriminants, we are able and want to build + -- a constrained subtype of the right size. function Build_Discriminal_Subtype_Of_Component (T : Entity_Id) return Node_Id; -- cgit v1.1