OSDN Git Service

* tree-dfa.c (get_ref_base_and_extent): Do not expect positive
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Mar 2007 20:11:20 +0000 (20:11 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Mar 2007 20:11:20 +0000 (20:11 +0000)
offsets for BIT_FIELD_REF and COMPONENT_REF.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/thin_pointer.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/thin_pointer.ads [new file with mode: 0644]
gcc/tree-dfa.c

index 5f29dbe..5267e52 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-dfa.c (get_ref_base_and_extent): Do not expect positive
+       offsets for BIT_FIELD_REF and COMPONENT_REF.
+
 2007-03-28  Richard Guenther  <rguenther@suse.de>
 
        * tree.c (is_global_var): Move ...
index 2b66dad..b3b28b3 100644 (file)
@@ -1,3 +1,7 @@
+2007-03-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/thin_pointer.ad[sb]: New test.
+
 2007-03-28 Douglas Gregor <doug.gregor@gmail.com>
 
        * g++.dg/cpp0x/bracket1.C: New.
diff --git a/gcc/testsuite/gnat.dg/thin_pointer.adb b/gcc/testsuite/gnat.dg/thin_pointer.adb
new file mode 100644 (file)
index 0000000..1e3943f
--- /dev/null
@@ -0,0 +1,11 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+package body Thin_Pointer is
+
+   procedure Set_Buffer (AD : Buf_Ptr; Buffer : Stream_ptr) is
+   begin
+      AD.B.A := Buffer (Buffer'First)'Address;
+   end Set_Buffer;
+
+end Thin_Pointer;
diff --git a/gcc/testsuite/gnat.dg/thin_pointer.ads b/gcc/testsuite/gnat.dg/thin_pointer.ads
new file mode 100644 (file)
index 0000000..6f528a5
--- /dev/null
@@ -0,0 +1,22 @@
+with System;
+
+package Thin_Pointer is
+
+   type Stream is array (Integer range <>) of Character;
+
+   type Stream_Ptr is access Stream;
+   for Stream_Ptr'Size use Standard'Address_Size;
+
+   type Buf is record
+      A : System.Address;
+   end record;
+
+   type Buf_Wrapper is record
+      B : Buf;
+   end record;
+
+   type Buf_Ptr is access Buf_Wrapper;
+
+   procedure Set_Buffer (AD : Buf_Ptr; Buffer : Stream_ptr);
+
+end Thin_Pointer;
index b23c531..70563e7 100644 (file)
@@ -896,7 +896,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
       switch (TREE_CODE (exp))
        {
        case BIT_FIELD_REF:
-         bit_offset += tree_low_cst (TREE_OPERAND (exp, 2), 1);
+         bit_offset += tree_low_cst (TREE_OPERAND (exp, 2), 0);
          break;
 
        case COMPONENT_REF:
@@ -906,11 +906,11 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
 
            if (this_offset && TREE_CODE (this_offset) == INTEGER_CST)
              {
-               HOST_WIDE_INT hthis_offset = tree_low_cst (this_offset, 1);
+               HOST_WIDE_INT hthis_offset = tree_low_cst (this_offset, 0);
 
                hthis_offset *= BITS_PER_UNIT;
                bit_offset += hthis_offset;
-               bit_offset += tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1);
+               bit_offset += tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 0);
              }
            else
              {
@@ -918,11 +918,8 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
                /* We need to adjust maxsize to the whole structure bitsize.
                   But we can subtract any constant offset seen sofar,
                   because that would get us out of the structure otherwise.  */
-               if (maxsize != -1
-                   && csize && host_integerp (csize, 1))
-                 {
-                   maxsize = (TREE_INT_CST_LOW (csize) - bit_offset);
-                 }
+               if (maxsize != -1 && csize && host_integerp (csize, 1))
+                 maxsize = TREE_INT_CST_LOW (csize) - bit_offset;
                else
                  maxsize = -1;
              }
@@ -959,11 +956,8 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
                /* We need to adjust maxsize to the whole array bitsize.
                   But we can subtract any constant offset seen sofar,
                   because that would get us outside of the array otherwise.  */
-               if (maxsize != -1
-                   && asize && host_integerp (asize, 1))
-                 {
-                   maxsize = (TREE_INT_CST_LOW (asize) - bit_offset);
-                 }
+               if (maxsize != -1 && asize && host_integerp (asize, 1))
+                 maxsize = TREE_INT_CST_LOW (asize) - bit_offset;
                else
                  maxsize = -1;