Fix PR c++/68831 (superfluous -Waddress warning for C++ delete)
authorPatrick Palka <ppalka@gcc.gnu.org>
Fri, 18 Dec 2015 02:25:39 +0000 (02:25 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Fri, 18 Dec 2015 02:25:39 +0000 (02:25 +0000)
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
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr68831.C [new file with mode: 0644]

index 4c7dc78a19726d11c1cb0d1880d770237fa4fee7..89c0a198a8280d2f1fdbeafb74d5265460e3ca1e 100644 (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>
 
        PR c++/67550
index b7f10a10e67516ad3746477e6fbbc2b6c9da7c62..1d5cc65ef2d195d525bb575c43193927f325a6c6 100644 (file)
@@ -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));
index baa159d381104eaf5a38bb0f910bb26f3f3a9c85..f991a69986973fdb8a8303cb6f407d544812f01e 100644 (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>
 
        * 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 (file)
index 0000000..2a354a5
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/68831
+// { dg-options "-Waddress" }
+
+class DenseMap {
+public:
+  ~DenseMap();
+};
+extern const DenseMap &GCMap;
+void foo() { delete &GCMap; }