diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3ba5de4eb7a5e22413b499dba06d4d6cb2c28216..6550e16c654daa7698c3e4eee37e687f83da5b44 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-09-28 Dodji Seketeli <dodji@redhat.com> + + PR c++/54372 - unused attribute inactive on dependant entities + * decl2.c (is_late_template_attribute): "unused" attribute is to + be applied at compile time. + 2012-09-25 Dodji Seketeli <dodji@redhat.com> PR c++/29028 - Missed unused warning on using declaration diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 0df461340bc53aed831aa719aaec7764660723c2..a590d1781561f1a5e29119ce73866576445547b1 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1104,6 +1104,11 @@ is_late_template_attribute (tree attr, tree decl) if (is_attribute_p ("weak", name)) return true; + /* Attribute unused is applied directly, as it appertains to + decls. */ + if (is_attribute_p ("unused", name)) + return false; + /* If any of the arguments are dependent expressions, we can't evaluate the attribute until instantiation time. */ for (arg = args; arg; arg = TREE_CHAIN (arg)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 407184d17bedb1897d884cb3c81adbedbd21abcb..22ff3f58ef0fa1c5ff2c7b691172c486d4279d41 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-09-28 Dodji Seketeli <dodji@redhat.com> + + PR c++/54372 - unused attribute inactive on dependant entities + * c-c++-common/Wunused-local-typedefs-2.c: New test. + 2012-09-25 Dodji Seketeli <dodji@redhat.com> PR c++/29028 - Missed unused warning on using declaration diff --git a/gcc/testsuite/c-c++-common/Wunused-local-typedefs-2.c b/gcc/testsuite/c-c++-common/Wunused-local-typedefs-2.c new file mode 100644 index 0000000000000000000000000000000000000000..77bacd788baf1ea86a56f24f051564b5c03b5b0c --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wunused-local-typedefs-2.c @@ -0,0 +1,35 @@ +/* Origin PR c++/54372 + { dg-options "-Wunused-local-typedefs" } + { dg-do compile } +*/ + +template <typename T> +void f2() +{ + typedef T t __attribute__((unused)); +} + +class S +{ + template <typename T> + void f4() + { + typedef T t __attribute__((unused)); + } +}; + +template <typename T> +class tS +{ + void f() + { + typedef T t2 __attribute__((unused)); + } + + template <typename U> + void f2() + { + typedef T t1 __attribute__((unused)); + typedef U t2 __attribute__((unused)); + } +};