EricWF added a comment. In https://reviews.llvm.org/D29877#766196, @EricWF wrote:
> In https://reviews.llvm.org/D29877#766176, @rsmith wrote: > > > In https://reviews.llvm.org/D29877#765968, @EricWF wrote: > > > > > I think this patch still gets the following case wrong: > > > > > > // foo.h > > > constexpr struct { > > > template <class T> void operator()(T) {} // emits unused template > > > warning > > > } foo; > > > > > > > > > What specifically do you think is wrong here? There is an unused internal > > linkage function template here. If we want to warn on unused internal > > linkage templates declared in headers, we should warn on this one. > > > I was confused about the linkage initially. My mistake. Should adding > `inline` here change that? No, it does not. Unnamed classes and their members can never have external linkage. > > >> Note that any use of `foo` here from an inline function would result in ODR >> violations (because you get a different `foo` in each translation unit), so >> it's probably at least a bad idea to do that. We could suppress this warning >> for unused internal linkage templates declared in headers, or maybe move >> that to a separate warning flag; can you point us at some code that does >> this in practice and isn't wrong? > > No. But I can point you to `range-v3` which uses this pattern and I think the > idiom is somewhat appealing, but that's orthogonal to Clang diagnosing it. It seems like simply naming the type avoids the linkage problems. I feel silly now. https://reviews.llvm.org/D29877 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits