When calling routine Add_Call, which extends the type predicate function
with a call to its ancestor's type predicate function, we checked that
the ancestor type is present twice: in the Add_Call itself and at its
only call site.
Also, when the ancestor type has a predicate function, this routine was
setting Has_Predicates flag on the derived type. However, this flag is
already propagated as part of the type derivation. Setting it while
building the predicate function was redundant (and felt to be done much
too late).
Code cleanup only.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch13.adb (Add_Call): Remove excessive condition and
unnecessary call to Set_Has_Predicates.
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -9583,8 +9583,8 @@ package body Sem_Ch13 is
-- Predicate_Function of the parent type, using Add_Call above.
procedure Add_Call (T : Entity_Id);
- -- Includes a call to the predicate function for type T in Expr if T
- -- has predicates and Predicate_Function (T) is non-empty.
+ -- Includes a call to the predicate function for type T in Expr if
+ -- Predicate_Function (T) is non-empty.
function Process_RE (N : Node_Id) return Traverse_Result;
-- Used in Process REs, tests if node N is a raise expression, and if
@@ -9608,8 +9608,8 @@ package body Sem_Ch13 is
Exp : Node_Id;
begin
- if Present (T) and then Present (Predicate_Function (T)) then
- Set_Has_Predicates (Typ);
+ if Present (Predicate_Function (T)) then
+ pragma Assert (Has_Predicates (Typ));
-- Build the call to the predicate function of T. The type may be
-- derived, so use an unchecked conversion for the actual.