re PR middle-end/83463 (ICE: tree check: expected integer_type or enumeral_type or...
authorMarek Polacek <polacek@redhat.com>
Mon, 18 Dec 2017 16:44:35 +0000 (16:44 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 18 Dec 2017 16:44:35 +0000 (16:44 +0000)
PR middle-end/83463
* gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref):
Check if TYPE is INTEGRAL_TYPE_P before accessing its min/max
values.

* gcc.dg/pr83463.c: New test.

From-SVN: r255781

gcc/ChangeLog
gcc/gimple-ssa-warn-restrict.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr83463.c [new file with mode: 0644]

index 5cd14bbaaa9c6f6fe99578698ca391a6400cc662..a4a2afe6348b88a61f04bd7db69af1545b4744c3 100644 (file)
@@ -1,3 +1,10 @@
+2017-12-18  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/83463
+       * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref):
+       Check if TYPE is INTEGRAL_TYPE_P before accessing its min/max
+       values.
+
 2017-12-18  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * config/arc/arc.md (maddsidi4, maddsidi4_split): Update pattern.
index 4d424735d2ac25684d9880d310d34316fc98aaed..d1a376637a2d75a14286be35294f002362f93209 100644 (file)
@@ -287,13 +287,15 @@ builtin_memref::builtin_memref (tree expr, tree size)
                  else
                    {
                      gimple *stmt = SSA_NAME_DEF_STMT (offset);
+                     tree type;
                      if (is_gimple_assign (stmt)
-                         && gimple_assign_rhs_code (stmt) == NOP_EXPR)
+                         && gimple_assign_rhs_code (stmt) == NOP_EXPR
+                         && (type = TREE_TYPE (gimple_assign_rhs1 (stmt)))
+                         && INTEGRAL_TYPE_P (type))
                        {
                          /* Use the bounds of the type of the NOP_EXPR operand
                             even if it's signed.  The result doesn't trigger
                             warnings but makes their output more readable.  */
-                         tree type = TREE_TYPE (gimple_assign_rhs1 (stmt));
                          offrange[0] = wi::to_offset (TYPE_MIN_VALUE (type));
                          offrange[1] = wi::to_offset (TYPE_MAX_VALUE (type));
                        }
index 831a9bb11263c1596ba8450de0cb7120b7ac5594..57ef599565c8765d618050dbf64e53c0f8732f87 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-18  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/83463
+       * gcc.dg/pr83463.c: New test.
+
 2017-12-18  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/59930
diff --git a/gcc/testsuite/gcc.dg/pr83463.c b/gcc/testsuite/gcc.dg/pr83463.c
new file mode 100644 (file)
index 0000000..735ef3c
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR middle-end/83463 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wrestrict" } */
+
+int *a;
+void *memcpy ();
+void
+m (void *p1)
+{
+  memcpy (0, p1, 0);
+}
+
+void
+p ()
+{
+  m (p + (long) a);
+}