* C++ PATCH for c++/60063, -Wunused-local-typedefs and attribute used
@ 2017-06-18 4:28 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-06-18 4:28 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
Attribute used isn't documented to apply to typedefs, but the
implementation allows it. We should handle it the same way in a
template, by applying it immediately rather than defer until
instantiation time.
Tested x86_64-pc-linux-gnu, applying to trunk and 7.
[-- Attachment #2: 60063.diff --]
[-- Type: text/plain, Size: 1384 bytes --]
commit 3c3deed6644421ec32a509df3ffdfc0010b31668
Author: Jason Merrill <jason@redhat.com>
Date: Fri Jun 16 23:30:35 2017 -0400
PR c++/60063 - -Wunused-local-typedefs and templates.
* decl2.c (is_late_template_attribute): Return false for "used".
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 69cb40f..72239ec 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 0000000..7efe112
--- /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 <class> struct S;
+
+void foo (int i) {
+ typedef __attribute__ ((used)) S<int> X;
+}
+
+template <class T>
+void bar (T i) {
+ typedef __attribute__ ((used)) S<T> Y;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-18 4:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-18 4:28 C++ PATCH for c++/60063, -Wunused-local-typedefs and attribute used Jason Merrill
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).