[PATCH] D114382: [clang] Fix wrong -Wunused-local-typedef warning within a template function

Kristina Bessonova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 14 11:48:55 PDT 2022


krisb added inline comments.


================
Comment at: clang/test/SemaCXX/warn-unused-local-typedef.cpp:246
+      typedef int Int; // no-diag
+      typedef char Char; // expected-warning {{unused typedef 'Char'}}
+      Int m;
----------------
krisb wrote:
> Quuxplusone wrote:
> > I haven't tried to understand the main point of this PR, but FWIW, have you seen https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61596 ? This looks suspiciously like that exact case. (I just filed its dup https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104792 the other day.)
> This patch prevents clang from warning on used typedefs (`Int` case), if those typedefs are defined within a local class of a templated function or a member function of a templated class.
> For `Char` case, which is unused in this example, the patch changes nothing.
> 
> Regarding https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104792, those typedefs seem well known, so could we just make clang skipping any checks for those particular names?
> Alternatively, we would likely need to stop warning on any typedefs defined within a function-local class (but those warnings may still be useful like in the test from this patch).
@Quuxplusone if you do not have objections for this patch, I'd land it now. It'll make things a bit better and do not prevent us from relaxing conditions for the warning further.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114382/new/

https://reviews.llvm.org/D114382



More information about the cfe-commits mailing list