public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix -Wunused-but-set-variable warnings on .*/->* operands (PR c++/44619)
@ 2010-06-22 14:56 Jakub Jelinek
  2010-06-22 18:31 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2010-06-22 14:56 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

Hi!

.* and ->* operands aren't marked as read, the following patch fixes it.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Or should that be mark_rvalue_use (or something else)?

2010-06-22  Jakub Jelinek  <jakub@redhat.com>

	PR c++/44619
	* typeck2.c (build_m_component_ref): Call mark_exp_read on
	datum and component.

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

--- gcc/cp/typeck2.c.jj	2010-06-20 16:36:49.000000000 +0200
+++ gcc/cp/typeck2.c	2010-06-22 12:28:34.000000000 +0200
@@ -1478,6 +1478,9 @@ build_m_component_ref (tree datum, tree 
   if (error_operand_p (datum) || error_operand_p (component))
     return error_mark_node;
 
+  mark_exp_read (datum);
+  mark_exp_read (component);
+
   ptrmem_type = TREE_TYPE (component);
   if (!TYPE_PTR_TO_MEMBER_P (ptrmem_type))
     {
--- gcc/testsuite/g++.dg/warn/Wunused-var-13.C.jj	2010-06-22 12:30:04.000000000 +0200
+++ gcc/testsuite/g++.dg/warn/Wunused-var-13.C	2010-06-22 08:20:23.000000000 +0200
@@ -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;
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ PATCH] Fix -Wunused-but-set-variable warnings on .*/->* operands (PR c++/44619)
  2010-06-22 14:56 [C++ PATCH] Fix -Wunused-but-set-variable warnings on .*/->* operands (PR c++/44619) Jakub Jelinek
@ 2010-06-22 18:31 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2010-06-22 18:31 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches List

On 06/22/2010 09:52 AM, Jakub Jelinek wrote:
> +  mark_exp_read (datum);
> +  mark_exp_read (component);

The datum is used as an lvalue, and the component as an rvalue.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-22 18:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-22 14:56 [C++ PATCH] Fix -Wunused-but-set-variable warnings on .*/->* operands (PR c++/44619) Jakub Jelinek
2010-06-22 18:31 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).