re PR tree-optimization/91945 (ICE: tree check: expected integer_cst, have var_decl...
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Nov 2019 10:17:29 +0000 (11:17 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Nov 2019 10:17:29 +0000 (11:17 +0100)
PR tree-optimization/91945
* builtins.c (compute_objsize): For ARRAY_REF, only multiply off
by tpsize if it is both non-NULL and INTEGER_CST, otherwise punt.
Formatting fix.

* gfortran.dg/pr91945.f90: New test.

From-SVN: r277820

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr91945.f90 [new file with mode: 0644]

index 87b108057390c044cde92417b1db209362b82d1d..39832efe348aa9f64b40939bf24d4be7b3f7d3c3 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/91945
+       * builtins.c (compute_objsize): For ARRAY_REF, only multiply off
+       by tpsize if it is both non-NULL and INTEGER_CST, otherwise punt.
+       Formatting fix.
+
 2019-11-05  Aldy Hernandez  <aldyh@redhat.com>
 
        * range-op.cc (wi_set_zero_nonzero_bits): Remove static qualifier.
index 5d811f113c9071329a631aacd275d80ba6013c75..c8fa86f641dbbe1b3141850f2111416b35f193d5 100644 (file)
@@ -3626,7 +3626,7 @@ compute_objsize (tree dest, int ostype, tree *pdecl /* = NULL */)
                }
            }
          else if (TREE_CODE (off) == SSA_NAME
-             && INTEGRAL_TYPE_P (TREE_TYPE (off)))
+                  && INTEGRAL_TYPE_P (TREE_TYPE (off)))
            {
              wide_int min, max;
              enum value_range_kind rng = get_range_info (off, &min, &max);
@@ -3680,7 +3680,8 @@ compute_objsize (tree dest, int ostype, tree *pdecl /* = NULL */)
          if (TREE_CODE (dest) == ARRAY_REF)
            {
              tree eltype = TREE_TYPE (dest);
-             if (tree tpsize = TYPE_SIZE_UNIT (eltype))
+             tree tpsize = TYPE_SIZE_UNIT (eltype);
+             if (tpsize && TREE_CODE (tpsize) == INTEGER_CST)
                off = fold_build2 (MULT_EXPR, size_type_node, off, tpsize);
              else
                return NULL_TREE;
index 9be2ab4ac451fb81b2a37232b0c543e2882fca5a..8a12ddc2c3a8dbeca470265995a05c5dee38c3bb 100644 (file)
@@ -1,5 +1,8 @@
 2019-11-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/91945
+       * gfortran.dg/pr91945.f90: New test.
+
        PR c++/92343
        * g++.dg/cpp2a/attr-likely6.C: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/pr91945.f90 b/gcc/testsuite/gfortran.dg/pr91945.f90
new file mode 100644 (file)
index 0000000..d417a8b
--- /dev/null
@@ -0,0 +1,5 @@
+! PR tree-optimization/91945
+! { dg-do compile }
+! { dg-options "-O3 -fstack-arrays -fno-guess-branch-probability" }
+
+include 'result_in_spec_1.f90'