Commit 38a979f2 by Marek Polacek Committed by Marek Polacek

re PR c++/68965 (`-Wunused-parameter` is reported in variadic lambda or function…

re PR c++/68965 (`-Wunused-parameter` is reported in variadic lambda or function using sizeof...(xs))

	PR c++/68965
	* pt.c (tsubst_copy): Mark elements in expanded vector as used.

	* g++.dg/cpp1y/parameter-pack-1.C: New test.
	* g++.dg/cpp1y/parameter-pack-2.C: New test.

From-SVN: r232569
parent f4d09712
......@@ -6,6 +6,9 @@
* cp-tree.h (clear_cv_cache, clear_fold_cache): Declare.
* decl.c (finish_enum_value_list): Call them.
PR c++/68965
* pt.c (tsubst_copy): Mark elements in expanded vector as used.
2016-01-18 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/11858
......
......@@ -14010,7 +14010,12 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
--c_inhibit_evaluation_warnings;
if (TREE_CODE (expanded) == TREE_VEC)
{
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 (expanded == error_mark_node)
return error_mark_node;
......
2016-01-19 Marek Polacek <polacek@redhat.com>
PR c++/68965
* g++.dg/cpp1y/parameter-pack-1.C: New test.
* g++.dg/cpp1y/parameter-pack-2.C: New test.
2016-01-19 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/69135
......
// PR c++/68965
// { dg-do compile { target c++14 } }
// { dg-options "-Wall -Wextra" }
auto count = [](auto&&... xs)
{
return sizeof...(xs);
};
struct count_struct
{
template<typename... Ts>
auto operator()(Ts&&... xs)
{
return sizeof...(xs);
}
};
int main()
{
count(1,2,3);
count_struct{}(1,2,3);
}
// PR c++/68965
// { dg-do compile { target c++14 } }
// { dg-options "-Wall -Wextra" }
auto count = [](auto&&... xs) // { dg-warning "unused parameter" }
{
};
struct count_struct
{
template<typename... Ts>
auto operator()(Ts&&... xs) // { dg-warning "unused parameter" }
{
}
};
int main()
{
count(1,2,3);
count_struct{}(1,2,3);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment