]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix internal error on alignment clause for type declared in generic unit
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 10 Oct 2024 11:06:12 +0000 (13:06 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 4 Nov 2024 15:57:56 +0000 (16:57 +0100)
The front-end raises Program_Error on an alignment clause for a type in a
generic unit that references the alignment of another type in the unit.

gcc/ada/ChangeLog:

PR ada/117051
* freeze.adb (Freeze_Entity): Call the layout procedure on subtypes
declared in a generic unit when they are static.

gcc/ada/freeze.adb

index c7e3be028a7c090a8407b8c6058e4c541f8e2d38..9a862176c30a0aede1cdec61e05fd809f69c013f 100644 (file)
@@ -8022,9 +8022,11 @@ package body Freeze is
          --  generation, and so the size and alignment values for such types
          --  are irrelevant. Ditto for types declared within a generic unit,
          --  which may have components that depend on generic parameters, and
-         --  that will be recreated in an instance.
+         --  that will be recreated in an instance, except for static subtypes
+         --  because they may be referenced in the static expressions of the
+         --  generic unit, which need to be evaluated during its processing.
 
-         if Inside_A_Generic then
+         if Inside_A_Generic and then not Is_Static_Subtype (E) then
             null;
 
          --  Otherwise we call the layout procedure