Commit e3e9e8ca by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/79746 (Confusing -Wunused-but-set-parameter warning with virtual inheritance)

	PR c++/79746
	* init.c (emit_mem_initializers): When not constructing vbases of
	abstract classes, mark arguments as read for
	-Wunused-but-set-parameter.

	* g++.dg/warn/Wunused-parm-9.C: New test.

From-SVN: r245802
parent 0f3f4ffe
2017-03-01 Jakub Jelinek <jakub@redhat.com>
PR c++/79746
* init.c (emit_mem_initializers): When not constructing vbases of
abstract classes, mark arguments as read for
-Wunused-but-set-parameter.
2017-02-28 Jason Merrill <jason@redhat.com>
Class template argument deduction refinements
......
......@@ -1217,6 +1217,12 @@ emit_mem_initializers (tree mem_inits)
/* C++14 DR1658 Means we do not have to construct vbases of
abstract classes. */
construct_virtual_base (subobject, arguments);
else
/* When not constructing vbases of abstract classes, at least mark
the arguments expressions as read to avoid
-Wunused-but-set-parameter false positives. */
for (tree arg = arguments; arg; arg = TREE_CHAIN (arg))
mark_exp_read (TREE_VALUE (arg));
if (inherited_base)
pop_deferring_access_checks ();
......
2017-03-01 Jakub Jelinek <jakub@redhat.com>
PR c++/79746
* g++.dg/warn/Wunused-parm-9.C: New test.
PR tree-optimization/79734
* g++.dg/opt/pr79734.C: New test.
......
// PR c++/79746
// { dg-do compile }
// { dg-options "-Wunused-but-set-parameter" }
struct A {
A (const char *x) : a(x) {} // { dg-bogus "set but not used" }
virtual int foo () = 0;
const char *a;
};
struct B : public virtual A {
B (const char *x) : A(x) {} // { dg-bogus "set but not used" }
};
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