PR tree-optimization/86622 - incorrect strlen of array of array plus variable offset
commitc4183f31f2467a1c995b140e5a83a2ce5e042325
authormsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Jul 2018 02:11:31 +0000 (25 02:11 +0000)
committermsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Jul 2018 02:11:31 +0000 (25 02:11 +0000)
treebf72d7afae065152f74b4f862adffad1c954d61e
parentd33119a8c54040162573fdc00835a58b1a55e732
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262958 138bc75d-0d04-0410-961f-82ee72b054a4
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]