diff mbox series

[COMMITTED,11/38] ada: Fix internal error on alignment clause for type declared in generic unit

Message ID 20241104161116.1431659-11-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/38] ada: Fix asymmetry in resolution of unary intrinsic operators | expand

Commit Message

Marc Poulhiès Nov. 4, 2024, 4:10 p.m. UTC
From: Eric Botcazou <ebotcazou@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/freeze.adb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index c7e3be028a7..9a862176c30 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -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