On Wed, Dec 09, 2020 at 10:50:22AM +0100, David Brown wrote:
> I'd say that it makes sense to have such a warning as a natural
> enhancement to the existing "-Wunused-but-set-variable" warning.  But I

That is not really possible.
The -Wunused-but-set-* warning works by having two bits for the DECL,
TREE_USED and DECL_READ_P, where any uses mark the var TREE_USED and
(conservatively) what can read the value marks it DECL_READ_P
and -Wunused-but-set-* is then variables that are TREE_USED and
!DECL_READ_P.  All this needs to be done early in the FE.
For the static vars, the optimization to remove them altogether is done
much later, and at that point the compiler doesn't know if it isn't used
because all the reads in the program have been optimized away vs. there were
none.

        Jakub

Reply via email to