OSDN Git Service

* sem_ch3.adb: Clarify some ???.
authorbosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Dec 2001 22:25:15 +0000 (22:25 +0000)
committerbosch <bosch@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Dec 2001 22:25:15 +0000 (22:25 +0000)
* exp_util.adb (Must_Be_Aligned): Removed, replaced by
Exp_Pakd.Known_Aligned_Enough

* sem_ch13.adb (Check_Address_Alignment): Removed, extended
version is moved to Exp_Ch13.

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

gcc/ada/ChangeLog
gcc/ada/exp_util.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch3.adb

index 5a24178..e82eb26 100644 (file)
@@ -1,3 +1,45 @@
+2001-12-11  Ed Schonberg <schonber@gnat.com>
+
+       * sem_ch3.adb: Clarify some ???.
+       
+2001-12-11  Robert Dewar <dewar@gnat.com>
+
+       * exp_util.adb (Must_Be_Aligned): Removed, replaced by 
+       Exp_Pakd.Known_Aligned_Enough
+       
+       * sem_ch13.adb (Check_Address_Alignment): Removed, extended 
+       version is moved to Exp_Ch13.
+
+2001-12-11  Robert Dewar <dewar@gnat.com>
+
+       * einfo.ads: Minor reformatting
+       
+       * exp_ch5.adb: Add comment for previous.change
+       
+       * ali.adb: New interface for extended typeref stuff.
+       
+       * ali.ads: New interface for typeref stuff.
+       
+       * checks.adb (Apply_Alignment_Check): New procedure.
+       
+       * debug.adb: Add -gnatdM for modified ALI output
+       
+       * exp_pakd.adb (Known_Aligned_Enough): Replaces Known_Aligned_Enough.
+       
+       * lib-xref.adb: Extend generation of <..> notation to cover 
+       subtype/object types. Note that this is a complete rewrite, 
+       getting rid of the very nasty quadratic algorithm previously 
+       used for derived type output.
+       
+       * lib-xref.ads: Extend description of <..> notation to cover 
+       subtype/object types. Uses {..} for these other cases. 
+       Also use (..) for pointer types.
+       
+       * sem_util.adb (Check_Potentially_Blocking_Operation): Slight cleanup.
+       
+       * exp_pakd.adb: Minor reformatting.  Note that prevous RH should say: 
+       (Known_Aligned_Enough): Replaces Must_Be_Aligned.
+
 2001-12-11  Vincent Celier <celier@gnat.com>
 
        * gnatcmd.adb:
index 6aeba91..f7a52a7 100644 (file)
@@ -2488,101 +2488,6 @@ package body Exp_Util is
       end if;
    end May_Generate_Large_Temp;
 
-   ---------------------
-   -- Must_Be_Aligned --
-   ---------------------
-
-   function Must_Be_Aligned (Obj : Node_Id) return Boolean is
-      Typ : constant Entity_Id := Etype (Obj);
-
-      function In_Partially_Packed_Record (Comp : Entity_Id) return Boolean;
-      --  If the component is in a record that contains previous packed
-      --  components, consider it unaligned because the back-end might
-      --  choose to pack the rest of the record. Lead to less efficient code,
-      --  but safer vis-a-vis of back-end choices.
-
-      -----------------------------
-      -- Partially_Packed_Record --
-      -----------------------------
-
-      function In_Partially_Packed_Record (Comp : Entity_Id) return Boolean is
-         Rec_Type  : constant Entity_Id := Scope (Comp);
-         Prev_Comp : Entity_Id;
-
-      begin
-         Prev_Comp := First_Entity (Rec_Type);
-         while Present (Prev_Comp) loop
-            if Is_Packed (Etype (Prev_Comp)) then
-               return True;
-
-            elsif Prev_Comp = Comp then
-               return False;
-            end if;
-
-            Next_Entity (Prev_Comp);
-         end loop;
-
-         return False;
-      end  In_Partially_Packed_Record;
-
-   --  Start of processing for Must_Be_Aligned
-
-   begin
-      --  If object is strictly aligned, we can quit now
-
-      if Strict_Alignment (Typ) then
-         return True;
-
-      --  Case of subscripted array reference
-
-      elsif Nkind (Obj) = N_Indexed_Component then
-
-         --  If we have a pointer to an array, then this is definitely
-         --  aligned, because pointers always point to aligned versions.
-
-         if Is_Access_Type (Etype (Prefix (Obj))) then
-            return True;
-
-         --  Otherwise, go look at the prefix
-
-         else
-            return Must_Be_Aligned (Prefix (Obj));
-         end if;
-
-      --  Case of record field
-
-      elsif Nkind (Obj) = N_Selected_Component then
-
-         --  What is significant here is whether the record type is packed
-
-         if Is_Record_Type (Etype (Prefix (Obj)))
-           and then Is_Packed (Etype (Prefix (Obj)))
-         then
-            return False;
-
-         --  Or the component has a component clause which might cause
-         --  the component to become unaligned (we can't tell if the
-         --  backend is doing alignment computations).
-
-         elsif Present (Component_Clause (Entity (Selector_Name (Obj)))) then
-            return False;
-
-         elsif In_Partially_Packed_Record (Entity (Selector_Name (Obj))) then
-            return False;
-
-         --  In all other cases, go look at prefix
-
-         else
-            return Must_Be_Aligned (Prefix (Obj));
-         end if;
-
-      --  If not selected or indexed component, must be aligned
-
-      else
-         return True;
-      end if;
-   end Must_Be_Aligned;
-
    ----------------------------
    -- New_Class_Wide_Subtype --
    ----------------------------
index 3fb6334..a4a76ff 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.1 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001, Free Software Foundation, Inc.         --
 --                                                                          --
@@ -27,6 +27,7 @@
 ------------------------------------------------------------------------------
 
 with Atree;    use Atree;
+with Checks;   use Checks;
 with Einfo;    use Einfo;
 with Errout;   use Errout;
 with Exp_Tss;  use Exp_Tss;
@@ -68,14 +69,6 @@ package body Sem_Ch13 is
    --  inherited from a derived type that is no longer appropriate for the
    --  new Esize value. In this case, we reset the Alignment to unknown.
 
-   procedure Check_Address_Alignment (E : Entity_Id; Expr : Node_Id);
-   --  Given an object entity E, for which the alignment is known, checks
-   --  to see if Expr (the expression from an Address clause) is a known
-   --  at compile time value, and if so posts a warning if the value is
-   --  not consistent with the known alignment requirement. This is not
-   --  an error, but rather leads to erroneous behavior, but we certainly
-   --  may as well give a warning if we detect this situation.
-
    procedure Check_Component_Overlap (C1_Ent, C2_Ent : Entity_Id);
    --  Given two entities for record components or discriminants, checks
    --  if they hav overlapping component clauses and issues errors if so.
@@ -315,7 +308,7 @@ package body Sem_Ch13 is
 
                Check_Constant_Address_Clause (Expr, U_Ent);
 
-            --  Case of address clause for variable or constant
+            --  Case of address clause for an object
 
             elsif
               Ekind (U_Ent) = E_Variable
@@ -398,10 +391,12 @@ package body Sem_Ch13 is
                      Warn_Overlay (Expr, Typ, Nam);
                   end if;
 
-                  --  Check for bad alignment
+                  --  If entity has delayed freeze then we will generate
+                  --  an alignment check at the freeze point. If there is
+                  --  no delayed freeze we can do it right now.
 
-                  if Known_Alignment (U_Ent) then
-                     Check_Address_Alignment (U_Ent, Expr);
+                  if not Has_Delayed_Freeze (U_Ent) then
+                     Apply_Alignment_Check (U_Ent, N);
                   end if;
 
                   --  Kill the size check code, since we are not allocating
@@ -2321,41 +2316,6 @@ package body Sem_Ch13 is
    end Analyze_Record_Representation_Clause;
 
    -----------------------------
-   -- Check_Address_Alignment --
-   -----------------------------
-
-   procedure Check_Address_Alignment (E : Entity_Id; Expr : Node_Id) is
-      Arg : Node_Id;
-
-   begin
-      if Nkind (Expr) = N_Unchecked_Type_Conversion then
-         Arg := Expression (Expr);
-
-      elsif Nkind (Expr) = N_Function_Call
-        and then Is_RTE (Entity (Name (Expr)), RE_To_Address)
-      then
-         Arg := First (Parameter_Associations (Expr));
-
-         if Nkind (Arg) = N_Parameter_Association then
-            Arg := Explicit_Actual_Parameter (Arg);
-         end if;
-
-      else
-         return;
-      end if;
-
-      --  Here Arg is the address value
-
-      if Compile_Time_Known_Value (Arg) then
-         if Expr_Value (Arg) mod Alignment (E) /= 0 then
-            Error_Msg_NE
-              ("?specified address for& not consistent with alignment",
-               Arg, E);
-         end if;
-      end if;
-   end Check_Address_Alignment;
-
-   -----------------------------
    -- Check_Component_Overlap --
    -----------------------------
 
index dff460c..dcae6f9 100644 (file)
@@ -7306,7 +7306,7 @@ package body Sem_Ch3 is
       Suffix_Index : Nat)
    is
       Def_Id     : Entity_Id;
-      R          : Node_Id;
+      R          : Node_Id := Empty;
       Checks_Off : Boolean := False;
       T          : constant Entity_Id := Etype (Index);
 
@@ -7408,8 +7408,6 @@ package body Sem_Ch3 is
       Set_RM_Size        (Def_Id, RM_Size        (T));
       Set_First_Rep_Item (Def_Id, First_Rep_Item (T));
 
-      --  ??? ??? is R always initialized, not at all obvious why?
-
       Set_Scalar_Range   (Def_Id, R);
 
       Set_Etype (S, Def_Id);
@@ -10333,12 +10331,8 @@ package body Sem_Ch3 is
 
          --  The parser guarantees that the attribute is a RANGE attribute
 
-         --  Is order critical here (setting T before Resolve). If so,
-         --  document why, if not use Analyze_And_Resolve and get T after???
-
-         Analyze (I);
+         Analyze_And_Resolve (I);
          T := Etype (I);
-         Resolve (I, T);
          R := I;
 
       --  If none of the above, must be a subtype. We convert this to a