From 2ef16b6eb25b29ae3790ab39162d1d6df3ccf284 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 8 Jun 2016 19:57:30 +0200 Subject: [PATCH] re PR c++/71442 (r232569 breaks -Wunused-*) PR c++/71442 * pt.c (tsubst_copy): Only set TREE_USED on DECLs. * g++.dg/cpp0x/Wunused-variable-1.C: New test. From-SVN: r237232 --- gcc/cp/ChangeLog | 5 +++ gcc/cp/pt.c | 3 +- gcc/testsuite/ChangeLog | 5 +++ .../g++.dg/cpp0x/Wunused-variable-1.C | 37 +++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 86dddd210d7..1627fd214c0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2016-06-08 Jakub Jelinek + + PR c++/71442 + * pt.c (tsubst_copy): Only set TREE_USED on DECLs. + 2016-06-06 Jakub Jelinek Patrick Palka diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 64fef68c9e3..4ccdd45b73b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14160,7 +14160,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) len = TREE_VEC_LENGTH (expanded); /* Set TREE_USED for the benefit of -Wunused. */ for (int i = 0; i < len; i++) - TREE_USED (TREE_VEC_ELT (expanded, i)) = true; + if (DECL_P (TREE_VEC_ELT (expanded, i))) + TREE_USED (TREE_VEC_ELT (expanded, i)) = true; } if (expanded == error_mark_node) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 93062fd78ef..2f3e4e16766 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-08 Jakub Jelinek + + PR c++/71442 + * g++.dg/cpp0x/Wunused-variable-1.C: New test. + 2016-06-08 Alan Lawrence * gcc.target/aarch64/aapcs64/aapcs64.exp: Also execute rec_*.c diff --git a/gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C b/gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C new file mode 100644 index 00000000000..39592b26a58 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C @@ -0,0 +1,37 @@ +// PR c++/71442 +// { dg-do compile { target c++11 } } +// { dg-options "-Wunused-variable" } + +struct C +{ + template + int operator()(Ts &&...) + { + return sizeof...(Ts); + } +}; + +int +foo () +{ + C {} (1, 1L, 1LL, 1.0); +} + +template +void +bar () +{ + char a; // { dg-warning "unused variable" } + short b; // { dg-warning "unused variable" } + int c; // { dg-warning "unused variable" } + long d; // { dg-warning "unused variable" } + long long e; // { dg-warning "unused variable" } + float f; // { dg-warning "unused variable" } + double g; // { dg-warning "unused variable" } +} + +void +baz () +{ + bar <0> (); +} -- 2.30.2