This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/31795] -Wunused should warn about variables set but never read
- From: "aldot at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 May 2007 10:16:08 -0000
- Subject: [Bug middle-end/31795] -Wunused should warn about variables set but never read
- References: <bug-31795-578@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from aldot at gcc dot gnu dot org 2007-05-03 11:16 -------
Maybe related to 30438, 18624
I started to do
Index: gcc/tree.h
===================================================================
--- gcc/tree.h (revision 124373)
+++ gcc/tree.h (working copy)
@@ -364,7 +364,7 @@ struct tree_common GTY(())
unsigned asm_written_flag: 1;
unsigned nowarning_flag : 1;
- unsigned used_flag : 1;
+ unsigned used_flag : 2;
unsigned nothrow_flag : 1;
unsigned static_flag : 1;
unsigned public_flag : 1;
@@ -1175,6 +1175,7 @@ extern void omp_clause_range_check_faile
Nonzero in an expr node means inhibit warning if value is unused.
In IDENTIFIER_NODEs, this means that some extern decl for this name
was used.
+ 1 denotes set but never used, 2 is actually used.
In a BLOCK, this means that the block contains variables that are used. */
#define TREE_USED(NODE) ((NODE)->common.used_flag)
It's a bit tricky to get this right for -O0 (-O1 and above is much easier) i
think.
--
aldot at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |aldot at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31795