summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2017-12-18 16:44:35 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2017-12-18 16:44:35 +0000
commit066fc7517dc82b00de335c22d6238e434439d237 (patch)
tree1fa88d8a9432b53085d0e9aa6ed9bbdfd063c378 /gcc
parent02c7dd78fa0a3d05231f6340c4cc80d91b2393a5 (diff)
re PR middle-end/83463 (ICE: tree check: expected integer_type or enumeral_type or boolean_type or real_type or fixed_point_type, have pointer_type in builtin_memr ef, at gimple-ssa-warn-restrict.c:297)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimple-ssa-warn-restrict.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr83463.c17
4 files changed, 33 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5cd14bbaaa9..a4a2afe6348 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c
index 4d424735d2a..d1a376637a2 100644
--- a/gcc/gimple-ssa-warn-restrict.c
+++ b/gcc/gimple-ssa-warn-restrict.c
@@ -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));
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 831a9bb1126..57ef599565c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..735ef3c6dc8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr83463.c
@@ -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);
+}