[Ada] Propagate predicate function to a full view of a private subtype
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 13 Jul 2020 13:22:27 +0000 (15:22 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 20 Oct 2020 07:21:30 +0000 (03:21 -0400)
gcc/ada/

* sem_ch3.adb (Analyze_Subtype_Declaration): Propagate predicate
function to full view of the created type as well, if it was
created.

gcc/ada/sem_ch3.adb

index 8fe118b078eb128765063b9ea5e8fc655d8489ff..91e4ebb6e4196840eb538e93b969121106a00f5a 100644 (file)
@@ -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));