From: Steve Baird Date: Mon, 21 Apr 2025 18:57:30 +0000 (-0700) Subject: ada: Fix Itype-related predicate check omissions (part 2). X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74a7c286be8259bd645fad68cbb356cad18403d8;p=thirdparty%2Fgcc.git ada: Fix Itype-related predicate check omissions (part 2). Add to the previous fix for this issue to better handle cases where GNATProve calls Einfo.Utils.Predicate_Function, passing in an Itype. gcc/ada/ChangeLog: * einfo-utils.adb (Predicate_Function): Look through an Itype if that takes us to another subtype of the same type. --- diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 60ee509da67..417da6e828b 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -2345,6 +2345,25 @@ package body Einfo.Utils is begin pragma Assert (Is_Type (Id)); + if Nkind (Associated_Node_For_Itype (Id)) = N_Subtype_Declaration then + declare + Associated_Id : constant Entity_Id := + Defining_Identifier (Associated_Node_For_Itype (Id)); + begin + -- Avoid Itype/predicate problems by looking through Itypes. + -- We never introduce new predicates for Itypes, so doing this + -- will never cause us to incorrectly overlook a predicate. + -- It is not clear whether the FE needs this fix, but + -- GNATProve does (note that GNATProve calls Predicate_Function). + + if Id /= Associated_Id + and then Base_Type (Id) = Base_Type (Associated_Id) + then + return Predicate_Function (Associated_Id); + end if; + end; + end if; + -- If type is private and has a completion, predicate may be defined on -- the full view.