[C++ PATCH] Fix -Wunused-but-set-* bug with static data members (PR c++/44412)
Jakub Jelinek
jakub@redhat.com
Fri Jun 4 18:38:00 GMT 2010
On Fri, Jun 04, 2010 at 02:20:09PM -0400, Jason Merrill wrote:
> On 06/04/2010 12:54 PM, Jakub Jelinek wrote:
> > PR c++/44412
> > * typeck.c (build_class_member_access_expr): Call mark_exp_read
> > on object for static data members.
>
> This seems wrong; the context in which the class member access
> appears should be marking it appropriately. Why isn't it marked in
> 'return s.b' when it gets converted to the return type?
The problem is that the object, if there are no side-effects in it,
doesn't appear any longer in the build_class_member_access_expr
result - for static data members that function returns the TREE_STATIC
VAR_DECL (with DECL_CONTEXT of the class), not a COMPONENT_REF, so when
the return argument is marked, it marks the TREE_STATIC VAR_DECL.
Jakub
More information about the Gcc-patches
mailing list