aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-01-11 05:13:57 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-01-10 22:13:57 -0700
commit1bfd6a0038c9ade9db7cbae3b550d14a62c91ebf (patch)
tree40c6d997cc3c2c18557c8bfa2bf6a706c9c9ed30 /gcc/gimple-fold.c
parent05ef31736c431ca4721ba8d05156e99af79a5aac (diff)
downloadgcc-1bfd6a0038c9ade9db7cbae3b550d14a62c91ebf.zip
gcc-1bfd6a0038c9ade9db7cbae3b550d14a62c91ebf.tar.gz
gcc-1bfd6a0038c9ade9db7cbae3b550d14a62c91ebf.tar.bz2
PR tree-optimization/83781 - Bootstrap failed on x86 with --with-arch=corei7
PR tree-optimization/83781 - Bootstrap failed on x86 with --with-arch=corei7 --with-cpu=corei7 gcc/ChangeLog: * gimple-fold.c (get_range_strlen): Avoid treating arrays of pointers as string arrays. gcc/testsuite/ChangeLog: * gcc.dg/strlenopt-42.c: New test. From-SVN: r256477
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 504a85d..3861692 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1360,10 +1360,17 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, int type,
{
tree type = TREE_TYPE (TREE_OPERAND (arg, 0));
+ /* Determine the "innermost" array type. */
while (TREE_CODE (type) == ARRAY_TYPE
&& TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
type = TREE_TYPE (type);
+ /* Avoid arrays of pointers. */
+ tree eltype = TREE_TYPE (type);
+ if (TREE_CODE (type) != ARRAY_TYPE
+ || !INTEGRAL_TYPE_P (eltype))
+ return false;
+
val = TYPE_SIZE_UNIT (type);
if (!val || integer_zerop (val))
return false;