From 970ee828e75fb3f67a7dc8dd8108e9a2f23b997b Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Wed, 31 May 2023 09:21:44 -0400 Subject: ada: Fix bug in predicate checks with address clauses This patch fixes a compiler bug triggered by having a type with some defaulted components, and a predicate, and an object of that type with an address clause. In this case, the compiler was crashing. gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Remove predicate-check generation if there is an address clause. These are unnecessary, and cause gigi to crash. * exp_util.ads (Following_Address_Clause): Remove obsolete "???" comments. The suggested changes were done long ago. --- gcc/ada/sem_ch3.adb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc/ada/sem_ch3.adb') diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index fb63690..85019df 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -4690,6 +4690,16 @@ package body Sem_Ch3 is elsif No (E) and then Is_Null_Record_Type (T) then null; + -- If there is an address clause for this object, do not generate a + -- predicate check here. It will be generated later, at the freezng + -- point. It would be wrong to generate references to the object + -- here, before the address has been determined. + + elsif Has_Aspect (Id, Aspect_Address) + or else Present (Following_Address_Clause (N)) + then + null; + -- Do not generate a predicate check if the initialization expression -- is a type conversion whose target subtype statically matches the -- object's subtype because the conversion has been subjected to the @@ -4709,7 +4719,6 @@ package body Sem_Ch3 is declare Check : constant Node_Id := Make_Predicate_Check (T, New_Occurrence_Of (Id, Loc)); - begin if No (Next_Decl) then Append_To (List_Containing (N), Check); -- cgit v1.1