From 9616781de2cfd1ab1d0e0c5fa238b12988c39945 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 5 Mar 2019 17:22:16 +0100 Subject: [PATCH] re PR middle-end/89590 (ICE in maybe_emit_free_warning) 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 | 6 ++++++ gcc/builtins.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr89590.c | 11 +++++++++++ 4 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr89590.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b85b54cb096..c02e488d90c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-03-05 Jakub Jelinek + + PR middle-end/89590 + * builtins.c (maybe_emit_free_warning): Punt if free doesn't have + exactly one argument. + 2019-03-05 Jakub Jelinek Richard Sandiford diff --git a/gcc/builtins.c b/gcc/builtins.c index c19ca308b1b..d216d6fb881 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7c57390f83b..98289eb174c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-05 Jakub Jelinek + + PR middle-end/89590 + * gcc.dg/pr89590.c: New test. + 2019-03-05 Wilco Dijkstra PR target/89222 diff --git a/gcc/testsuite/gcc.dg/pr89590.c b/gcc/testsuite/gcc.dg/pr89590.c new file mode 100644 index 00000000000..441b0f9c47e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89590.c @@ -0,0 +1,11 @@ +/* PR middle-end/89590 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall -w" } */ + +void free (void *); + +void +foo (void) +{ + ((void (*)()) free) (); +} -- 2.30.2