diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2012-08-20 17:38:53 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2012-08-20 17:38:53 +0000 |
commit | d952d7ad3121f9119b1b842efcd884233854c599 (patch) | |
tree | de8dafb6dc8147a1b8be002129bd10f6338607e8 /gcc/cp | |
parent | d88513eaf77e9dd8bcc5a662518d18bd350e383c (diff) | |
download | gcc-d952d7ad3121f9119b1b842efcd884233854c599.zip gcc-d952d7ad3121f9119b1b842efcd884233854c599.tar.gz gcc-d952d7ad3121f9119b1b842efcd884233854c599.tar.bz2 |
re PR c++/10416 ('unused variable' warning ignores ctor/dtor side-effects)
/cp
2012-08-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/10416
* decl.c (poplevel): Check TYPE_HAS_NONTRIVIAL_DESTRUCTOR for
Wunused_variable too.
/testsuite
2012-08-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/10416
* g++.dg/warn/Wunused-var-17.C: New.
From-SVN: r190538
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 10 |
2 files changed, 11 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5c4f362..2ac0deb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-08-20 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/10416 + * decl.c (poplevel): Check TYPE_HAS_NONTRIVIAL_DESTRUCTOR for + Wunused_variable too. + 2012-08-20 Diego Novillo <dnovillo@google.com> * decl.c (poplevel): Start TV_NAME_LOOKUP conditionally. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0dad597..365ca94 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -621,16 +621,16 @@ poplevel (int keep, int reverse, int functionbody) if (TREE_CODE (decl) == VAR_DECL && (! TREE_USED (decl) || !DECL_READ_P (decl)) && ! DECL_IN_SYSTEM_HEADER (decl) - && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) + && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl) + && TREE_TYPE (decl) != error_mark_node + && (!CLASS_TYPE_P (TREE_TYPE (decl)) + || !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))) { if (! TREE_USED (decl)) warning (OPT_Wunused_variable, "unused variable %q+D", decl); else if (DECL_CONTEXT (decl) == current_function_decl - && TREE_TYPE (decl) != error_mark_node && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE - && errorcount == unused_but_set_errorcount - && (!CLASS_TYPE_P (TREE_TYPE (decl)) - || !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))) + && errorcount == unused_but_set_errorcount) { warning (OPT_Wunused_but_set_variable, "variable %q+D set but not used", decl); |