From: Mark Mitchell Date: Tue, 7 Jan 2003 02:38:32 +0000 (+0000) Subject: re PR c++/9165 (false "defined but not used" warnings) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c10cdb3d75dcd62c2eaf97fe805fe642f9d21585;p=gcc.git re PR c++/9165 (false "defined but not used" warnings) PR c++/9165 * decl2.c (build_cleanup): Mark the object as used. PR c++/9165 * g++.dg/warn/Wunused-3.C: New test. From-SVN: r60972 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6e5e223d905..2ebbbf72f9c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2003-01-06 Mark Mitchell + PR c++/9165 + * decl2.c (build_cleanup): Mark the object as used. + * pt.c (retrieve_local_specialization): Revert 2003-01-05 change. (hash_local_specialization): New function. (register_local_specialization): Revert 2003-01-05 change. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 85b6a2ede38..6363007b4ef 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1865,12 +1865,24 @@ import_export_tinfo (tree decl, tree type, bool is_in_library) DECL_INTERFACE_KNOWN (decl) = 1; } +/* Return an expression that performs the destruction of DECL, which + must be a VAR_DECL whose type has a non-trivial destructor, or is + an array whose (innermost) elements have a non-trivial destructor. */ + tree build_cleanup (tree decl) { tree temp; tree type = TREE_TYPE (decl); + /* This function should only be called for declarations that really + require cleanups. */ + my_friendly_assert (!TYPE_HAS_TRIVIAL_DESTRUCTOR (type), 20030106); + + /* Treat all objects with destructors as used; the destructor may do + something substantive. */ + mark_used (decl); + if (TREE_CODE (type) == ARRAY_TYPE) temp = decl; else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8b4fce3179c..2ae70604887 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,9 @@ 2003-01-06 Mark Mitchell - * testsuite/g++.dg/abi/bitfield9.C: New test. + PR c++/9165 + * g++.dg/warn/Wunused-3.C: New test. + + * g++.dg/abi/bitfield9.C: New test. PR c++/9189 * g++.dg/parse/defarg3.C: New test. diff --git a/gcc/testsuite/g++.dg/warn/Wunused-3.C b/gcc/testsuite/g++.dg/warn/Wunused-3.C new file mode 100644 index 00000000000..31009094352 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-3.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options "-Wunused -O" } + +void do_cleanups(); + +class Cleanup { +public: + ~Cleanup() { do_cleanups();} +}; + +static Cleanup dummy;