This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Remove special internal handling of class-wide subtypes


Class-wide subtypes are handled specially in the front-end for targets that do
not require front-end layout, as they are created already frozen.  This means
that they don't go through the freezing process, which can make it difficult
to enforce consistent setting of internal flags.

This change removes this special handling, as well as adjusts gigi accordingly
and lets class-wide subtypes be treated the regular way, in preparation for an
enhancement in the handling of the Debug_Info_Needed flag for them.

No functional changes so no test required.  Tested on i586-suse-linux, applied 
on the mainline.


2009-11-24  Eric Botcazou  <ebotcazou@adacore.com>

	* exp_util.adb (Make_CW_Equivalent_Type): Do not mark the type as
	frozen for targets that do not require front-end layout.
	(New_Class_Wide_Subtype): Always reset the freezing status to False.
	* exp_ch8.adb: Do not 'with' Targparm.
	(Expand_N_Object_Renaming_Declaration): Always freeze a class-wide
	subtype that has been built from the expression.
	* exp_intr.adb (Expand_Unc_Deallocation): If the designated type is
	class wide, freeze the implicit type that has been built from the
	expression at the dereference point.
	* freeze.adb (Freeze_Entity): Adjust comment.
	* gcc-interface/decl.c (Gigi_Equivalent_Type) <E_Class_Wide_Type>:
	Remove useless test.
	* gcc-interface/trans.c (process_freeze_entity): Do not special-case
	class-wide subtypes.

	* s-osinte-aix.adb (clock_gettime): Fix comment.
	* s-osinte-darwin.adb (clock_gettime): Likewise.


-- 
Eric Botcazou
Index: exp_util.adb
===================================================================
--- exp_util.adb	(revision 154511)
+++ exp_util.adb	(working copy)
@@ -3775,19 +3775,6 @@ package body Exp_Util is
       --  end Equiv_T;
 
       Equiv_Type := Make_Defining_Identifier (Loc, New_Internal_Name ('T'));
-
-      --  When the target requires front-end layout, it's necessary to allow
-      --  the equivalent type to be frozen so that layout can occur (when the
-      --  associated class-wide subtype is frozen, the equivalent type will
-      --  be frozen, see freeze.adb). For other targets, Gigi wants to have
-      --  the equivalent type marked as frozen and deals with this type itself.
-      --  In the Gigi case this will also avoid the generation of an init
-      --  procedure for the type.
-
-      if not Frontend_Layout_On_Target then
-         Set_Is_Frozen (Equiv_Type);
-      end if;
-
       Set_Ekind (Equiv_Type, E_Record_Type);
       Set_Parent_Subtype (Equiv_Type, Constr_Root);
 
@@ -4090,18 +4077,7 @@ package body Exp_Util is
       Set_Ekind (Res, E_Class_Wide_Subtype);
       Set_Next_Entity (Res, Empty);
       Set_Etype (Res, Base_Type (CW_Typ));
-
-      --  For targets where front-end layout is required, reset the Is_Frozen
-      --  status of the subtype to False (it can be implicitly set to true
-      --  from the copy of the class-wide type). For other targets, Gigi
-      --  doesn't want the class-wide subtype to go through the freezing
-      --  process (though it's unclear why that causes problems and it would
-      --  be nice to allow freezing to occur normally for all targets ???).
-
-      if Frontend_Layout_On_Target then
-         Set_Is_Frozen (Res, False);
-      end if;
-
+      Set_Is_Frozen (Res, False);
       Set_Freeze_Node (Res, Empty);
       return (Res);
    end New_Class_Wide_Subtype;
Index: exp_ch8.adb
===================================================================
--- exp_ch8.adb	(revision 154511)
+++ exp_ch8.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -35,7 +35,6 @@ with Sem;      use Sem;
 with Sem_Ch8;  use Sem_Ch8;
 with Sinfo;    use Sinfo;
 with Stand;    use Stand;
-with Targparm; use Targparm;
 
 package body Exp_Ch8 is
 
@@ -254,15 +253,9 @@ package body Exp_Ch8 is
          Set_Etype (Defining_Identifier (N), Entity (Subtype_Mark (N)));
 
          --  Freeze the class-wide subtype here to ensure that the subtype
-         --  and equivalent type are frozen before the renaming. This is
-         --  required for targets where Frontend_Layout_On_Target is true.
-         --  For targets where Gigi is used, class-wide subtype should not
-         --  be frozen (in that case the subtype is marked as already frozen
-         --  when it's created).
+         --  and equivalent type are frozen before the renaming.
 
-         if Frontend_Layout_On_Target then
-            Freeze_Before (N, Entity (Subtype_Mark (N)));
-         end if;
+         Freeze_Before (N, Entity (Subtype_Mark (N)));
       end if;
 
       --  Ada 2005 (AI-318-02): If the renamed object is a call to a build-in-
Index: s-osinte-aix.adb
===================================================================
--- s-osinte-aix.adb	(revision 154511)
+++ s-osinte-aix.adb	(working copy)
@@ -110,8 +110,7 @@ package body System.OS_Interface is
    is
       pragma Unreferenced (clock_id);
 
-      --  Darwin threads don't have clock_gettime, so use
-      --  gettimeofday() instead.
+      --  Older AIX don't have clock_gettime, so use gettimeofday
 
       use Interfaces;
 
Index: s-osinte-darwin.adb
===================================================================
--- s-osinte-darwin.adb	(revision 154511)
+++ s-osinte-darwin.adb	(working copy)
@@ -93,8 +93,7 @@ package body System.OS_Interface is
    is
       pragma Unreferenced (clock_id);
 
-      --  AIX threads don't have clock_gettime, so use
-      --  gettimeofday() instead.
+      --  Darwin Threads don't have clock_gettime, so use gettimeofday
 
       use Interfaces;
 
Index: exp_intr.adb
===================================================================
--- exp_intr.adb	(revision 154511)
+++ exp_intr.adb	(working copy)
@@ -1018,14 +1018,19 @@ package body Exp_Intr is
                else
                   D_Type := Make_Defining_Identifier (Loc,
                               New_Internal_Name ('A'));
-                  Insert_Action (N,
+                  Insert_Action (Deref,
                     Make_Subtype_Declaration (Loc,
                       Defining_Identifier => D_Type,
                       Subtype_Indication  => D_Subtyp));
-                  Freeze_Itype (D_Type, N);
 
                end if;
 
+               --  Force freezing at the point of the dereference. For the
+               --  class wide case, this avoids having the subtype frozen
+               --  before the equivalent type.
+
+               Freeze_Itype (D_Type, Deref);
+
                Set_Actual_Designated_Subtype (Free_Node, D_Type);
             end;
 
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 154511)
+++ gcc-interface/decl.c	(working copy)
@@ -4965,9 +4965,7 @@ Gigi_Equivalent_Type (Entity_Id gnat_ent
       break;
 
     case E_Class_Wide_Type:
-      gnat_equiv = ((Present (Equivalent_Type (gnat_entity)))
-		    ? Equivalent_Type (gnat_entity)
-		    : Root_Type (gnat_entity));
+      gnat_equiv = Root_Type (gnat_entity);
       break;
 
     case E_Task_Type:
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 154511)
+++ gcc-interface/trans.c	(working copy)
@@ -6087,11 +6087,9 @@ process_freeze_entity (Node_Id gnat_node
   if (Present (Address_Clause (gnat_entity)))
     gnu_old = 0;
 
-  /* Don't do anything for class-wide types they are always
-     transformed into their root type.  */
-  if (Ekind (gnat_entity) == E_Class_Wide_Type
-      || (Ekind (gnat_entity) == E_Class_Wide_Subtype
-	  && Present (Equivalent_Type (gnat_entity))))
+  /* Don't do anything for class-wide types as they are always transformed
+     into their root type.  */
+  if (Ekind (gnat_entity) == E_Class_Wide_Type)
     return;
 
   /* Don't do anything for subprograms that may have been elaborated before
Index: freeze.adb
===================================================================
--- freeze.adb	(revision 154511)
+++ freeze.adb	(working copy)
@@ -3459,10 +3459,7 @@ package body Freeze is
             end if;
 
             --  The equivalent type associated with a class-wide subtype needs
-            --  to be frozen to ensure that its layout is done. Class-wide
-            --  subtypes are currently only frozen on targets requiring
-            --  front-end layout (see New_Class_Wide_Subtype and
-            --  Make_CW_Equivalent_Type in exp_util.adb).
+            --  to be frozen to ensure that its layout is done.
 
             if Ekind (E) = E_Class_Wide_Subtype
               and then Present (Equivalent_Type (E))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]