This patch fixes a bug where if we have "subtype S is T with Predicate
=> ...", and T is a private type whose full type is derived from another
private type, then the predicate of S is not checked.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch13.adb (Analyze_Aspect_Specifications): Add freeze node
for the Underlying_Full_View if it exists. The freeze node is
what triggers the generation of the predicate function.
* freeze.adb: Minor reformatting.
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -6175,8 +6175,7 @@ package body Freeze is
if Present (F_Node) then
Inherit_Freeze_Node
- (Fnod => F_Node,
- Typ => Full_View (E));
+ (Fnod => F_Node, Typ => Full_View (E));
else
Set_Has_Delayed_Freeze (Full_View (E), False);
Set_Freeze_Node (Full_View (E), Empty);
@@ -6187,9 +6186,7 @@ package body Freeze is
F_Node := Freeze_Node (Full_View (E));
if Present (F_Node) then
- Inherit_Freeze_Node
- (Fnod => F_Node,
- Typ => E);
+ Inherit_Freeze_Node (Fnod => F_Node, Typ => E);
else
-- {Incomplete,Private}_Subtypes with Full_Views
-- constrained by discriminants.
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -3051,6 +3051,21 @@ package body Sem_Ch13 is
Set_Has_Delayed_Aspects (Full_View (E));
Ensure_Freeze_Node (Full_View (E));
+
+ -- If there is an Underlying_Full_View, also create a
+ -- freeze node for that one.
+
+ if Is_Private_Type (Full_View (E)) then
+ declare
+ U_Full : constant Entity_Id :=
+ Underlying_Full_View (Full_View (E));
+ begin
+ if Present (U_Full) then
+ Set_Has_Delayed_Aspects (U_Full);
+ Ensure_Freeze_Node (U_Full);
+ end if;
+ end;
+ end if;
end if;
-- Predicate_Failure