From bbff63af019632111032b9c6169e59fcaef47c81 Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 18 Jun 2017 04:55:02 +0000 Subject: [PATCH] PR c++/60063 - -Wunused-local-typedefs and templates. * decl2.c (is_late_template_attribute): Return false for "used". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249347 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/decl2.c | 5 +++-- gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-4.C | 13 +++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d0825743e45..465e7d9ffe6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2017-06-17 Jason Merrill + PR c++/60063 - -Wunused-local-typedefs and templates. + * decl2.c (is_late_template_attribute): Return false for "used". + PR c++/70844 - -Wuseless-cast and inheriting constructor. * method.c (forward_parm): Suppress warn_useless_cast. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 69cb40f2998..72239ec6208 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1091,9 +1091,10 @@ 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 + /* Attributes used and unused are applied directly, as they appertain to decls. */ - if (is_attribute_p ("unused", name)) + if (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-local-typedefs-4.C b/gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-4.C new file mode 100644 index 00000000000..7efe1125477 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-4.C @@ -0,0 +1,13 @@ +// PR c++/60063 +// { dg-options -Wunused-local-typedefs } + +template struct S; + +void foo (int i) { + typedef __attribute__ ((used)) S X; +} + +template +void bar (T i) { + typedef __attribute__ ((used)) S Y; +} -- 2.11.4.GIT