re PR middle-end/89590 (ICE in maybe_emit_free_warning)
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Mar 2019 16:22:16 +0000 (17:22 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Mar 2019 16:22:16 +0000 (17:22 +0100)
PR middle-end/89590
* builtins.c (maybe_emit_free_warning): Punt if free doesn't have
exactly one argument.

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

From-SVN: r269392

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

index b85b54cb096b8178580198658e22f4162e8628b7..c02e488d90c41953cd0795a1e4cd85fda3901d65 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89590
+       * builtins.c (maybe_emit_free_warning): Punt if free doesn't have
+       exactly one argument.
+
 2019-03-05  Jakub Jelinek  <jakub@redhat.com>
            Richard Sandiford  <richard.sandiford@arm.com>
 
index c19ca308b1bd289fdb825a4c11a9406fc64fb783..d216d6fb88172747cf8016e7a1ed0683b14e1628 100644 (file)
@@ -10604,6 +10604,9 @@ maybe_emit_sprintf_chk_warning (tree exp, enum built_in_function fcode)
 static void
 maybe_emit_free_warning (tree exp)
 {
+  if (call_expr_nargs (exp) != 1)
+    return;
+
   tree arg = CALL_EXPR_ARG (exp, 0);
 
   STRIP_NOPS (arg);
index 7c57390f83bd824635867c35c738e0f830a97f55..98289eb174cb19b2e57c88757f69ecd853e352c6 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89590
+       * gcc.dg/pr89590.c: New test.
+
 2019-03-05  Wilco Dijkstra  <wdijkstr@arm.com>
 
        PR target/89222
diff --git a/gcc/testsuite/gcc.dg/pr89590.c b/gcc/testsuite/gcc.dg/pr89590.c
new file mode 100644 (file)
index 0000000..441b0f9
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR middle-end/89590 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall -w" } */
+
+void free (void *);
+
+void
+foo (void)
+{
+  ((void (*)()) free) ();
+}