]> gcc.gnu.org Git - gcc.git/commitdiff
PR tree-optimization/83781 - Bootstrap failed on x86 with --with-arch=corei7
authorMartin Sebor <msebor@redhat.com>
Thu, 11 Jan 2018 05:13:57 +0000 (05:13 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Thu, 11 Jan 2018 05:13:57 +0000 (22:13 -0700)
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

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/strlenopt-42.c [new file with mode: 0644]

index bb6bf49107df2de756470a9411da6d6aec0ff728..f69ddc6d257be830ae0403fe91373524b41a8b02 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-10  Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/83781
+       * gimple-fold.c (get_range_strlen): Avoid treating arrays of pointers
+       as string arrays.
+
 2018-01-11  Martin Sebor  <msebor@gmail.com>
            Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
index 504a85d1441da6814229dee3028793b13cba2cde..386169235553cb1bf915e517dc02ebdc7b042964 100644 (file)
@@ -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;
index dd4bfcec00ca1eb3d12737170ed54a60bf6dba2d..8572bfc9d4a5bf96466368db3c30f3ac712bde58 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-10  Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/83781
+       * gcc.dg/strlenopt-42.c: New test.
+
 2018-01-11  Martin Sebor  <msebor@gmail.com>
            Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
diff --git a/gcc/testsuite/gcc.dg/strlenopt-42.c b/gcc/testsuite/gcc.dg/strlenopt-42.c
new file mode 100644 (file)
index 0000000..019b89e
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR tree-optimization/83781 - Bootstrap failed on x86 with --with-arch=corei7
+   --with-cpu=corei7
+   Verify that the upper bound of the size of an array of pointers
+   to strings isn't considered to be the upper bound of the lengths
+   of the pointed-to strings.
+   { dg-do compile }
+   { dg-options "-O2 -Wall" } */
+
+const char* const ap[32] = { "1", "12", "123" };
+
+char d4[4];
+char d7[7];
+
+void nowarn_range_ptr_var_1 (int i)
+{
+  __builtin_sprintf (d4, "%s", ap[i]);
+}
+
+void nowarn_range_ptr_var_2 (int i, int j)
+{
+  __builtin_sprintf (d7, "%s%s", ap[i], ap[j]);
+}
This page took 0.105304 seconds and 5 git commands to generate.