]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Propagate Ghost status from parent to derived subprograms
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 10 Sep 2021 20:27:20 +0000 (22:27 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 5 Oct 2021 08:20:02 +0000 (08:20 +0000)
gcc/ada/

* sem_ch3.adb (Derive_Subprogram): Copy ghost status from parent
to derived subprogram.

gcc/ada/sem_ch3.adb

index bf81f763faaed8474b75482f7a2be126c073d356..f1a56ad2b77350c5ea2376f56adb0cbdc4693e58 100644 (file)
@@ -16111,6 +16111,14 @@ package body Sem_Ch3 is
 
       Set_No_Return (New_Subp, No_Return (Parent_Subp));
 
+      --  If the parent subprogram is marked as Ghost, then so is the derived
+      --  subprogram. The ghost policy for the derived subprogram is set from
+      --  the effective ghost policy at the point of derived type declaration.
+
+      if Is_Ghost_Entity (Parent_Subp) then
+         Set_Is_Ghost_Entity (New_Subp);
+      end if;
+
       --  A derived function with a controlling result is abstract. If the
       --  Derived_Type is a nonabstract formal generic derived type, then
       --  inherited operations are not abstract: the required check is done at