+2019-08-05 Martin Liska <mliska@suse.cz>
+
+ PR c++/91334
+ * tree-ssa-dce.c (propagate_necessity): Handle new operators
+ with not arguments.
+ (eliminate_unnecessary_stmts): Likewise.
+
2019-08-05 Richard Biener <rguenther@suse.de>
PR middle-end/91169
--- /dev/null
+/* PR c++/91334. */
+/* { dg-do compile } */
+
+#include <new>
+#include <stdlib.h>
+
+struct A {
+ A() { throw 0; }
+ void* operator new(size_t size, double = 0.0) { return ::operator new(size);}
+ void operator delete(void* p, double) { exit(0); }
+ void operator delete(void* p) { abort(); }
+};
+
+int main() { try { new A; } catch(...) {} }
if (is_delete_operator
|| gimple_call_builtin_p (stmt, BUILT_IN_FREE))
{
+ /* It can happen that a user delete operator has the pointer
+ argument optimized out already. */
+ if (gimple_call_num_args (stmt) == 0)
+ continue;
+
tree ptr = gimple_call_arg (stmt, 0);
gimple *def_stmt;
tree def_callee;
|| (is_gimple_call (stmt)
&& gimple_call_operator_delete_p (as_a <gcall *> (stmt)))))
{
- tree ptr = gimple_call_arg (stmt, 0);
- if (TREE_CODE (ptr) == SSA_NAME)
+ /* It can happen that a user delete operator has the pointer
+ argument optimized out already. */
+ if (gimple_call_num_args (stmt) > 0)
{
- gimple *def_stmt = SSA_NAME_DEF_STMT (ptr);
- if (!gimple_nop_p (def_stmt)
- && !gimple_plf (def_stmt, STMT_NECESSARY))
- gimple_set_plf (stmt, STMT_NECESSARY, false);
+ tree ptr = gimple_call_arg (stmt, 0);
+ if (TREE_CODE (ptr) == SSA_NAME)
+ {
+ gimple *def_stmt = SSA_NAME_DEF_STMT (ptr);
+ if (!gimple_nop_p (def_stmt)
+ && !gimple_plf (def_stmt, STMT_NECESSARY))
+ gimple_set_plf (stmt, STMT_NECESSARY, false);
+ }
}
}