Fix PR c++/68831 (superfluous -Waddress warning for C++ delete)

gcc/cp/ChangeLog:

	PR c++/68831
	* init.c (build_delete): Use a warning sentinel to disable
	-Waddress warnings when building the conditional that tests
	if the operand is NULL.

gcc/testsuite/ChangeLog:

	PR c++/68831
	* g++.dg/pr68831.C: New test.

From-SVN: r231798
This commit is contained in:
Patrick Palka 2015-12-18 02:25:39 +00:00
parent 474c8a0757
commit 458cd4c394
4 changed files with 22 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2015-12-18 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/68831
* init.c (build_delete): Use a warning sentinel to disable
-Waddress warnings when building the conditional that tests
if the operand is NULL.
2015-12-17 Jason Merrill <jason@redhat.com> 2015-12-17 Jason Merrill <jason@redhat.com>
PR c++/67550 PR c++/67550

View file

@ -4449,6 +4449,7 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete,
else else
{ {
/* Handle deleting a null pointer. */ /* Handle deleting a null pointer. */
warning_sentinel s (warn_address);
ifexp = fold (cp_build_binary_op (input_location, ifexp = fold (cp_build_binary_op (input_location,
NE_EXPR, addr, nullptr_node, NE_EXPR, addr, nullptr_node,
complain)); complain));

View file

@ -1,3 +1,8 @@
2015-12-18 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/68831
* g++.dg/pr68831.C: New test.
2015-12-17 Jeff Law <law@redhat.com> 2015-12-17 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/split-path-1.c: Explicitly ask for path * gcc.dg/tree-ssa/split-path-1.c: Explicitly ask for path

View file

@ -0,0 +1,9 @@
// PR c++/68831
// { dg-options "-Waddress" }
class DenseMap {
public:
~DenseMap();
};
extern const DenseMap &GCMap;
void foo() { delete &GCMap; }