diff --git a/gcc/cgraph.c b/gcc/cgraph.c index dbde8aaaba1..cb59a5a71fc 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -2190,6 +2190,8 @@ cgraph_node::dump (FILE *f) fprintf (f, " optimize_size"); if (parallelized_function) fprintf (f, " parallelized_function"); + if (DECL_IS_MALLOC (decl)) + fprintf (f, " decl_is_malloc"); if (DECL_IS_OPERATOR_NEW_P (decl)) fprintf (f, " %soperator_new", DECL_IS_REPLACEABLE_OPERATOR (decl) ? "replaceable_" : ""); diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 054f35981a5..4c47eec8509 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1973,7 +1973,8 @@ propagate_malloc (void) funct_state l = funct_state_summaries->get (node); if (!node->alias && l->malloc_state == STATE_MALLOC - && !node->inlined_to) + && !node->inlined_to + && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (node->decl)))) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Function %s found to be malloc\n", diff --git a/gcc/testsuite/g++.dg/ipa/pr98075.C b/gcc/testsuite/g++.dg/ipa/pr98075.C new file mode 100644 index 00000000000..0c4219d1ff3 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr98075.C @@ -0,0 +1,30 @@ +/* PR ipa/98075 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-inline" } */ + +template +class xg { +public: + BS * + fw () + { + return static_cast (operator new (sizeof (BS))); + } +}; + +class zp : xg { +public: + __attribute__ ((always_inline)) zp () + { + hy = xg::fw (); + } + +private: + int *hy; +}; + +void +e5 () +{ + zp ix; +}