This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] restore -Wunused-variable on a typedef'd variable in a function template (PR 79548)
- From: Jason Merrill <jason at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 21 Feb 2017 10:08:47 -0800
- Subject: Re: [PATCH] restore -Wunused-variable on a typedef'd variable in a function template (PR 79548)
- Authentication-results: sourceware.org; auth=none
- References: <28dd4f25-b208-52af-af1e-7bc5e36db557@gmail.com>
On 02/17/2017 05:07 PM, Martin Sebor wrote:
* decl.c (poplevel): Avoid diagnosing entities declared with
attribute unused.
This change is OK.
(initialize_local_var): Do not consider the type of a variable
when determining whether or not it's used.
This is not; the documentation for attribute unused says,
When attached to a type (including a @code{union} or a @code{struct}),
this attribute means that variables of that type are meant to appear
possibly unused. GCC does not produce a warning for any variables of
that type, even if the variable appears to do nothing. This is often
the case with lock or thread classes, which are usually defined and then
not referenced, but contain constructors and destructors that have
nontrivial bookkeeping functions.
So a TREE_USED type should imply TREE_USED on variables of that type.
Jason