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] Housekeeping work in gigi (18/n)


In preparation for some upcoming real fixes, tested on i586-suse-linux, 
applied on the mainline.


2009-10-16  Eric Botcazou  <ebotcazou@adacore.com>

	* exp_dbug.ads: Adjust type names in comments.
	* gcc-interface/decl.c (maybe_pad_type): Remove NAME_TRAILER parameter,
	add new IS_COMPONENT_TYPE parameter.  Adjust.  Remove dead code.
	(gnat_to_gnu_entity): Adjust for above change.
	(gnat_to_gnu_component_type): Likewise.
	(gnat_to_gnu_field): Likewise.
	* gcc-interface/trans.c (call_to_gnu): Likewise.  Do not unnecessarily
	call max_size.
	* gcc-interface/utils.c (finish_record_type): Remove obsolete code.
	* gcc-interface/gigi.h (maybe_pad_type): Adjust prototype.


-- 
Eric Botcazou
Index: exp_dbug.ads
===================================================================
--- exp_dbug.ads	(revision 152750)
+++ exp_dbug.ads	(working copy)
@@ -873,12 +873,12 @@ package Exp_Dbug is
       --  the element type for AT1 might have a type defined as if it had
       --  been written:
       --
-      --     type at1___C_PAD is record null; end record;
-      --     for at1___C_PAD'Size use 16 * 8;
+      --     type at1___PAD is record null; end record;
+      --     for at1___PAD'Size use 16 * 8;
       --
       --  and there would also be
       --
-      --     type at1___C_PAD___XVS is record t1: Integer; end record;
+      --     type at1___PAD___XVS is record t1: Integer; end record;
       --     type t1 is ...
       --
       --  Had the subtype Int been dynamic:
@@ -888,7 +888,7 @@ package Exp_Dbug is
       --  Then the compiler would also generate a declaration whose effect
       --  would be
       --
-      --     at1___C_PAD___XVZ: constant Integer := 32 + M * 8 + padding term;
+      --     at1___PAD___XVZ: constant Integer := 32 + M * 8 + padding term;
       --
       --  Not all unconstrained types are so encoded; the XVS convention may be
       --  unnecessary for unconstrained types of fixed size. However, this
Index: gcc-interface/utils.c
===================================================================
--- gcc-interface/utils.c	(revision 152750)
+++ gcc-interface/utils.c	(working copy)
@@ -739,11 +739,6 @@ finish_record_type (tree record_type, tr
   if (code == QUAL_UNION_TYPE)
     nreverse (fieldlist);
 
-  /* If the type is discriminated, it can be used to access all its
-     constrained subtypes, so force structural equality checks.  */
-  if (CONTAINS_PLACEHOLDER_P (size))
-    SET_TYPE_STRUCTURAL_EQUALITY (record_type);
-
   if (rep_level < 2)
     {
       /* If this is a padding record, we never want to make the size smaller
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 152750)
+++ gcc-interface/decl.c	(working copy)
@@ -633,7 +633,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	    else
 	      gnu_type
 		= maybe_pad_type (gnu_type, NULL_TREE, align, gnat_entity,
-				  "PAD", false, definition, true);
+				  false, false, definition, true);
 	  }
 
 	/* If we are defining the object, see if it has a Size value and
@@ -838,7 +838,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	gnu_object_size = gnu_size ? gnu_size : TYPE_SIZE (gnu_type);
 	if (gnu_size || align > 0)
 	  gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity,
-				     "PAD", false, definition,
+				     false, false, definition,
 				     gnu_size ? true : false);
 
 	/* If this is a renaming, avoid as much as possible to create a new
@@ -1017,8 +1017,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	    && !gnu_expr
 	    && TREE_CODE (gnu_type) == RECORD_TYPE
 	    && (TYPE_CONTAINS_TEMPLATE_P (gnu_type)
-	        /* Beware that padding might have been introduced
-		   via maybe_pad_type above.  */
+	        /* Beware that padding might have been introduced above.  */
 		|| (TYPE_IS_PADDING_P (gnu_type)
 		    && TREE_CODE (TREE_TYPE (TYPE_FIELDS (gnu_type)))
 		       == RECORD_TYPE
@@ -4446,7 +4445,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	 us when we make the new TYPE_DECL below.  */
       if (gnu_size || align > 0)
 	gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity,
-				   "PAD", true, definition, false);
+				   false, true, definition, false);
 
       if (TREE_CODE (gnu_type) == RECORD_TYPE
 	  && TYPE_IS_PADDING_P (gnu_type))
@@ -5037,7 +5036,7 @@ gnat_to_gnu_component_type (Entity_Id gn
 	orig_type = gnu_type;
 
       gnu_type = maybe_pad_type (gnu_type, gnu_comp_size, 0, gnat_array,
-				 "C_PAD", false, definition, true);
+				 true, false, definition, true);
 
       /* If a padding record was made, declare it now since it will never be
 	 declared otherwise.  This is necessary to ensure that its subtrees
@@ -6046,25 +6045,20 @@ make_packable_type (tree type, bool in_r
 
 /* Ensure that TYPE has SIZE and ALIGN.  Make and return a new padded type
    if needed.  We have already verified that SIZE and TYPE are large enough.
-
-   GNAT_ENTITY and NAME_TRAILER are used to name the resulting record and
-   to issue a warning.
-
-   IS_USER_TYPE is true if we must complete the original type.
-
-   DEFINITION is true if this type is being defined.
-
-   SAME_RM_SIZE is true if the RM size of the resulting type is to be set
-   to SIZE too; otherwise, it's set to the RM size of the original type.  */
+   GNAT_ENTITY is used to name the resulting record and to issue a warning.
+   IS_COMPONENT_TYPE is true if this is being done for the component type
+   of an array.  IS_USER_TYPE is true if we must complete the original type.
+   DEFINITION is true if this type is being defined.  SAME_RM_SIZE is true
+   if the RM size of the resulting type is to be set to SIZE too; otherwise,
+   it's set to the RM size of the original type.  */
 
 tree
 maybe_pad_type (tree type, tree size, unsigned int align,
-		Entity_Id gnat_entity, const char *name_trailer,
+		Entity_Id gnat_entity, bool is_component_type,
 		bool is_user_type, bool definition, bool same_rm_size)
 {
   tree orig_rm_size = same_rm_size ? NULL_TREE : rm_size (type);
   tree orig_size = TYPE_SIZE (type);
-  unsigned int orig_align = align;
   tree record, field;
 
   /* If TYPE is a padded type, see if it agrees with any size and alignment
@@ -6124,15 +6118,12 @@ maybe_pad_type (tree type, tree size, un
   TYPE_IS_PADDING_P (record) = 1;
 
   if (Present (gnat_entity))
-    TYPE_NAME (record) = create_concat_name (gnat_entity, name_trailer);
+    TYPE_NAME (record) = create_concat_name (gnat_entity, "PAD");
 
   TYPE_VOLATILE (record)
     = Present (gnat_entity) && Treat_As_Volatile (gnat_entity);
 
   TYPE_ALIGN (record) = align;
-  if (orig_align)
-    TYPE_USER_ALIGN (record) = align;
-
   TYPE_SIZE (record) = size ? size : orig_size;
   TYPE_SIZE_UNIT (record)
     = convert (sizetype,
@@ -6256,7 +6247,7 @@ maybe_pad_type (tree type, tree size, un
 	    post_error_ne_tree ("{^ }bits of & unused?",
 				gnat_error_node, gnat_entity,
 				size_diffop (size, orig_size));
-	  else if (name_trailer[0] == 'C')
+	  else if (is_component_type)
 	    post_error_ne_tree ("component of& padded{ by ^ bits}?",
 				gnat_entity, gnat_entity,
 				size_diffop (size, orig_size));
@@ -6634,7 +6625,7 @@ gnat_to_gnu_field (Entity_Id gnat_field,
 
       orig_field_type = gnu_field_type;
       gnu_field_type = maybe_pad_type (gnu_field_type, gnu_size, 0, gnat_field,
-				       "PAD", false, definition, true);
+				       false, false, definition, true);
 
       /* If a padding record was made, declare it now since it will never be
 	 declared otherwise.  This is necessary to ensure that its subtrees
Index: gcc-interface/gigi.h
===================================================================
--- gcc-interface/gigi.h	(revision 152750)
+++ gcc-interface/gigi.h	(working copy)
@@ -124,21 +124,16 @@ extern tree make_aligning_type (tree typ
 
 /* Ensure that TYPE has SIZE and ALIGN.  Make and return a new padded type
    if needed.  We have already verified that SIZE and TYPE are large enough.
-
-   GNAT_ENTITY and NAME_TRAILER are used to name the resulting record and
-   to issue a warning.
-
-   IS_USER_TYPE is true if we must be sure we complete the original type.
-
-   DEFINITION is true if this type is being defined.
-
-   SAME_RM_SIZE is true if the RM_Size of the resulting type is to be
-   set to its TYPE_SIZE; otherwise, it's set to the RM_Size of the original
-   type.  */
+   GNAT_ENTITY is used to name the resulting record and to issue a warning.
+   IS_COMPONENT_TYPE is true if this is being done for the component type
+   of an array.  IS_USER_TYPE is true if we must complete the original type.
+   DEFINITION is true if this type is being defined.  SAME_RM_SIZE is true
+   if the RM size of the resulting type is to be set to SIZE too; otherwise,
+   it's set to the RM size of the original type.  */
 extern tree maybe_pad_type (tree type, tree size, unsigned int align,
-                            Entity_Id gnat_entity, const char *name_trailer,
+			    Entity_Id gnat_entity, bool is_component_type,
 			    bool is_user_type, bool definition,
-                            bool same_rm_size);
+			    bool same_rm_size);
 
 /* Given a GNU tree and a GNAT list of choices, generate an expression to test
    the value passed against the list of choices.  */
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 152750)
+++ gcc-interface/trans.c	(working copy)
@@ -2423,22 +2423,27 @@ call_to_gnu (Node_Id gnat_node, tree *gn
       }
     }
 
-  /* If we are calling by supplying a pointer to a target, set up that
-     pointer as the first argument.  Use GNU_TARGET if one was passed;
-     otherwise, make a target by building a variable of the maximum size
-     of the type.  */
+  /* If we are calling by supplying a pointer to a target, set up that pointer
+     as the first argument.  Use GNU_TARGET if one was passed; otherwise, make
+     a target by building a variable and use the maximum size of the type if
+     it has self-referential size.  */
   if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type))
     {
-      tree gnu_real_ret_type
+      tree gnu_ret_type
 	= TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (gnu_subprog_type)));
 
       if (!gnu_target)
 	{
-	  tree gnu_obj_type
-	    = maybe_pad_type (gnu_real_ret_type,
-			      max_size (TYPE_SIZE (gnu_real_ret_type), true),
-			      0, Etype (Name (gnat_node)), "PAD", false,
-			      false, false);
+	  tree gnu_obj_type;
+
+	  if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_ret_type)))
+	    gnu_obj_type
+	      = maybe_pad_type (gnu_ret_type,
+				max_size (TYPE_SIZE (gnu_ret_type), true),
+				0, Etype (Name (gnat_node)), false, false,
+				false, true);
+	  else
+	    gnu_obj_type = gnu_ret_type;
 
 	  /* ??? We may be about to create a static temporary if we happen to
 	     be at the global binding level.  That's a regression from what
@@ -2454,7 +2459,7 @@ call_to_gnu (Node_Id gnat_node, tree *gn
       gnu_actual_list
 	= tree_cons (NULL_TREE,
 		     build_unary_op (ADDR_EXPR, NULL_TREE,
-				     unchecked_convert (gnu_real_ret_type,
+				     unchecked_convert (gnu_ret_type,
 							gnu_target,
 							false)),
 		     NULL_TREE);

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