2009-04-20 Ed Schonberg <schonberg@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Apr 2009 13:11:19 +0000 (13:11 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 20 Apr 2009 13:11:19 +0000 (13:11 +0000)
* exp_util.adb (Expand_Subtype_From_Expr): use the
underlying_record_view when available, to create the proper constrained
subtype for an object of a derived type with unknown discriminants.

2009-04-20  Javier Miranda  <miranda@adacore.com>

* exp_ch6.ad (Expand_Inlined_Call): Avoid generation of temporaries for
formals that have pragma unreferenced.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146414 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/exp_util.adb

index 28c42da..65cd4e8 100644 (file)
@@ -1,3 +1,14 @@
+2009-04-20  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_util.adb (Expand_Subtype_From_Expr): use the
+       underlying_record_view when available, to create the proper constrained
+       subtype for an object of a derived type with unknown discriminants.
+
+2009-04-20  Javier Miranda  <miranda@adacore.com>
+
+       * exp_ch6.adb (Expand_Inlined_Call): Avoid generation of temporaries for
+       formals that have pragma unreferenced.
+
 2009-04-20  Pascal Obry  <obry@adacore.com>
 
        * a-direct.adb (To_Lower_If_Case_Insensitive): Removed.
index 82311e1..989dc1a 100644 (file)
@@ -3670,6 +3670,16 @@ package body Exp_Ch6 is
             return;
          end if;
 
+         --  Avoid generation of temporaries for unreferenced formals
+
+         --  What is going on here ??? test below is for *PRAGMA* unreferenced
+         --  not for an unreferenced formal. Is this a bug fix, or simply an
+         --  optimization. Needs comment fix and explanation ???
+
+         if Has_Pragma_Unreferenced (F) then
+            goto Continue;
+         end if;
+
          --  If the argument may be a controlling argument in a call within
          --  the inlined body, we must preserve its classwide nature to insure
          --  that dynamic dispatching take place subsequently. If the formal
@@ -3790,6 +3800,7 @@ package body Exp_Ch6 is
             Set_Renamed_Object (F, Temp);
          end if;
 
+         <<Continue>>
          Next_Formal (F);
          Next_Actual (A);
       end loop;
index 8205735..8e54797 100644 (file)
@@ -1328,15 +1328,28 @@ package body Exp_Util is
       then
          null;
 
-      --  Nothing to be done for derived types with unknown discriminants if
-      --  the parent type also has unknown discriminants.
+      --  Case of derived type with unknown discriminants where the parent type
+      --  also has unknown discriminants.
 
       elsif Is_Record_Type (Unc_Type)
         and then not Is_Class_Wide_Type (Unc_Type)
         and then Has_Unknown_Discriminants (Unc_Type)
         and then Has_Unknown_Discriminants (Underlying_Type (Unc_Type))
       then
-         null;
+         --  Nothing to be done if no underlying record view available
+
+         if No (Underlying_Record_View (Unc_Type)) then
+            null;
+
+         --  Otherwise use the Underlying_Record_View to create the proper
+         --  constrained subtype for an object of a derived type with unknown
+         --  discriminants.
+
+         else
+            Remove_Side_Effects (Exp);
+            Rewrite (Subtype_Indic,
+              Make_Subtype_From_Expr (Exp, Underlying_Record_View (Unc_Type)));
+         end if;
 
       --  In Ada95, Nothing to be done if the type of the expression is
       --  limited, because in this case the expression cannot be copied,