From 458cd4c394dec8e42ff75ecd5212461408962203 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Fri, 18 Dec 2015 02:25:39 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/init.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr68831.C | 9 +++++++++ 4 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/pr68831.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4c7dc78a197..89c0a198a82 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2015-12-18 Patrick Palka + + 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 PR c++/67550 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index b7f10a10e67..1d5cc65ef2d 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -4449,6 +4449,7 @@ build_delete (tree otype, tree addr, special_function_kind auto_delete, else { /* Handle deleting a null pointer. */ + warning_sentinel s (warn_address); ifexp = fold (cp_build_binary_op (input_location, NE_EXPR, addr, nullptr_node, complain)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index baa159d3811..f991a699869 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-18 Patrick Palka + + PR c++/68831 + * g++.dg/pr68831.C: New test. + 2015-12-17 Jeff Law * gcc.dg/tree-ssa/split-path-1.c: Explicitly ask for path diff --git a/gcc/testsuite/g++.dg/pr68831.C b/gcc/testsuite/g++.dg/pr68831.C new file mode 100644 index 00000000000..2a354a57bb1 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr68831.C @@ -0,0 +1,9 @@ +// PR c++/68831 +// { dg-options "-Waddress" } + +class DenseMap { +public: + ~DenseMap(); +}; +extern const DenseMap &GCMap; +void foo() { delete &GCMap; } -- 2.30.2