[Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning
--- Comment #4 from jakub at gcc dot gnu dot org 2010-06-24 11:00 --- Fixed. -- jakub at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44412
[Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning
--- Comment #1 from jakub at gcc dot gnu dot org 2010-06-04 12:03 --- More complete testcase: // 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; s.c = 6;// { dg-warning set but not used } } int f4 () { S s; s.c = 6; return s.c; } Guess we should mark the object through which a static data member is accessed, because that access already marks the object as TREE_USED, yet it is not a set of the object. Not sure where to do that though. Calling methods or static methods apparently is handled already, in both cases build_new_method_call - build_this - cp_build_unary_op ADDR_EXPR - mark_lvalue_use - mark_exp_read takes care of it: // 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 (); } -- jakub at gcc dot gnu dot org changed: What|Removed |Added CC||dodji at gcc dot gnu dot ||org, jason at gcc dot gnu ||dot org Summary|Another bogus set-but-not- |[4.6 Regression] Another |used warning|bogus set-but-not-used ||warning Target Milestone|--- |4.6.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44412
[Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning
--- Comment #2 from jakub at gcc dot gnu dot org 2010-06-04 14:12 --- Created an attachment (id=20838) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20838action=view) gcc46-pr44412.patch Untested patch. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44412
[Bug c++/44412] [4.6 Regression] Another bogus set-but-not-used warning
--- Comment #3 from jakub at gcc dot gnu dot org 2010-06-04 18:46 --- Subject: Bug 44412 Author: jakub Date: Fri Jun 4 18:45:07 2010 New Revision: 160290 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=160290 Log: 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. Added: trunk/gcc/testsuite/g++.dg/warn/Wunused-var-10.C trunk/gcc/testsuite/g++.dg/warn/Wunused-var-11.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44412