From ea5a7a774a2d5d2759f45c77efa17a91182e614f Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 17 Feb 2023 18:01:52 +0100 Subject: ada: Fix bogus error on predicated limited record declared in protected type This happens when the limited record is initialized with a function call because of a couple of issues: incorrect tree sharing when building the predicate check and too late freezing for a compiler-generated subtype. It turns out that building the predicate check manually is redundant here, since predicate checks are automatically generated during the expansion of assignment statements, and the late freezing can be easily fixed. gcc/ada/ * exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do not manually generate a predicate check. Call Unqualify before doing pattern matching on the expression. * sem_ch3.adb (Analyze_Object_Declaration): Also freeze the actual subtype when it is built in the definite case. --- gcc/ada/sem_ch3.adb | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/ada/sem_ch3.adb') diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 2ebbe36..bace2cf 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -4971,6 +4971,7 @@ package body Sem_Ch3 is end if; Rewrite (Object_Definition (N), New_Occurrence_Of (Act_T, Loc)); + Freeze_Before (N, Act_T); elsif Nkind (E) = N_Function_Call and then Constant_Present (N) -- cgit v1.1