OSDN Git Service

PR c++/44682
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Jun 2010 20:12:31 +0000 (20:12 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Jun 2010 20:12:31 +0000 (20:12 +0000)
* class.c (build_base_path): If want_pointer, call mark_rvalue_use
on expr.

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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161511 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wunused-var-14.C [new file with mode: 0644]

index 3b5f1bd..a7df7b8 100644 (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.
index f945923..51f749f 100644 (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);
index 5f0ea3f..e355894 100644 (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
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-14.C b/gcc/testsuite/g++.dg/warn/Wunused-var-14.C
new file mode 100644 (file)
index 0000000..a552b56
--- /dev/null
@@ -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);
+}