This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.


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

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #3 from Dodji Seketeli <dodji at gcc dot gnu.org> 2012-09-20 11:27:19 UTC ---
The 'unused' attribute is applied to its appertaining entity only at
instantiation time.  As a result, TREE_USED is not set on the entity before
instantiation.

But then maybe_warn_unused_local_typedefs checks for TREE_USED at compile time,
and wrongly emits the warning.

I am testing this patch that tests for the syntactic presence of the unused
attribute:


diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 6de2f1c..36c4aa6 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -10899,7 +10899,8 @@ maybe_warn_unused_local_typedefs (void)
       && errorcount == unused_local_typedefs_warn_count)
     {
       FOR_EACH_VEC_ELT (tree, l->local_typedefs, i, decl)
-       if (!TREE_USED (decl))
+       if (!TREE_USED (decl)
+           && !lookup_attribute_spec (get_identifier ("unused")))
          warning_at (DECL_SOURCE_LOCATION (decl),
                      OPT_Wunused_local_typedefs,
                      "typedef %qD locally defined but not used", decl);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]