Comments
Patch
@@ -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 ("unused", DECL_ATTRIBUTES (decl)))
warning_at (DECL_SOURCE_LOCATION (decl),
OPT_Wunused_local_typedefs,
"typedef %qD locally defined but not used", decl);
new file mode 100644
@@ -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));
+ }
+};