]> gcc.gnu.org Git - gcc.git/commitdiff
PR middle-end/92952 - gfortran.dg/lto/pr87689 FAILs at -O2
authorMartin Sebor <msebor@redhat.com>
Mon, 16 Dec 2019 22:24:15 +0000 (22:24 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Mon, 16 Dec 2019 22:24:15 +0000 (15:24 -0700)
gcc/ChangeLog:
* builtins.c (compute_objsize): Adjust offset by the array low bound.

From-SVN: r279445

gcc/ChangeLog
gcc/builtins.c

index d25666380cd19ec62ef687c763453d5f14c64610..26dd71177e7daa590c0c233cac067ba6ef6cdd10 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-16  Martin Sebor  <msebor@redhat.com>
+
+       PR middle-end/92952
+       * builtins.c (compute_objsize): Adjust offset by the array low bound.
+
 2019-12-16  David Malcolm  <dmalcolm@redhat.com>
 
        * pretty-print.c (pp_write_text_as_html_like_dot_to_stream): New
index 3e89f2a7f26ffa7318848ad5b6a46b79a5445144..1297494ba0cf3a221a91531d519ddbb1bf69f8c7 100644 (file)
@@ -3999,6 +3999,16 @@ compute_objsize (tree dest, int ostype, tree *pdecl /* = NULL */,
             above.  */
          if (TREE_CODE (dest) == ARRAY_REF)
            {
+             tree lowbnd = array_ref_low_bound (dest);
+             if (!integer_zerop (lowbnd) && tree_fits_uhwi_p (lowbnd))
+               {
+                 /* Adjust the offset by the low bound of the array
+                    domain (normally zero but 1 in Fortran).  */
+                 unsigned HOST_WIDE_INT lb = tree_to_uhwi (lowbnd);
+                 offrng[0] -= lb;
+                 offrng[1] -= lb;
+               }
+
              /* Convert the array index into a byte offset.  */
              tree eltype = TREE_TYPE (dest);
              tree tpsize = TYPE_SIZE_UNIT (eltype);
This page took 0.131147 seconds and 5 git commands to generate.