Commit 2aa64966 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/44412 (Another bogus set-but-not-used warning)

	PR c++/44412
	* 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.

From-SVN: r160290
parent 16c82123
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>
PR c++/44362
......
......@@ -2229,6 +2229,7 @@ build_class_member_access_expr (tree object, tree member,
{
/* 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.
......
// 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;
}
// 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 ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment