OSDN Git Service

* stor-layout.c (initialize_sizetypes): Set SIZETYPE earlier,
[pf3gnuchains/gcc-fork.git] / gcc / ada / exp_ch2.adb
index bc8c2ff..130d74d 100644 (file)
@@ -41,6 +41,7 @@ with Sem_Res;  use Sem_Res;
 with Sem_Util; use Sem_Util;
 with Sem_Warn; use Sem_Warn;
 with Sinfo;    use Sinfo;
+with Snames;   use Snames;
 with Stand;    use Stand;
 with Tbuild;   use Tbuild;
 with Uintp;    use Uintp;
@@ -55,9 +56,9 @@ package body Exp_Ch2 is
    --  Given a node N for a variable whose Current_Value field is set.
    --  If the node is for a discrete type, replaces the node with a
    --  copy of the referenced value. This provides a limited form of
-   --  value propagation for variables which are initialized and have
-   --  not been modified at the time of reference. The call has no
-   --  effect if the Current_Value refers to a conditional with a
+   --  value propagation for variables which are initialized or assigned
+   --  not been further modified at the time of reference. The call has
+   --  no effect if the Current_Value refers to a conditional with a
    --  condition other than equality.
 
    procedure Expand_Discriminant (N : Node_Id);
@@ -158,11 +159,7 @@ package body Exp_Ch2 is
                CS := Scope (CS);
 
             --  Otherwise, the reference is dubious, and we cannot be
-            --  sure that it is safe to do the replacement. Note in
-            --  particular, in a loop (except for the special case
-            --  tested above), we cannot safely do a replacement since
-            --  there may be an assignment at the bottom of the loop
-            --  that will affect a reference at the top of the loop.
+            --  sure that it is safe to do the replacement.
 
             else
                exit;
@@ -177,6 +174,10 @@ package body Exp_Ch2 is
    begin
       if True
 
+         --  No replacement if value raises constraint error
+
+         and then Nkind (CV) /= N_Raise_Constraint_Error
+
          --  Do this only for discrete types
 
          and then Is_Discrete_Type (T)
@@ -216,6 +217,14 @@ package body Exp_Ch2 is
          --  issue that they do not get replaced when they could be).
 
          and then Nkind (Parent (N)) /= N_Pragma_Argument_Association
+
+         --  Same for Asm_Input and Asm_Output attribute references
+
+         and then not (Nkind (Parent (N)) = N_Attribute_Reference
+                         and then
+                           (Attribute_Name (Parent (N)) = Name_Asm_Input
+                              or else
+                            Attribute_Name (Parent (N)) = Name_Asm_Output))
       then
          --  Case of Current_Value is a compile time known value
 
@@ -410,7 +419,6 @@ package body Exp_Ch2 is
                or else
              Ekind (E) = E_Out_Parameter)
         and then Present (Current_Value (E))
-        and then Nkind (Current_Value (E)) /= N_Raise_Constraint_Error
       then
          Expand_Current_Value (N);
 
@@ -510,8 +518,9 @@ package body Exp_Ch2 is
       P_Comp_Ref :=
         Make_Selected_Component (Loc,
           Prefix =>
-            Unchecked_Convert_To (Parm_Type,
-              New_Reference_To (Addr_Ent, Loc)),
+            Make_Explicit_Dereference (Loc,
+              Unchecked_Convert_To (Parm_Type,
+                New_Reference_To (Addr_Ent, Loc))),
           Selector_Name =>
             New_Reference_To (Entry_Component (Ent_Formal), Loc));