]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
trans.c (gnat_to_gnu): Use POINTER_PLUS_EXPR in pointer arithmetics.
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 21 Jan 2008 11:58:53 +0000 (11:58 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 21 Jan 2008 11:58:53 +0000 (11:58 +0000)
* trans.c (gnat_to_gnu) <N_Free_Statement>: Use POINTER_PLUS_EXPR
in pointer arithmetics.
* utils2.c (build_allocator): Likewise.

From-SVN: r131692

gcc/ada/ChangeLog
gcc/ada/trans.c
gcc/ada/utils2.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/alignment1.ads [new file with mode: 0644]

index 33293cf9096d4ab29021781454d27c12f12b4f68..f571ec962c2964e469f2300cb3b0217674e3eaca 100644 (file)
@@ -1,3 +1,9 @@
+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-17  Eric Botcazou  <ebotcazou@adacore.com>
 
        * utils.c (build_function_stub): Properly build the call expression.
index 5b04972b2d235c50cc28b77318643685cb179170..c79ed4dbd3fc16517c67a62b5cff2dfb40a2014a 100644 (file)
@@ -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 b8f59477af59a8afda3d251d39ef3322420138a9..a2a7be4c13580cdb5124a83c591b9c619595a69a 100644 (file)
@@ -2066,10 +2066,9 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc,
         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);
index 04ad10cd0321f44dab49c06dd6d300eb2591241d..e15a98f683984215cf9437d51a470c0bed0ba61d 100644 (file)
@@ -1,3 +1,7 @@
+2008-01-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/alignment1.ads: New test.
+
 2008-01-21  Richard Guenther  <rguenther@suse.de>
 
        PR c++/34850
diff --git a/gcc/testsuite/gnat.dg/specs/alignment1.ads b/gcc/testsuite/gnat.dg/specs/alignment1.ads
new file mode 100644 (file)
index 0000000..cffcba1
--- /dev/null
@@ -0,0 +1,11 @@
+-- { 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;