From: Steve Baird <ba...@adacore.com>

In some cases the compiler incorrectly concludes that a package body is
required for a package specification that includes the implicit declaration
of one or more inherited subprograms for an explicitly declared derived type.
Spurious error messages (e.g., "cannot generate code for file") may result.

gcc/ada/

        * sem_ch7.adb
        (Requires_Completion_In_Body): Modify the Comes_From_Source test so that
        the implicit declaration of an inherited subprogram does not cause
        an incorrect result of True.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch7.adb | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb
index 09d85bea335..0f0fc90ad6b 100644
--- a/gcc/ada/sem_ch7.adb
+++ b/gcc/ada/sem_ch7.adb
@@ -2827,13 +2827,14 @@ package body Sem_Ch7 is
       --  Otherwise test to see if entity requires a completion. Note that
       --  subprogram entities whose declaration does not come from source are
       --  ignored here on the basis that we assume the expander will provide an
-      --  implicit completion at some point.
+      --  implicit completion at some point. In particular, an inherited
+      --  subprogram of a derived type should not cause us to return True here.
 
       elsif (Is_Overloadable (Id)
               and then Ekind (Id) not in E_Enumeration_Literal | E_Operator
               and then not Is_Abstract_Subprogram (Id)
               and then not Has_Completion (Id)
-              and then Comes_From_Source (Parent (Id)))
+              and then Comes_From_Source (Id))
 
         or else
           (Ekind (Id) = E_Package
-- 
2.45.1

Reply via email to