PR tree-optimization/86622 - incorrect strlen of array of array plus variable offset
commitbfb9bd47b2daac0a01c561effac1d8244ddd99f6
authorMartin Sebor <msebor@redhat.com>
Wed, 25 Jul 2018 02:11:31 +0000 (25 02:11 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Wed, 25 Jul 2018 02:11:31 +0000 (24 20:11 -0600)
treebf72d7afae065152f74b4f862adffad1c954d61e
parentae752f020fd86b2d34a1556124dc4e5f01a8dcce
PR tree-optimization/86622 - incorrect strlen of array of array plus variable offset

PR tree-optimization/86622 - incorrect strlen of array of array plus variable offset
PR tree-optimization/86532 - Wrong code due to a wrong strlen folding starting with r262522

gcc/ChangeLog:

PR tree-optimization/86622
PR tree-optimization/86532
* builtins.h (string_length): Declare.
* builtins.c (c_strlen): Correct handling of non-constant offsets.
(check_access): Be prepared for non-constant length ranges.
(string_length): Make extern.
* expr.c (string_constant): Only handle the minor non-constant
array index.  Use string_constant to compute the length of
a generic string constant.

gcc/testsuite/ChangeLog:

PR tree-optimization/86622
PR tree-optimization/86532
* gcc.c-torture/execute/strlen-2.c: New test.
* gcc.c-torture/execute/strlen-3.c: New test.
* gcc.c-torture/execute/strlen-4.c: New test.

From-SVN: r262958
gcc/ChangeLog
gcc/builtins.c
gcc/builtins.h
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/strlen-2.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/strlen-3.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/strlen-4.c [new file with mode: 0644]