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] Fix a couple of oversights wrt POINTER_PLUS_EXPR


Tested on i586-suse-linux, applied on the mainline.


2008-01-21  Eric Botcazou  <ebotcazou@adacore.com>

	* trans.c (gnat_to_gnu) <N_Free_Statement>: Use POINTER_PLUS_EXPR
	in pointer arithmetics.
	* utils2.c (build_allocator): Likewise.


2008-01-21  Eric Botcazou  <ebotcazou@adacore.com>

        * gnat.dg/specs/alignment1.ads: New test.


-- 
Eric Botcazou
Index: trans.c
===================================================================
--- trans.c	(revision 131674)
+++ trans.c	(working copy)
@@ -4672,10 +4672,9 @@ gnat_to_gnu (Node_Id gnat_node)
 		 = (void *)GNU_PTR - (void *)sizeof (void *))  */
  	      gnu_ptr
  		= build_binary_op
-		    (MINUS_EXPR, ptr_void_type_node,
+		    (POINTER_PLUS_EXPR, ptr_void_type_node,
 		     convert (ptr_void_type_node, gnu_ptr),
-		     convert (ptr_void_type_node,
-			      TYPE_SIZE_UNIT (ptr_void_type_node)));
+		     size_int (-POINTER_SIZE/BITS_PER_UNIT));
 
  	      /* GNU_PTR (void *) = *(void **)GNU_PTR  */
  	      gnu_ptr
Index: utils2.c
===================================================================
--- utils2.c	(revision 131674)
+++ utils2.c	(working copy)
@@ -2066,10 +2066,9 @@ build_allocator (tree type, tree init, t
 	 front.  */
       {
 	tree ptr_addr
-	  = build_binary_op (MINUS_EXPR, ptr_void_type_node,
+	  = build_binary_op (POINTER_PLUS_EXPR, ptr_void_type_node,
 			     convert (ptr_void_type_node, result),
-			     convert (ptr_void_type_node,
-				      TYPE_SIZE_UNIT (ptr_void_type_node)));
+			     size_int (-POINTER_SIZE/BITS_PER_UNIT));
 
 	tree ptr_ref
 	  = convert (build_pointer_type (ptr_void_type_node), ptr_addr);
-- { dg-do compile }

package Alignment1 is
   S : Natural := 20;
   pragma Volatile (S);

   type Block is array (1 .. S) of Integer;
   for Block'Alignment use 128;

   B : Block;
end;

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