re PR middle-end/86202 (ICE in get_range_info calling an invalid memcpy() declaration)
authorMarek Polacek <polacek@redhat.com>
Tue, 3 Jul 2018 14:21:15 +0000 (14:21 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 3 Jul 2018 14:21:15 +0000 (14:21 +0000)
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
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wint-conversion-2.c [new file with mode: 0644]

index a0b7d35de5a06c5c5fb9a23513b14e208fc03551..91f983df3110d57233e1bd6a0b01b3a652af35f7 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-03  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/86202
+       * gimple-fold.c (size_must_be_zero_p): Check the type of the size.
+
 2018-07-03  Richard Biener  <rguenther@suse.de>
 
        PR ipa/86389
index a31f5071863c227a64de2c561110dcade1ad1708..6ce34bfb57c74dd19388974d9a86e2202b5f03fa 100644 (file)
@@ -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;
index c1bfad8ccfce86c9a97e95d52b21ee24a193992c..9e6f966b9d5bd8da50ada42fec0367844f05e0af 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-03  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/86202
+       * gcc.dg/Wint-conversion-2.c: New test.
+
 2018-07-03  Richard Biener  <rguenther@suse.de>
 
        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 (file)
index 0000000..0c9dac4
--- /dev/null
@@ -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" } */
+}