* typeck.c (build_class_member_access_expr): Call mark_exp_read
on object for static data members.
* g++.dg/warn/Wunused-var-10.C: New test.
* g++.dg/warn/Wunused-var-11.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160290
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-06-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/44412
+ * typeck.c (build_class_member_access_expr): Call mark_exp_read
+ on object for static data members.
+
2010-06-04 Jakub Jelinek <jakub@redhat.com>
Jason Merrill <jason@redhat.com>
{
/* A static data member. */
result = member;
+ mark_exp_read (object);
/* If OBJECT has side-effects, they are supposed to occur. */
if (TREE_SIDE_EFFECTS (object))
result = build2 (COMPOUND_EXPR, TREE_TYPE (result), object, result);
2010-06-04 Jakub Jelinek <jakub@redhat.com>
+ PR c++/44412
+ * g++.dg/warn/Wunused-var-10.C: New test.
+ * g++.dg/warn/Wunused-var-11.C: New test.
+
PR c++/44362
* c-c++-common/Wunused-var-10.c: New test.
--- /dev/null
+// PR c++/44412
+// { dg-do compile }
+// { dg-options "-Wunused" }
+
+struct S
+{
+ static const int a = 3;
+ static int b;
+ int c;
+};
+
+const int S::a;
+int S::b = 4;
+
+int
+f1 ()
+{
+ S s;
+ return s.a;
+}
+
+int
+f2 ()
+{
+ S s;
+ return s.b;
+}
+
+void
+f3 ()
+{
+ S s; // { dg-warning "set but not used" }
+ s.c = 6;
+}
+
+int
+f4 ()
+{
+ S s;
+ s.c = 6;
+ return s.c;
+}
--- /dev/null
+// PR c++/44412
+// { dg-do compile }
+// { dg-options "-Wunused" }
+
+struct S
+{
+ int foo ();
+ static int bar ();
+};
+
+int S::foo ()
+{
+ return 5;
+}
+
+int S::bar ()
+{
+ return 6;
+}
+
+int
+f1 ()
+{
+ S s;
+ return s.foo ();
+}
+
+int
+f2 ()
+{
+ S s;
+ return s.bar ();
+}