From: Piotr Trojanek Date: Tue, 14 Oct 2025 14:15:46 +0000 (+0200) Subject: ada: Remove workaround for a freezing issue with address of a slice X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fbdaed53ea4a215325d4a6d33cdcf49e3df39a52;p=thirdparty%2Fgcc.git ada: Remove workaround for a freezing issue with address of a slice Rewriting of an address of a slice, e.g. "X (Low .. High)'Address" into an address of an indexed component, e.g. "X (Low)'Address", was only done as a workaround for some freezing issue. Apparently this freezing issue is now solved and the rewriting is causing problems for GNATprove. (This rewriting, if needed, should be rather done in expansion and not resolution.) gcc/ada/ChangeLog: * sem_attr.adb (Resolve_Attribute): Remove rewriting of a slice address expression. --- diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 88b7e765cf8..20270c20fe1 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -12493,70 +12493,6 @@ package body Sem_Attr is Set_Address_Taken (Entity (P)); end if; - if Nkind (P) = N_Slice then - - -- Arr (X .. Y)'address is identical to Arr (X)'address, - -- even if the array is packed and the slice itself is not - -- addressable. Transform the prefix into an indexed component. - - -- Note that the transformation is safe only if we know that - -- the slice is non-null. That is because a null slice can have - -- an out of bounds index value. - - -- Right now, gigi blows up if given 'Address on a slice as a - -- result of some incorrect freeze nodes generated by the front - -- end, and this covers up that bug in one case, but the bug is - -- likely still there in the cases not handled by this code ??? - - -- It's not clear what 'Address *should* return for a null - -- slice with out of bounds indexes, this might be worth an ARG - -- discussion ??? - - -- One approach would be to do a length check unconditionally, - -- and then do the transformation below unconditionally, but - -- analyze with checks off, avoiding the problem of the out of - -- bounds index. This approach would interpret the address of - -- an out of bounds null slice as being the address where the - -- array element would be if there was one, which is probably - -- as reasonable an interpretation as any ??? - - declare - Loc : constant Source_Ptr := Sloc (P); - D : constant Node_Id := Discrete_Range (P); - Lo : Node_Id; - - begin - if Is_Entity_Name (D) - and then - Not_Null_Range - (Type_Low_Bound (Entity (D)), - Type_High_Bound (Entity (D))) - then - Lo := - Make_Attribute_Reference (Loc, - Prefix => (New_Occurrence_Of (Entity (D), Loc)), - Attribute_Name => Name_First); - - elsif Nkind (D) = N_Range - and then Not_Null_Range (Low_Bound (D), High_Bound (D)) - then - Lo := Low_Bound (D); - - else - Lo := Empty; - end if; - - if Present (Lo) then - Rewrite (P, - Make_Indexed_Component (Loc, - Prefix => Relocate_Node (Prefix (P)), - Expressions => New_List (Lo))); - - Analyze_And_Resolve (P); - end if; - end; - end if; - ------------------ -- Body_Version -- ------------------