From 45656a992eb18bfefe2e6e20d3b425afe945af28 Mon Sep 17 00:00:00 2001 From: Ronan Desplanques Date: Mon, 24 Oct 2022 11:50:06 +0200 Subject: ada: Adjust classwide contract expression preanalysis Before this patch, a classwide contract expression was preanalyzed only when its primitive operation's type was frozen. It caused name resolution to be off in the cases where the freezing took place after the end of the declaration list the primitive operation was declared in. This patch makes it so that if the compiler gets to the end of the declaration list before the type is frozen, it preanalyzes the classwide contract expression, so that the names are resolved in the right context. gcc/ada/ * contracts.adb (Preanalyze_Class_Conditions): New procedure. (Preanalyze_Condition): Moved out from Merge_Class_Conditions in order to be spec-visible. * contracts.ads (Preanalyze_Class_Conditions): New procedure. * sem_prag.adb (Analyze_Pre_Post_Condition_In_Decl_Part): Call Preanalyze_Class_Conditions when necessary. --- gcc/ada/contracts.ads | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/ada/contracts.ads') diff --git a/gcc/ada/contracts.ads b/gcc/ada/contracts.ads index bde32ffc5b4..ae6355ef410 100644 --- a/gcc/ada/contracts.ads +++ b/gcc/ada/contracts.ads @@ -276,6 +276,10 @@ package Contracts is -- which are invoked from the caller side; they are also used to build -- the dispatch-table wrapper (DTW), if required. + procedure Preanalyze_Class_Conditions (Spec_Id : Entity_Id); + -- Preanalyze class-wide pre-/postconditions of the given subprogram + -- specification. + procedure Process_Class_Conditions_At_Freeze_Point (Typ : Entity_Id); -- Merge, preanalyze, and check class-wide pre/postconditions of Typ -- primitives. -- cgit v1.2.1