Underlying_Type now recursively goes down the chain of private derivations,
including the Underlying_Full_View if any, so we call it instead of making
the descent manually in Build_Initialization_Call.  No functional changes.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-08-01  Eric Botcazou  <ebotca...@adacore.com>

        * exp_ch3.adb (Build_Initialization_Call): Call Underlying_Type
        to go down the chain of private derivations.
        * freeze.adb (Freeze_Entity): Fix typo in comment.

Index: freeze.adb
===================================================================
--- freeze.adb  (revision 213463)
+++ freeze.adb  (working copy)
@@ -5034,7 +5034,7 @@
                --  Otherwise freeze full view and patch the pointers so that
                --  the freeze node will elaborate both views in the back end.
                --  However, if full view is itself private, freeze underlying
-               --  full view instead and patch the pointer so that the freeze
+               --  full view instead and patch the pointers so that the freeze
                --  node will elaborate the three views in the back end.
 
                else
Index: exp_ch3.adb
===================================================================
--- exp_ch3.adb (revision 213439)
+++ exp_ch3.adb (working copy)
@@ -1491,15 +1491,21 @@
          return Empty_List;
       end if;
 
-      --  Go to full view if private type. In the case of successive
-      --  private derivations, this can require more than one step.
+      --  Go to full view or underlying full view if private type. In the case
+      --  of successive private derivations, this can require two steps.
 
-      while Is_Private_Type (Full_Type)
+      if Is_Private_Type (Full_Type)
         and then Present (Full_View (Full_Type))
-      loop
+      then
          Full_Type := Full_View (Full_Type);
-      end loop;
+      end if;
 
+      if Is_Private_Type (Full_Type)
+        and then Present (Underlying_Full_View (Full_Type))
+      then
+         Full_Type := Underlying_Full_View (Full_Type);
+      end if;
+
       --  If Typ is derived, the procedure is the initialization procedure for
       --  the root type. Wrap the argument in an conversion to make it type
       --  honest. Actually it isn't quite type honest, because there can be
@@ -1583,12 +1589,6 @@
             begin
                if Is_Protected_Type (T) then
                   T := Corresponding_Record_Type (T);
-
-               elsif Is_Private_Type (T)
-                 and then Present (Underlying_Full_View (T))
-                 and then Is_Protected_Type (Underlying_Full_View (T))
-               then
-                  T := Corresponding_Record_Type (Underlying_Full_View (T));
                end if;
 
                Arg :=

Reply via email to