Skip to content

Commit

Permalink
PR c++/71442
Browse files Browse the repository at this point in the history
	* pt.c (tsubst_copy): Only set TREE_USED on DECLs.

	* g++.dg/cpp0x/Wunused-variable-1.C: New test.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-5-branch@237234 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
jakub committed Jun 8, 2016
1 parent 9300ead commit 79a00c2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
5 changes: 5 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2016-06-08 Jakub Jelinek <jakub@redhat.com>

PR c++/71442
* pt.c (tsubst_copy): Only set TREE_USED on DECLs.

2016-06-03 Release Manager

* GCC 5.4.0 released.
Expand Down
3 changes: 2 additions & 1 deletion gcc/cp/pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -13287,7 +13287,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)
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2016-06-08 Jakub Jelinek <jakub@redhat.com>

PR c++/71442
* g++.dg/cpp0x/Wunused-variable-1.C: New test.

2016-06-07 Uros Bizjak <ubizjak@gmail.com>

PR target/71389
Expand Down
37 changes: 37 additions & 0 deletions gcc/testsuite/g++.dg/cpp0x/Wunused-variable-1.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// PR c++/71442
// { dg-do compile { target c++11 } }
// { dg-options "-Wunused-variable" }

struct C
{
template<typename... Ts>
int operator()(Ts &&...)
{
return sizeof...(Ts);
}
};

int
foo ()
{
C {} (1, 1L, 1LL, 1.0);
}

template<int N>
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> ();
}

0 comments on commit 79a00c2

Please sign in to comment.