public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function.
@ 2012-08-25 7:16 flast at flast dot jp
2012-08-25 7:18 ` [Bug c++/54372] " flast at flast dot jp
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: flast at flast dot jp @ 2012-08-25 7:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54372
Bug #: 54372
Summary: __attribute__((unused)) doesn't work with unused local
typedef in template function.
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: flast@flast.jp
GCC 4.8 warns unused local typedefs and can suppres it with
__attribute__((unused)).
However, in member or non-member template function, it doesn't work with
dependent type.
I tested attached code.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
@ 2012-08-25 7:18 ` flast at flast dot jp
2012-09-18 12:39 ` paolo.carlini at oracle dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: flast at flast dot jp @ 2012-08-25 7:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54372
--- Comment #1 from Kohei Takahashi <flast at flast dot jp> 2012-08-25 07:17:49 UTC ---
Created attachment 28082
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28082
test code
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
2012-08-25 7:18 ` [Bug c++/54372] " flast at flast dot jp
@ 2012-09-18 12:39 ` paolo.carlini at oracle dot com
2012-09-20 11:27 ` dodji at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-09-18 12:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54372
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-09-18
CC| |paolo.carlini at oracle dot
| |com
Ever Confirmed|0 |1
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-09-18 12:38:48 UTC ---
Now that the new warning is also in -Wall, it would be nice to fix this.
Note that local variables are already "more than Ok", that is at template
definition time we produce no -Wunused warnings at all even without the
attribute (we only warn at instantiation time): I suppose something similar
should be not too difficult to implement for the new warning too...
Dodji, what do you think?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
2012-08-25 7:18 ` [Bug c++/54372] " flast at flast dot jp
2012-09-18 12:39 ` paolo.carlini at oracle dot com
@ 2012-09-20 11:27 ` dodji at gcc dot gnu.org
2012-09-20 11:59 ` paolo.carlini at oracle dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu.org @ 2012-09-20 11:27 UTC (permalink / raw)
To: gcc-bugs
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);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
` (2 preceding siblings ...)
2012-09-20 11:27 ` dodji at gcc dot gnu.org
@ 2012-09-20 11:59 ` paolo.carlini at oracle dot com
2012-09-20 14:14 ` dodji at seketeli dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-09-20 11:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54372
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-09-20 11:59:11 UTC ---
Ah, ah, thanks, great that the issue seems easy to fix!
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
` (3 preceding siblings ...)
2012-09-20 11:59 ` paolo.carlini at oracle dot com
@ 2012-09-20 14:14 ` dodji at seketeli dot org
2012-09-22 13:07 ` flast at flast dot jp
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: dodji at seketeli dot org @ 2012-09-20 14:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54372
--- Comment #5 from dodji at seketeli dot org <dodji at seketeli dot org> 2012-09-20 14:13:28 UTC ---
A candiate patch was sent to
http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01456.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
` (4 preceding siblings ...)
2012-09-20 14:14 ` dodji at seketeli dot org
@ 2012-09-22 13:07 ` flast at flast dot jp
2012-09-28 13:33 ` dodji at gcc dot gnu.org
2012-09-28 13:36 ` dodji at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: flast at flast dot jp @ 2012-09-22 13:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54372
--- Comment #6 from Kohei Takahashi <flast at flast dot jp> 2012-09-22 13:06:32 UTC ---
I tested on x86_64-linux-gnu and works fine.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
` (5 preceding siblings ...)
2012-09-22 13:07 ` flast at flast dot jp
@ 2012-09-28 13:33 ` dodji at gcc dot gnu.org
2012-09-28 13:36 ` dodji at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu.org @ 2012-09-28 13:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54372
--- Comment #7 from Dodji Seketeli <dodji at gcc dot gnu.org> 2012-09-28 13:32:52 UTC ---
Author: dodji
Date: Fri Sep 28 13:32:41 2012
New Revision: 191830
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191830
Log:
PR c++/54372 - unused attribute inactive on dependant entities
In the example of this patch, gcc/g++ invoked with
-Wunused-local-typedefs warns on dependant entities even when those
are decorated with the 'unused' attribute.
This is because in cplus_decl_attributes, save_template_attributes
makes so that the 'unused' attribute is applied to its appertaining
entity only at instantiation time. But then at parsing time
maybe_warn_unused_local_typedefs checks for TREE_USED before warning.
This patch applies the 'unused' attribute at compilation time.
Tested on x86_64-unknown-linux-gnu against trunk.
gcc/cp/
* decl2.c (is_late_template_attribute): "unused" attribute is to
be applied at compile time.
gcc/testsuite/
* c-c++-common/Wunused-local-typedefs-2.c: New test.
Added:
trunk/gcc/testsuite/c-c++-common/Wunused-local-typedefs-2.c
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl2.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/54372] __attribute__((unused)) doesn't work with unused local typedef in template function.
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
` (6 preceding siblings ...)
2012-09-28 13:33 ` dodji at gcc dot gnu.org
@ 2012-09-28 13:36 ` dodji at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu.org @ 2012-09-28 13:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54372
Dodji Seketeli <dodji at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #8 from Dodji Seketeli <dodji at gcc dot gnu.org> 2012-09-28 13:35:49 UTC ---
Fixed in trunk (4.8)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-09-28 13:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-25 7:16 [Bug c++/54372] New: __attribute__((unused)) doesn't work with unused local typedef in template function flast at flast dot jp
2012-08-25 7:18 ` [Bug c++/54372] " flast at flast dot jp
2012-09-18 12:39 ` paolo.carlini at oracle dot com
2012-09-20 11:27 ` dodji at gcc dot gnu.org
2012-09-20 11:59 ` paolo.carlini at oracle dot com
2012-09-20 14:14 ` dodji at seketeli dot org
2012-09-22 13:07 ` flast at flast dot jp
2012-09-28 13:33 ` dodji at gcc dot gnu.org
2012-09-28 13:36 ` dodji at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).