re PR c++/44682 (warning: variable ‘x’ set but not used)

PR c++/44682
	* class.c (build_base_path): If want_pointer, call mark_rvalue_use
	on expr.

	* g++.dg/warn/Wunused-var-14.C: New test.

From-SVN: r161511
This commit is contained in:
Jakub Jelinek 2010-06-28 22:12:31 +02:00 committed by Jakub Jelinek
parent 83377c6a3f
commit 7fd7263dc9
4 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2010-06-28 Jakub Jelinek <jakub@redhat.com>
PR c++/44682
* class.c (build_base_path): If want_pointer, call mark_rvalue_use
on expr.
2010-06-28 Steven Bosscher <steven@gcc.gnu.org>
* init.c: Do not include except.h.

View File

@ -283,6 +283,8 @@ build_base_path (enum tree_code code,
if (!want_pointer)
/* This must happen before the call to save_expr. */
expr = cp_build_unary_op (ADDR_EXPR, expr, 0, tf_warning_or_error);
else
mark_rvalue_use (expr);
offset = BINFO_OFFSET (binfo);
fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull);

View File

@ -1,3 +1,8 @@
2010-06-28 Jakub Jelinek <jakub@redhat.com>
PR c++/44682
* g++.dg/warn/Wunused-var-14.C: New test.
2010-06-28 Tobias Burnus <burnus@net-b.de>
PR fortran/43298

View File

@ -0,0 +1,17 @@
// PR c++/44682
// { dg-do compile }
// { dg-options "-Wunused" }
struct S { virtual ~S () {} };
struct T { virtual ~T () {} };
struct U : S, T {};
void f (U &);
void
g (void *v)
{
T *t = static_cast <T *> (v);
U *u = static_cast <U *> (t);
f (*u);
}