]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/59315
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 29 Jan 2014 13:40:49 +0000 (13:40 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 29 Jan 2014 13:40:49 +0000 (13:40 +0000)
* decl.c (cxx_maybe_build_cleanup): Call mark_used.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207236 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/warn/Wunused-3.C

index 3ed0ef8da7fc07249afcde1df02ea75c9935e16e..f2ff37abb8330db2ee22f0dcd66fac2a42ccf2ac 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-29  Jason Merrill  <jason@redhat.com>
+
+       PR c++/59315
+       * decl.c (cxx_maybe_build_cleanup): Call mark_used.
+
 2014-01-29  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58702
index e14e401d0fce23070f90dd50b1c79c8a8605e9fd..10f4e647cfc63a6dce603a13d33fc87948f6e7ca 100644 (file)
@@ -14353,6 +14353,13 @@ cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain)
      destructor call instead.  */
   if (cleanup != NULL && EXPR_P (cleanup))
     SET_EXPR_LOCATION (cleanup, UNKNOWN_LOCATION);
+
+  if (cleanup
+      && !lookup_attribute ("warn_unused", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
+    /* Treat objects with destructors as used; the destructor may do
+       something substantive.  */
+    mark_used (decl);
+
   return cleanup;
 }
 
index 31009094352b39042218c9339b021abcc2a4d547..2d00dda3faaa53b5f1bd844bebb5c0db83d343e8 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-do compile }
-// { dg-options "-Wunused -O" }
+// { dg-options "-Wunused -O -fno-use-cxa-atexit" }
 
 void do_cleanups();