aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-warn-restrict.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-12-11 01:22:08 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-12-10 18:22:08 -0700
commit1486eb791fce1b48d24075e281afd09864713e52 (patch)
tree67f9b03a71809c4fd08239f8335cf2235efe5765 /gcc/gimple-ssa-warn-restrict.c
parent03da9b757be0d4b2b1770c10f7e6f68d286a01da (diff)
downloadgcc-1486eb791fce1b48d24075e281afd09864713e52.zip
gcc-1486eb791fce1b48d24075e281afd09864713e52.tar.gz
gcc-1486eb791fce1b48d24075e281afd09864713e52.tar.bz2
PR tree-optimization/86196 - Bogus -Wrestrict on memcpy between array elements at unequal indices
gcc/ChangeLog: PR tree-optimization/86196 * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Use base size only of arrays. gcc/testsuite/ChangeLog: PR tree-optimization/86196 * gcc.dg/Wrestrict-18.c: New test. From-SVN: r266967
Diffstat (limited to 'gcc/gimple-ssa-warn-restrict.c')
-rw-r--r--gcc/gimple-ssa-warn-restrict.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c
index 035fbf8..d47f73f 100644
--- a/gcc/gimple-ssa-warn-restrict.c
+++ b/gcc/gimple-ssa-warn-restrict.c
@@ -272,15 +272,16 @@ builtin_memref::builtin_memref (tree expr, tree size)
offset_int maxoff = maxobjsize;
tree basetype = TREE_TYPE (base);
- if (TREE_CODE (basetype) == ARRAY_TYPE
- && ref
- && array_at_struct_end_p (ref))
- ; /* Use the maximum possible offset for last member arrays. */
- else if (tree basesize = TYPE_SIZE_UNIT (basetype))
- if (TREE_CODE (basesize) == INTEGER_CST)
- /* Size could be non-constant for a variable-length type such
- as a struct with a VLA member (a GCC extension). */
- maxoff = wi::to_offset (basesize);
+ if (TREE_CODE (basetype) == ARRAY_TYPE)
+ {
+ if (ref && array_at_struct_end_p (ref))
+ ; /* Use the maximum possible offset for last member arrays. */
+ else if (tree basesize = TYPE_SIZE_UNIT (basetype))
+ if (TREE_CODE (basesize) == INTEGER_CST)
+ /* Size could be non-constant for a variable-length type such
+ as a struct with a VLA member (a GCC extension). */
+ maxoff = wi::to_offset (basesize);
+ }
if (offrange[0] >= 0)
{