diff options
author | Jason Merrill <jason@redhat.com> | 2018-04-04 15:10:32 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-04-04 15:10:32 -0400 |
commit | 3dba92a96d5d11dbf34f5d92cec63739657c5369 (patch) | |
tree | 42f0b87c60b57eb3fc51541173e027b64922dfb7 | |
parent | f4d43ef08641f6ffd48532a165a043eead1e4b3a (diff) | |
download | gcc-3dba92a96d5d11dbf34f5d92cec63739657c5369.zip gcc-3dba92a96d5d11dbf34f5d92cec63739657c5369.tar.gz gcc-3dba92a96d5d11dbf34f5d92cec63739657c5369.tar.bz2 |
PR c++/84221 - bogus -Wunused with attribute and template.
* decl2.c (is_late_template_attribute): Handle unused and used
normally on non-TYPE_DECL.
From-SVN: r259098
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wunused-var-32.C | 9 |
3 files changed, 18 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 261bd06..9b75419 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-04-04 Jason Merrill <jason@redhat.com> + PR c++/84221 - bogus -Wunused with attribute and template. + * decl2.c (is_late_template_attribute): Handle unused and used + normally on non-TYPE_DECL. + PR c++/85135 - ICE with omitted template arguments. * decl.c (grokdeclarator): Catch deduced class type in trailing return type. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 6ae6cef..6078fb6 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1145,10 +1145,11 @@ is_late_template_attribute (tree attr, tree decl) if (is_attribute_p ("weak", name)) return true; - /* Attributes used and unused are applied directly, as they appertain to - decls. */ - if (is_attribute_p ("unused", name) - || is_attribute_p ("used", name)) + /* Attributes used and unused are applied directly to typedefs for the + benefit of maybe_warn_unused_local_typedefs. */ + if (TREE_CODE (decl) == TYPE_DECL + && (is_attribute_p ("unused", name) + || is_attribute_p ("used", name))) return false; /* Attribute tls_model wants to modify the symtab. */ diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-32.C b/gcc/testsuite/g++.dg/warn/Wunused-var-32.C new file mode 100644 index 0000000..5558f93 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-var-32.C @@ -0,0 +1,9 @@ +// PR c++/84221 +// { dg-additional-options -Wunused } + +template <class T> struct __attribute((unused)) A { }; + +void f (void) +{ + A<int> a; // shouldn't warn +} |