@@ -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))
{
@@ -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;
+}