]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
exp_ch9.adb (Actual_Index_Expression): When the expansion occurs inside a generic...
authorHristian Kirtchev <kirtchev@adacore.com>
Mon, 15 Oct 2007 13:54:57 +0000 (15:54 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 15 Oct 2007 13:54:57 +0000 (15:54 +0200)
2007-10-15  Hristian Kirtchev  <kirtchev@adacore.com>

* exp_ch9.adb (Actual_Index_Expression): When the expansion occurs
inside a generic body, retrieve the full view of the entry family
discrete subtype if available.

From-SVN: r129324

gcc/ada/exp_ch9.adb

index 8874f8d18de7df860a206e3604a72fffe41e4554..87fbc1282a0e357752da53a1673166774aa7c186 100644 (file)
@@ -511,6 +511,53 @@ package body Exp_Ch9 is
          elsif Ekind (Prev) = E_Entry_Family then
             S :=
               Etype (Discrete_Subtype_Definition (Declaration_Node (Prev)));
+
+            --  The need for the following full view retrieval stems from
+            --  this complex case of nested generics and tasking:
+
+            --     generic
+            --        type Formal_Index is range <>;
+            --        ...
+            --     package Outer is
+            --        type Index is private;
+            --        generic
+            --           ...
+            --        package Inner is
+            --           procedure P;
+            --        end Inner;
+            --     private
+            --        type Index is new Formal_Index range 1 .. 10;
+            --     end Outer;
+
+            --     package body Outer is
+            --        task type T is
+            --           entry Fam (Index);  --  (2)
+            --           entry E;
+            --        end T;
+            --        package body Inner is  --  (3)
+            --           procedure P is
+            --           begin
+            --              T.E;             --  (1)
+            --           end P;
+            --       end Inner;
+            --       ...
+
+            --  We are currently building the index expression for the entry
+            --  call "T.E" (1). Part of the expansion must mention the range
+            --  of the discrete type "Index" (2) of entry family "Fam".
+            --  However only the private view of type "Index" is available to
+            --  the inner generic (3) because there was no prior mention of
+            --  the type inside "Inner". This visibility requirement is
+            --  implicit and cannot be detected during the construction of
+            --  the generic trees and needs special handling.
+
+            if In_Instance_Body
+              and then Is_Private_Type (S)
+              and then Present (Full_View (S))
+            then
+               S := Full_View (S);
+            end if;
+
             Lo := Type_Low_Bound  (S);
             Hi := Type_High_Bound (S);