diff options
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r-- | gcc/ada/exp_ch6.adb | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 08e93c4..bbb7bde 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -1720,15 +1720,19 @@ package body Exp_Ch6 is -- this is harder to verify, and there may be a redundant check. -- Note also that Subp may be either a subprogram entity for - -- direct calls, or a type entity for indirect calls, hence the - -- test that Is_Overloadable returns True before testing whether - -- Subp is an inherited operation. + -- direct calls, or a type entity for indirect calls, which must + -- be handled separately because the name does not denote an + -- overloadable entity. - if (Present (Find_Aspect (E_Actual, Aspect_Predicate)) + -- If the formal is class-wide the corresponding postcondition + -- procedure does not include a predicate call, so it has to be + -- generated explicitly. + + if (Has_Aspect (E_Actual, Aspect_Predicate) or else - Present (Find_Aspect (E_Actual, Aspect_Dynamic_Predicate)) + Has_Aspect (E_Actual, Aspect_Dynamic_Predicate) or else - Present (Find_Aspect (E_Actual, Aspect_Static_Predicate))) + Has_Aspect (E_Actual, Aspect_Static_Predicate)) and then not Is_Init_Proc (Subp) then if (Is_Derived_Type (E_Actual) @@ -1738,6 +1742,12 @@ package body Exp_Ch6 is then Append_To (Post_Call, Make_Predicate_Check (E_Actual, Actual)); + + elsif Is_Class_Wide_Type (E_Formal) + and then not Is_Class_Wide_Type (E_Actual) + then + Append_To + (Post_Call, Make_Predicate_Check (E_Actual, Actual)); end if; end if; |