[Bug c++/8045] Missing "unused variable" warning

manu at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Jul 8 22:09:00 GMT 2009



------- Comment #5 from manu at gcc dot gnu dot org  2009-07-08 22:08 -------
Are there some cases where a declaration such T x = y can be considered an use
of 'x' by itself?

The following patch warns for this, but it also produces warnings for some
testcases in the testsuite.

Index: gcc/cp/init.c
===================================================================
--- gcc/cp/init.c       (revision 149319)
+++ gcc/cp/init.c       (working copy)
@@ -1261,11 +1261,11 @@ build_aggr_init (tree exp, tree init, in
       if (init)
        TREE_TYPE (init) = itype;
       return stmt_expr;
     }

-  if (TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == PARM_DECL)
+  if (TREE_CODE (exp) == PARM_DECL)
     /* Just know that we've seen something for this node.  */
     TREE_USED (exp) = 1;

   is_global = begin_init_stmts (&stmt_expr, &compound_stmt);
   destroy_temps = stmts_are_full_exprs_p ();


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.4.0
   Last reconfirmed|2005-12-11 23:03:44         |2009-07-08 22:08:57
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8045



More information about the Gcc-bugs mailing list