diff options
author | Martin Sebor <msebor@redhat.com> | 2019-12-16 22:24:15 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-12-16 15:24:15 -0700 |
commit | 126036359a27ee32a433d0404d88557bb0d15687 (patch) | |
tree | e42abfcd06549977d1125249b945a937b929f342 /gcc/builtins.c | |
parent | a326a3dedbff2c190418a28466946cac82295147 (diff) | |
download | gcc-126036359a27ee32a433d0404d88557bb0d15687.zip gcc-126036359a27ee32a433d0404d88557bb0d15687.tar.gz gcc-126036359a27ee32a433d0404d88557bb0d15687.tar.bz2 |
PR middle-end/92952 - gfortran.dg/lto/pr87689 FAILs at -O2
gcc/ChangeLog:
* builtins.c (compute_objsize): Adjust offset by the array low bound.
From-SVN: r279445
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 3e89f2a..1297494 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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); |