Mark DECL_SET_IS_OPERATOR_DELETE for user-provided delete operators.

2019-08-02  Martin Liska  <mliska@suse.cz>

	* decl.c (grok_op_properties):
	Mark DECL_SET_IS_OPERATOR_DELETE for user-provided delete operators.
2019-08-02  Martin Liska  <mliska@suse.cz>

	* g++.dg/cpp1y/new2.C: New test.

From-SVN: r273996
This commit is contained in:
Martin Liska 2019-08-02 08:07:15 +02:00 committed by Martin Liska
parent 5bae71d1aa
commit 8e8e7af514
4 changed files with 52 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2019-08-02 Martin Liska <mliska@suse.cz>
* decl.c (grok_op_properties):
Mark DECL_SET_IS_OPERATOR_DELETE for user-provided delete operators.
2019-08-01 Martin Sebor <msebor@redhat.com>
PR c++/90947

View File

@ -13678,7 +13678,10 @@ grok_op_properties (tree decl, bool complain)
}
if (op_flags & OVL_OP_FLAG_DELETE)
coerce_delete_type (decl, loc);
{
DECL_SET_IS_OPERATOR_DELETE (decl, true);
coerce_delete_type (decl, loc);
}
else
{
DECL_SET_IS_OPERATOR_NEW (decl, true);

View File

@ -1,3 +1,7 @@
2019-08-02 Martin Liska <mliska@suse.cz>
* g++.dg/cpp1y/new2.C: New test.
2019-08-02 Senthil Kumar Selvaraj <senthilkumar.selvaraj@microchip.com>
* gcc.dg/torture/ssa-fre-6.c: Add dg-require-effective-target int32.

View File

@ -0,0 +1,39 @@
/* { dg-do compile } */
/* { dg-options "-O2 -std=c++17 -fdump-tree-cddce-details" } */
#include <cstdio>
#include <cstdlib>
#include <new>
void* operator new(std::size_t sz)
{
std::printf("global op new called, size = %zu\n", sz);
void *ptr = std::malloc(sz);
if (ptr)
return ptr;
else
throw std::bad_alloc{};
}
void operator delete(void* ptr) noexcept
{
std::puts("global op delete called");
std::free(ptr);
}
void
new_primitive_load() {
int *x = new int;
int tmp = *x;
delete x;
}
void
new_array_load() {
int *x = new int[10];
int tmp = x[4];
delete [] x;
}
/* { dg-final { scan-tree-dump-times "Deleting : _\\d+ = operator new" 2 "cddce1"} } */
/* { dg-final { scan-tree-dump-times "Deleting : operator delete" 2 "cddce1"} } */