From 3f27391f45bee92884daf6dcf40a652a38a69658 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 3 Jul 2018 14:21:15 +0000 Subject: [PATCH] re PR middle-end/86202 (ICE in get_range_info calling an invalid memcpy() declaration) PR middle-end/86202 * gimple-fold.c (size_must_be_zero_p): Check the type of the size. * gcc.dg/Wint-conversion-2.c: New test. From-SVN: r262344 --- gcc/ChangeLog | 5 +++++ gcc/gimple-fold.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/Wint-conversion-2.c | 11 +++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/Wint-conversion-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a0b7d35de5a..91f983df311 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-07-03 Marek Polacek + + PR middle-end/86202 + * gimple-fold.c (size_must_be_zero_p): Check the type of the size. + 2018-07-03 Richard Biener PR ipa/86389 diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index a31f5071863..6ce34bfb57c 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -645,7 +645,7 @@ size_must_be_zero_p (tree size) if (integer_zerop (size)) return true; - if (TREE_CODE (size) != SSA_NAME) + if (TREE_CODE (size) != SSA_NAME || !INTEGRAL_TYPE_P (TREE_TYPE (size))) return false; wide_int min, max; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c1bfad8ccfc..9e6f966b9d5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-03 Marek Polacek + + PR middle-end/86202 + * gcc.dg/Wint-conversion-2.c: New test. + 2018-07-03 Richard Biener PR ipa/86389 diff --git a/gcc/testsuite/gcc.dg/Wint-conversion-2.c b/gcc/testsuite/gcc.dg/Wint-conversion-2.c new file mode 100644 index 00000000000..0c9dac44c41 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wint-conversion-2.c @@ -0,0 +1,11 @@ +/* PR middle-end/86202 */ +/* { dg-do compile } */ +/* { dg-options "-Wint-conversion" } */ + +void *memcpy (void *, void *, __SIZE_TYPE__ *); +void *a, *b; +void f (void) +{ + long unsigned int c = 0; + memcpy (a, b, c); /* { dg-warning "passing argument" } */ +} -- 2.30.2