re PR c++/44619 (Bogus set but not used warning when using pointer to member operators)
authorJakub Jelinek <jakub@redhat.com>
Tue, 22 Jun 2010 20:50:03 +0000 (22:50 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 22 Jun 2010 20:50:03 +0000 (22:50 +0200)
PR c++/44619
* typeck2.c (build_m_component_ref): Call mark_lvalue_use on
datum and mark_rvalue_use on component.

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

From-SVN: r161230

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

index 31479189e88cbe8e6b60c03d49bb347258d96c7f..95a7138e67348fb9fa29cb4e354e7662b27b0d49 100644 (file)
@@ -1,5 +1,9 @@
 2010-06-22  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/44619
+       * typeck2.c (build_m_component_ref): Call mark_lvalue_use on
+       datum and mark_rvalue_use on component.
+
        PR c++/44627
        * error.c (dump_expr): Don't look at CALL_EXPR_ARG (t, 0) if
        the CALL_EXPR has no arguments.
index 3d48c22faab4575a3ee6358a5ad18498013ba2b4..9526aba0666977912afcdf69b1c16b64daa65984 100644 (file)
@@ -1478,6 +1478,9 @@ build_m_component_ref (tree datum, tree component)
   if (error_operand_p (datum) || error_operand_p (component))
     return error_mark_node;
 
+  mark_lvalue_use (datum);
+  mark_rvalue_use (component);
+
   ptrmem_type = TREE_TYPE (component);
   if (!TYPE_PTR_TO_MEMBER_P (ptrmem_type))
     {
index a954c9bbe23c965d98585f8824e474231943d0a7..cfaa6cf65d77c1f1db032a4ca324c1f59f3d6830 100644 (file)
@@ -1,5 +1,8 @@
 2010-06-22  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/44619
+       * g++.dg/warn/Wunused-var-13.C: New test.
+
        PR c++/44627
        * g++.dg/diagnostic/method1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-13.C b/gcc/testsuite/g++.dg/warn/Wunused-var-13.C
new file mode 100644 (file)
index 0000000..43df81d
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/44619
+// { dg-do compile }
+// { dg-options "-Wunused -W" }
+
+struct S { int x, y; };
+
+int
+f1 ()
+{
+  struct S p;
+  int S::*q = &S::x;
+  p.*q = 5;
+  return p.*q;
+}
+
+int
+f2 (struct S *p, int S::*q)
+{
+  struct S *r = p;
+  int S::*s = q;
+  return r->*s;
+}