When the ancestor in subtype declaration is a private type, routine
Analyze_Subtype_Declaration creates private and full view, but only
the private view had Predicate_Function inherited from the ancestor.

Now also the full view has Predicate_Function inherited. This doesn't
appear to affect compilation, but fixes a crash in GNATprove, which
expects Predicate_Function to be set on both views.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * sem_ch3.adb (Analyze_Subtype_Declaration): Propagate predicate
        function to full view of the created type as well, if it was
        created.
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -5713,6 +5713,16 @@ package body Sem_Ch3 is
       then
          Set_Subprograms_For_Type (Id, Subprograms_For_Type (T));
 
+         --  If the current declaration created both a private and a full view,
+         --  then propagate Predicate_Function to the latter as well.
+
+         if Present (Full_View (Id))
+           and then No (Predicate_Function (Full_View (Id)))
+         then
+            Set_Subprograms_For_Type
+              (Full_View (Id), Subprograms_For_Type (Id));
+         end if;
+
          if Has_Static_Predicate (T) then
             Set_Has_Static_Predicate (Id);
             Set_Static_Discrete_Predicate (Id, Static_Discrete_Predicate (T));


Reply via email to