[PATCH] D29877: Warn about unused static file scope function template declarations.

Richard Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 26 15:14:37 PDT 2017

rsmith added a comment.

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.

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?


More information about the cfe-commits mailing list